Views
No views yet
molcrawl-rna-gpt2-small pre-trained model.1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4model = AutoModelForCausalLM.from_pretrained("kojima-lab/molcrawl-rna-celltype-gpt2-small")
5tokenizer = AutoTokenizer.from_pretrained("kojima-lab/molcrawl-rna-celltype-gpt2-small")
6
7# Generate next gene-id tokens (RNA gene-list model)
8prompt = "ENSG00000000003 ENSG00000000005 ENSG00000000419"
9inputs = tokenizer(prompt, return_tensors="pt")
10with torch.no_grad():
11 output_ids = model.generate(
12 **inputs,
13 max_new_tokens=50,
14 do_sample=True,
15 temperature=0.8,
16 eos_token_id=None, # HF config.json has legacy eos_token_id=0; disable early stop
17 pad_token_id=0,
18 )
19print(tokenizer.decode(output_ids[0], skip_special_tokens=True))
201@misc{molcrawl_rna_celltype_gpt2_small,
2 title={molcrawl-rna-celltype-gpt2-small},
3 author={{RIKEN}},
4 year={2026},
5 publisher={{Hugging Face}},
6 url={{https://huggingface.co/kojima-lab/molcrawl-rna-celltype-gpt2-small}}
7}convert_tokens_to_ids to encode a
prefix, then ask the model for the next gene.1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3
4REPO_ID = "kojima-lab/molcrawl-rna-celltype-gpt2-small"
5tokenizer = AutoTokenizer.from_pretrained(REPO_ID)
6model = AutoModelForCausalLM.from_pretrained(REPO_ID)
7model.eval()
8
9# Prefix sequence of ENSEMBL gene IDs (Geneformer-style ranked input)
10genes = [
11 "ENSG00000000003",
12 "ENSG00000000005",
13 "ENSG00000001167",
14 "ENSG00000002586",
15]
16ids = tokenizer.convert_tokens_to_ids(genes)
17input_ids = torch.tensor([ids])
18
19with torch.no_grad():
20 outputs = model(input_ids=input_ids)
21
22# Next-token (next-gene) prediction
23next_id = outputs.logits[0, -1].argmax(dim=-1).item()
24next_gene = tokenizer.convert_ids_to_tokens([next_id])[0]
25print(f"Predicted next gene: {next_gene}")
26# => Predicted next gene: LCE1F