1 {
2 "Biomarkers_abbreviations" : [ "HbA1c" , "CRP" ] ,
3 "Biomarkers_full_name" : [ "Hemoglobin A1c" , "C-Reactive Protein" , "troponin I" ] ,
4 "All_biomarkers" : [ "HbA1c" , "Hemoglobin A1c" , "CRP" , "C-Reactive Protein" , "troponin I" ]
5 }
Qwen/Qwen3.5-0.8B
└── v1 (1K biomarker NER samples) → loss 1.645
└── v1.1 (1K Nemotron-labeled, JSON output) → loss 1.051 ← THIS MODEL
Method: LoRA (bf16, NOT 4-bit — per Unsloth Qwen3.5 guidelines)
LoRA rank: 16, alpha: 16
Learning rate: 1e-4 (cosine scheduler)
Batch size: 8 (gradient accumulation 2, effective 16)
Epochs: 3
Optimizer: adamw_8bit
Sequence length: 2048
Framework: Unsloth + TRL SFTTrainer
Hardware: NVIDIA RTX A6000 (48GB), ~11 minutes
1 from unsloth import FastLanguageModel
2 from transformers import AutoTokenizer
3 import torch
4
5 model , tokenizer = FastLanguageModel . from_pretrained (
6 model_name = "Shubh-0789/biomarker-qwen3.5-0.8b-lora-v1.1" ,
7 max_seq_length = 2048 ,
8 load_in_4bit = False ,
9 load_in_16bit = True ,
10 dtype = torch . bfloat16 ,
11 )
12 text_tokenizer = AutoTokenizer . from_pretrained ( "Shubh-0789/biomarker-qwen3.5-0.8b-lora-v1.1" )
13 FastLanguageModel . for_inference ( model )
14 model . generation_config . pad_token_id = text_tokenizer . pad_token_id
15
16 messages = [
17 { "role" : "user" , "content" : "Extract all biomarker names from the following clinical text. Return ONLY a JSON.\nText: The patient's HbA1c was 7.2%, C-Reactive Protein (CRP) levels elevated at 15mg/L, and troponin I was within normal range." }
18 ]
19
20 inputs = text_tokenizer . apply_chat_template (
21 messages , tokenize = True , add_generation_prompt = True ,
22 return_tensors = "pt" , return_dict = True ,
23 ) . to ( model . device )
24
25 with torch . no_grad ( ) :
26 outputs = model . generate ( ** inputs , max_new_tokens = 256 , temperature = 0.1 , do_sample = True )
27
28 result = text_tokenizer . decode ( outputs [ 0 ] [ inputs [ "input_ids" ] . shape [ 1 ] : ] , skip_special_tokens = True )
29 print ( result )
30 # {"Biomarkers_abbreviations": ["HbA1c", "CRP"], "Biomarkers_full_name": ["Hemoglobin A1c", "C-Reactive Protein", "troponin I"], "All_biomarkers": ["HbA1c", "Hemoglobin A1c", "CRP", "C-Reactive Protein", "troponin I"]}
1 from peft import PeftModel
2 from transformers import AutoModelForCausalLM , AutoTokenizer
3
4 base_model = AutoModelForCausalLM . from_pretrained ( "Qwen/Qwen3.5-0.8B" , torch_dtype = "bfloat16" , device_map = "auto" )
5 model = PeftModel . from_pretrained ( base_model , "Shubh-0789/biomarker-qwen3.5-0.8b-lora-v1.1" )
6 tokenizer = AutoTokenizer . from_pretrained ( "Shubh-0789/biomarker-qwen3.5-0.8b-lora-v1.1" )