The model is finetuned from ProtBert-BFD using unpaired antibody sequences from the
Observed Antibody Space
.
Use
The model and tokeniser can be loaded using the
transformers
library
from transformers import BertModel, BertTokenizer
tokeniser = BertTokenizer.from_pretrained("Exscientia/IgBert_unpaired", do_lower_case=False)
model = BertModel.from_pretrained("Exscientia/IgBert_unpaired", add_pooling_layer=False)
The tokeniser is used to prepare batch inputs
# single chain sequences
sequences = [
"EVVMTQSPASLSVSPGERATLSCRARASLGISTDLAWYQQRPGQAPRLLIYGASTRATGIPARFSGSGSGTEFTLTISSLQSEDSAVYYCQQYSNWPLTFGGGTKVEIK",
"ALTQPASVSGSPGQSITISCTGTSSDVGGYNYVSWYQQHPGKAPKLMIYDVSKRPSGVSNRFSGSKSGNTASLTISGLQSEDEADYYCNSLTSISTWVFGGGTKLTVL"
]
# The tokeniser expects input of the form ["E V V M...", "A L T Q..."]
sequences = [' '.join(sequence) for sequence in sequences]
tokens = tokeniser.batch_encode_plus(
sequences,
add_special_tokens=True,
pad_to_max_length=True,
return_tensors="pt",
return_special_tokens_mask=True
)
Note that the tokeniser adds a
[CLS]
token at the beginning of each sequence, a
[SEP]
token at the end of each sequence and pads using the
[PAD]
token. For example a batch containing sequences
E V V M
,
A L
will be tokenised to
[CLS] E V V M [SEP]
and
[CLS] A L [SEP] [PAD] [PAD]
.
Sequence embeddings are generated by feeding tokens through the model
To obtain a sequence representation, the residue tokens can be averaged over like so
import torch
# mask special tokens before summing over embeddings
residue_embeddings[tokens["special_tokens_mask"] == 1] = 0
sequence_embeddings_sum = residue_embeddings.sum(1)
# average embedding by dividing sum by sequence lengths
sequence_lengths = torch.sum(tokens["special_tokens_mask"] == 0, dim=1)
sequence_embeddings = sequence_embeddings_sum / sequence_lengths.unsqueeze(1)
For sequence level fine-tuning the model can be loaded with a pooling head by setting
add_pooling_layer=True
and using
output.pooler_output
in the down-stream task.
Runs of Exscientia IgBert_unpaired on huggingface.co
9.6K
Total runs
0
24-hour runs
562
3-day runs
568
7-day runs
8.8K
30-day runs
More Information About IgBert_unpaired huggingface.co Model
IgBert_unpaired huggingface.co is an AI model on huggingface.co that provides IgBert_unpaired's model effect (), which can be used instantly with this Exscientia IgBert_unpaired model. huggingface.co supports a free trial of the IgBert_unpaired model, and also provides paid use of the IgBert_unpaired. Support call IgBert_unpaired model through api, including Node.js, Python, http.
IgBert_unpaired huggingface.co is an online trial and call api platform, which integrates IgBert_unpaired's modeling effects, including api services, and provides a free online trial of IgBert_unpaired, you can try IgBert_unpaired online for free by clicking the link below.
Exscientia IgBert_unpaired online free url in huggingface.co:
IgBert_unpaired is an open source model from GitHub that offers a free installation service, and any user can find IgBert_unpaired on GitHub to install. At the same time, huggingface.co provides the effect of IgBert_unpaired install, users can directly use IgBert_unpaired installed effect in huggingface.co for debugging and trial. It also supports api for free installation.