Views
No views yet
[V:TRBV20-1], [V:TRAV1-2], …) + [V_UNK]
= 128 total. It is built for the input grammar [V:gene] | CDR3, where the atomic V token stands in for the
germline CDR1/CDR2 (which the V gene determines).tokenizer.json, vocab.txt, added_tokens.json, …) + vgene_map.json — a map
from a raw V-gene symbol to its atomic token ("TRBV20-1" -> "[V:TRBV20-1]"; unknown → [V_UNK]).1import json
2from huggingface_hub import hf_hub_download
3from transformers import AutoTokenizer
4
5tok = AutoTokenizer.from_pretrained("argentel/tcr-vtoken") # base AA + V-gene tokens (128)
6vmap = json.load(open(hf_hub_download("argentel/tcr-vtoken", "vgene_map.json"))) # raw V-gene -> token
7
8v_gene, cdr3 = "TRBV20-1", "CASSYSTDTQYF"
9vtok = vmap.get(v_gene, "[V_UNK]") # atomic V token
10text = f"{vtok} {tok.sep_token} {' '.join(cdr3)}" # "[V:TRBV20-1] | C A S S ..."
11enc = tok(text)
12print(tok.convert_ids_to_tokens(enc["input_ids"]))
13# ['*', '[V:TRBV20-1]', '|', 'C', 'A', 'S', 'S', 'Y', 'S', 'T', 'D', 'T', 'Q', 'Y', 'F', '|']
14# *=[CLS] and |=[SEP] are added automatically; [V:TRBV20-1] is ONE atomic token.
15print(tok.convert_tokens_to_ids("[V:TRBV20-1]")) # 87 (V tokens have ids >= 26)added_tokens.json (ids 26–127), not vocab.txt (which is only the 26 base tokens);
AutoTokenizer merges both, so len(tok) == 128.