BioMegatron
is a transformer developed by the Applied Deep Learning Research team at NVIDIA. This particular Megatron model trained on top of the Megatron-LM model, adding a PubMed corpusto the Megatron-LM corpora(Wikipedia, RealNews, OpenWebText, and CC-Stories). BioMegatron follows a similar (albeit not identical) architecture as BERT and it has 345 million parameters:
We provide in the repository an alternative version of the
python script
in order to any user to cross-check the validity of the model replicated in this repository.
import os
import torch
from convert_biomegatron_checkpoint import convert_megatron_checkpoint
print_checkpoint_structure = True
path_to_checkpoint = "/path/to/BioMegatron345mUncased/"# Extract the basename.
basename = os.path.dirname(path_to_checkpoint).split('/')[-1]
# Load the model.
input_state_dict = torch.load(os.path.join(path_to_checkpoint, 'model_optim_rng.pt'), map_location="cpu")
# Convert.print("Converting")
output_state_dict, output_config = convert_megatron_checkpoint(input_state_dict, head_model=False)
# Print the structure of converted state dict.if print_checkpoint_structure:
recursive_print(None, output_state_dict)
# Store the config to file.
output_config_file = os.path.join(path_to_checkpoint, "config.json")
print(f'Saving config to "{output_config_file}"')
withopen(output_config_file, "w") as f:
json.dump(output_config, f)
# Store the state_dict to file.
output_checkpoint_file = os.path.join(path_to_checkpoint, "pytorch_model.bin")
print(f'Saving checkpoint to "{output_checkpoint_file}"')
torch.save(output_state_dict, output_checkpoint_file)
BioMegatron can be run with the standard 🤗 script for loading models. Here we show an example identical to that of
nvidia/megatron-bert-uncased-345m
.
import os
import torch
from transformers import BertTokenizer, MegatronBertForMaskedLM, AutoModelForMaskedLM
checkpoint = "EMBO/BioMegatron345mUncased"# The tokenizer. Megatron was trained with standard tokenizer(s).
tokenizer = BertTokenizer.from_pretrained(checkpoint)
# Load the model from $MYDIR/nvidia/megatron-bert-uncased-345m.
model = AutoModelForMaskedLM.from_pretrained(checkpoint)
device = torch.device("cpu")
# Create inputs (from the BERT example page).input = tokenizer("The capital of France is [MASK]", return_tensors="pt").to(device)
label = tokenizer("The capital of France is Paris", return_tensors="pt")["input_ids"].to(device)
# Run the model.with torch.no_grad():
output = model(**input, labels=label)
print(output)
Limitations
This implementation has not been fine-tuned in any task. It has only the weights of the official nVIDIA checkpoint. It needs to be trained to perform any downstream task.
BioMegatron345mUncased huggingface.co is an AI model on huggingface.co that provides BioMegatron345mUncased's model effect (), which can be used instantly with this EMBO BioMegatron345mUncased model. huggingface.co supports a free trial of the BioMegatron345mUncased model, and also provides paid use of the BioMegatron345mUncased. Support call BioMegatron345mUncased model through api, including Node.js, Python, http.
BioMegatron345mUncased huggingface.co is an online trial and call api platform, which integrates BioMegatron345mUncased's modeling effects, including api services, and provides a free online trial of BioMegatron345mUncased, you can try BioMegatron345mUncased online for free by clicking the link below.
EMBO BioMegatron345mUncased online free url in huggingface.co:
BioMegatron345mUncased is an open source model from GitHub that offers a free installation service, and any user can find BioMegatron345mUncased on GitHub to install. At the same time, huggingface.co provides the effect of BioMegatron345mUncased install, users can directly use BioMegatron345mUncased installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
BioMegatron345mUncased install url in huggingface.co: