Task: Binary classification - detect genomic islands (horizontally transferred genes).
1from peft import PeftModel
2from transformers import AutoModelForCausalLM, AutoTokenizer
3import torch
4
5base = AutoModelForCausalLM.from_pretrained('yahmaachi/omni-dna-multitask-1b')
6tokenizer = AutoTokenizer.from_pretrained('yahmaachi/omni-dna-multitask-1b')
7tokenizer.add_tokens(['HGT_detection'])
8base.resize_token_embeddings(len(tokenizer))
9
10model = PeftModel.from_pretrained(base, 'Nhoodie/omni-dna-hgt-lora-best')
11model.eval()
12
13dna = 'ATGCGATCGATCGATCGATC...' # your sequence
14inputs = tokenizer(dna + 'HGT_detection', return_tensors='pt')
15with torch.no_grad():
16 logits = model(**inputs).logits[:, -1, :]
17 prob = torch.softmax(logits, dim=-1)
18 # token 4097 = 1 (HGT), token 4096 = 0 (not HGT)
19 hgt_prob = prob[0, 4097].item()
20print(f'HGT probability: {hgt_prob:.4f}')
The training exhibited an interesting collapse-recovery pattern: after initial overfitting
around epoch 2-3.4, the novel token (HGT_detection, #4117) underwent a representational
reorganization, leading to a new best AUC of 0.8736 at step 1300.
Steps 1300 and 1500 are sibling models - different representational equilibria rather than
descendant relationships. Step 1300 optimizes ranking (AUC), step 1500 optimizes classification (F1).