1 {
2 "endpoints" : [
3 {
4 "endpoint_name_standardized" : "Objective Response Rate" ,
5 "measurement_of" : "tumor response" ,
6 "measurement_type" : "binary" ,
7 "metric_type" : "proportion" ,
8 "timeframe" : "Week 24" ,
9 "measurement_method" : "RECIST v1.1" ,
10 "evaluation_criteria" : "CR or PR" ,
11 "unit" : "%" ,
12 "population" : null ,
13 "is_composite" : false ,
14 "components" : [ ]
15 }
16 ]
17 }
Method: LoRA (bf16, NOT 4-bit)
LoRA rank: 16, alpha: 16
Learning rate: 2e-4 (cosine)
Batch size: 2 (gradient accumulation 8, effective 16)
Epochs: 3
Optimizer: adamw_8bit
Sequence length: 2048
Gradient checkpointing: unsloth
1 import json
2 from unsloth import FastLanguageModel
3 from transformers import AutoTokenizer
4 import torch
5
6 model , tokenizer = FastLanguageModel . from_pretrained (
7 model_name = "Shubh-0789/endpoint-qwen3.5-4b-lora" ,
8 max_seq_length = 2048 ,
9 load_in_4bit = False ,
10 load_in_16bit = True ,
11 dtype = torch . bfloat16 ,
12 )
13 text_tokenizer = AutoTokenizer . from_pretrained ( "Shubh-0789/endpoint-qwen3.5-4b-lora" )
14 FastLanguageModel . for_inference ( model )
15 model . generation_config . pad_token_id = text_tokenizer . pad_token_id
16
17 clinical_text = "Primary endpoints are ORR and progression-free survival (PFS) assessed by RECIST v1.1 | [Time Frame: Up to 24 months]"
18
19 messages = [
20 { "role" : "user" , "content" : f"Extract and classify the clinical trial endpoint from the following text. Return ONLY a JSON.\nText: { clinical_text } " }
21 ]
22
23 inputs = text_tokenizer . apply_chat_template (
24 messages , tokenize = True , add_generation_prompt = True ,
25 return_tensors = "pt" , return_dict = True ,
26 ) . to ( model . device )
27
28 with torch . no_grad ( ) :
29 outputs = model . generate ( ** inputs , max_new_tokens = 512 , temperature = 0.1 , do_sample = True )
30
31 result = text_tokenizer . decode ( outputs [ 0 ] [ inputs [ "input_ids" ] . shape [ 1 ] : ] , skip_special_tokens = True )
32 endpoints = json . loads ( result )
33 print ( json . dumps ( endpoints , indent = 2 ) )
1 {
2 "endpoints" : [
3 {
4 "endpoint_name_standardized" : "Objective Response Rate" ,
5 "measurement_of" : "tumor response" ,
6 "measurement_type" : "binary" ,
7 "metric_type" : "proportion" ,
8 "timeframe" : "Up to 24 months" ,
9 "measurement_method" : "RECIST v1.1" ,
10 "evaluation_criteria" : null ,
11 "unit" : "%" ,
12 "population" : null ,
13 "is_composite" : false ,
14 "components" : [ ]
15 } ,
16 {
17 "endpoint_name_standardized" : "Progression-Free Survival" ,
18 "measurement_of" : "disease progression or death" ,
19 "measurement_type" : "time-to-event" ,
20 "metric_type" : "hazard ratio" ,
21 "timeframe" : "Up to 24 months" ,
22 "measurement_method" : "RECIST v1.1" ,
23 "evaluation_criteria" : null ,
24 "unit" : null ,
25 "population" : null ,
26 "is_composite" : false ,
27 "components" : [ ]
28 }
29 ]
30 }
1 from peft import PeftModel
2 from transformers import AutoModelForCausalLM , AutoTokenizer
3
4 base_model = AutoModelForCausalLM . from_pretrained ( "Qwen/Qwen3.5-4B" , torch_dtype = "bfloat16" , device_map = "auto" )
5 model = PeftModel . from_pretrained ( base_model , "Shubh-0789/endpoint-qwen3.5-4b-lora" )
6 tokenizer = AutoTokenizer . from_pretrained ( "Shubh-0789/endpoint-qwen3.5-4b-lora" )
@misc{endpoint-qwen3.5-4b-lora,
author = {Shubh-0789},
title = {Clinical Trial Endpoint Classifier — 4B (Qwen3.5-4B LoRA)},
year = {2026},
publisher = {Hugging Face},
url = {https://huggingface.co/Shubh-0789/endpoint-qwen3.5-4b-lora}
}