Downloads · 30 days
0
vab46/llama-3.1-8b-instruct-lora-clinical_iter2_epoch2
llama-3.1-8b-instruct-lora-clinical_iter2_epoch2 is a machine learning model from vab46. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This model is a PEFT/LoRA adapter single epoch fine-tuned on top of meta-llama/Llama-3.1-8B-Instruct. Fine tuning has been done on iter2 anchor-context-groundTruthjunkHandled dataset
Downloads · 30 days
0
Access
Public
Updated Sep 28, 2026
Repo size
526 MB
Likes
1
Public
Click a slice to open those files.
.safetensors168 MB · 62%
From the Hugging Face model README
This model is a PEFT/LoRA adapter single epoch fine-tuned on top of meta-llama/Llama-3.1-8B-Instruct. Fine tuning has been done on iter2 anchor-context-groundTruth_junkHandled dataset related to clinical trials. This fine tuned adapter on base LLM can be to address clinical trials related questions in general(macro/broad overview, patient eligiblity, operations etc related question). Further this can also be used for prompt engineering based on CT, or RAG generation(related to CT) based on retrieved chunks.
PeftModelForCausalLM(
(base_model): LoraModel(
(model): LlamaForCausalLM(
(model): LlamaModel(
(embed_tokens): Embedding(128256, 4096)
(layers): ModuleList(
(0-31): 32 x LlamaDecoderLayer(
(self_attn): LlamaAttention(
(q_proj): lora.Linear4bit(
(base_layer): Linear4bit(in_features=4096, out_features=4096, bias=False)
(lora_dropout): ModuleDict(
(default): Dropout(p=0.05, inplace=False)
)
(lora_A): ModuleDict(
(default): Linear(in_features=4096, out_features=16, bias=False)
)
(lora_B): ModuleDict(
(default): Linear(in_features=16, out_features=4096, bias=False)
)
(lora_embedding_A): ParameterDict()
(lora_embedding_B): ParameterDict()
(lora_magnitude_vector): ModuleDict()
)
(k_proj): lora.Linear4bit(
(base_layer): Linear4bit(in_features=4096, out_features=1024, bias=False)
(lora_dropout): ModuleDict(
(default): Dropout(p=0.05, inplace=False)
)
(lora_A): ModuleDict(
(default): Linear(in_features=4096, out_features=16, bias=False)
)
(lora_B): ModuleDict(
(default): Linear(in_features=16, out_features=1024, bias=False)
)
(lora_embedding_A): ParameterDict()
(lora_embedding_B): ParameterDict()
(lora_magnitude_vector): ModuleDict()
)
(v_proj): lora.Linear4bit(
(base_layer): Linear4bit(in_features=4096, out_features=1024, bias=False)
(lora_dropout): ModuleDict(
(default): Dropout(p=0.05, inplace=False)
)
(lora_A): ModuleDict(
(default): Linear(in_features=4096, out_features=16, bias=False)
)
(lora_B): ModuleDict(
(default): Linear(in_features=16, out_features=1024, bias=False)
)
(lora_embedding_A): ParameterDict()
(lora_embedding_B): ParameterDict()
(lora_magnitude_vector): ModuleDict()
)
(o_proj): lora.Linear4bit(
(base_layer): Linear4bit(in_features=4096, out_features=4096, bias=False)
(lora_dropout): ModuleDict(
(default): Dropout(p=0.05, inplace=False)
)
(lora_A): ModuleDict(
(default): Linear(in_features=4096, out_features=16, bias=False)
)
(lora_B): ModuleDict(
(default): Linear(in_features=16, out_features=4096, bias=False)
)
(lora_embedding_A): ParameterDict()
(lora_embedding_B): ParameterDict()
(lora_magnitude_vector): ModuleDict()
)
)
(mlp): LlamaMLP(
(gate_proj): lora.Linear4bit(
(base_layer): Linear4bit(in_features=4096, out_features=14336, bias=False)
(lora_dropout): ModuleDict(
(default): Dropout(p=0.05, inplace=False)
)
(lora_A): ModuleDict(
(default): Linear(in_features=4096, out_features=16, bias=False)
)
(lora_B): ModuleDict(
(default): Linear(in_features=16, out_features=14336, bias=False)
)
(lora_embedding_A): ParameterDict()
(lora_embedding_B): ParameterDict()
(lora_magnitude_vector): ModuleDict()
)
(up_proj): lora.Linear4bit(
(base_layer): Linear4bit(in_features=4096, out_features=14336, bias=False)
(lora_dropout): ModuleDict(
(default): Dropout(p=0.05, inplace=False)
)
(lora_A): ModuleDict(
(default): Linear(in_features=4096, out_features=16, bias=False)
)
(lora_B): ModuleDict(
(default): Linear(in_features=16, out_features=14336, bias=False)
)
(lora_embedding_A): ParameterDict()
(lora_embedding_B): ParameterDict()
(lora_magnitude_vector): ModuleDict()
)
(down_proj): lora.Linear4bit(
(base_layer): Linear4bit(in_features=14336, out_features=4096, bias=False)
(lora_dropout): ModuleDict(
(default): Dropout(p=0.05, inplace=False)
)
(lora_A): ModuleDict(
(default): Linear(in_features=14336, out_features=16, bias=False)
)
(lora_B): ModuleDict(
(default): Linear(in_features=16, out_features=4096, bias=False)
)
(lora_embedding_A): ParameterDict()
(lora_embedding_B): ParameterDict()
(lora_magnitude_vector): ModuleDict()
)
(act_fn): SiLUActivation()
)
(input_layernorm): LlamaRMSNorm((4096,), eps=1e-05)
(post_attention_layernorm): LlamaRMSNorm((4096,), eps=1e-05)
)
)
(norm): LlamaRMSNorm((4096,), eps=1e-05)
(rotary_emb): LlamaRotaryEmbedding()
)
(lm_head): Linear(in_features=4096, out_features=128256, bias=False)
)
)
)
You can load this model using bitsandbytes for 4-bit quantization and peft to apply the adapter weights. Tokenizer formatting utilizes the base model's official chat template to map query/question tokens alongside retrieved context blocks.
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
from peft import PeftModel
MODEL_ID = "meta-llama/Llama-3.1-8B-Instruct"
# 1. Load the tokenizer from the base model
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
# 2. Configure 4-bit quantization
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_use_double_quant=True
)
# 3. Load quantized base model
base_model = AutoModelForCausalLM.from_pretrained(
MODEL_ID,
quantization_config=bnb_config,
device_map="auto",
torch_dtype=torch.float16
)
# 4. Load your current LoRA fine-tuned adapter
model = PeftModel.from_pretrained(
base_model,
"vab46/llama-3.1-8b-instruct-lora-clinical_iter2_epoch2"
)
model.eval()
# ==========================================
# 5. STRUCTURE RAG PROMPTS WITH CHAT TEMPLATE
# ==========================================
# Mapping the query/question with relevant context chunks into the message schema
SYSTEM_PROMPT = "You are a helpful assistant specialized in clinical data analysis."
retrieved_context = "..." # Paste or map your retrieved context blocks here
user_query = "..." # Paste your question/anchor here
messages = [
{"role": "system", "content": SYSTEM_PROMPT},
{
"role": "user",
"content": f"CONTEXT(RETRIEVED_BLOCKS):
CONTEXT:
TITLE: WATCH-STEP : Pilot Trial: Smartwatch-Guided Secondary Prevention After Stroke Randomized Trial of Nurse-led Program With Active vs Passive Smartwatch in Minor Stroke. A Randomized Controlled Trial Evaluating a Nurse-led Secondary Prevention and Physical Activity Program Supported by Either an Active Smartwatch (Structured Feedback) or Passive Smartwatch in Patients With Minor Stroke.
SUMMARY: After a first stroke or transient ischemic attack (TIA), the risk of recurrence is high in the weeks and months following the initial event. There are several modifiable risk factors that can reduce this risk, such as blood pressure, diet, physical activity, and smoking. Many stroke patients (NIHSS \< 5) have a low daily step count during the early recovery period, despite a good functional prognosis.
Active smartwatches provide real-time feedback, track progress, and set personalized walking goals, thereby boosting motivation and adherence to physical activity recommendations.
The combination of advice provided by nurses and active behavioral coaching supported by a smartwatch, compared to passive monitoring, could significantly increase daily step counts over a 12-week period. The results of this research will help guide future large-scale secondary prevention strategies integrating digital health and structured nursing support.
INCLUSION_CRITERIA:
Age ≤ 40-75
Patients with recent minor ischemic stroke or TIA, initial NIHSS ≤5 (\< 30 days)
mRS ≤2 before stroke and on discharge
Patient with Wifi access (for data transmission)
Able to understand smartwatch instructions
Written informed consent
Ambulatory ≥10 meters without assistance and without walking aid
Expected to live at home during the study period.
QUESTION:
What is the main goal of this clinical trial regarding secondary prevention after a minor stroke?"
}
]
# Apply Llama 3.1 specific formatting tokens automatically
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
return_tensors="pt"
).to(model.device)
# Generate response
with torch.no_grad():
outputs = model.generate(
inputs,
max_new_tokens=512,
eos_token_id=tokenizer.eos_token_id
)
response = tokenizer.decode(outputs[0][inputs.shape[-1]:], skip_special_tokens=True)
print("RELEVANT_ANSWER(generated by LLM):", response)
| question_type | examples | base_rougeL | lora_rougeL | base_bertscore | lora_bertscore | base_num_ground | lora_num_ground | base_num_recall | lora_num_recall |
|---|---|---|---|---|---|---|---|---|---|
| Eligibility / Qualification | 228 | 0.63521 | 0.655508 | 0.927499 | 0.932039 | 0.919022 | 0.907919 | 0.851973 | 0.871438 |
| Intervention | 64 | 0.662192 | 0.673651 | 0.943153 | 0.944862 | 0.996094 | 0.996875 | 0.889397 | 0.903348 |
| Numeric / Threshold | 37 | 0.68203 | 0.660298 | 0.942677 | 0.93895 | 0.953346 | 0.96686 | 0.897614 | 0.88217 |
| Other | 180 | 0.595429 | 0.598936 | 0.934205 | 0.934145 | 0.99037 | 0.991528 | 0.882738 | 0.881085 |
| Study Design | 227 | 0.823676 | 0.808107 | 0.967911 | 0.967096 | 0.987518 | 0.987518 | 0.965859 | 0.965859 |
| Temporal | 48 | 0.582274 | 0.569226 | 0.933253 | 0.930462 | 1 | 1 | 0.905556 | 0.859375 |
| Metric | Base | LoRA-1 |
|---|---|---|
| Mean context-support score | 0.44257 | 0.441146 |
| Mean low-support sentence rate | 0.022534 | 0.022534 |
| Mean numeric groundedness | 0.968105 | 0.965843 |
| Mean numeric recall | 0.900501 | 0.903364 |
| PAIRED ROUGE-L OUTCOMES | |
|---|---|
| rouge_winner | |
| Tie | 365 |
| LoRA | 211 |
| Base | 208 |
| Name: count, dtype: int64 | |
| PAIRED BERTSCORE OUTCOMES | |
| bertscore_winner | |
| LoRA | 275 |
| Base | 268 |
| Tie | 241 |
| Metric | Base | LoRA-1 | Absolute Δ | Relative Δ % |
|---|---|---|---|---|
| ROUGE-L | 0.681817 | 0.683128 | 0.001311 | 0.192302 |
| BERTScore-F1 | 0.943086 | 0.943949 | 0.000863 | 0.091516 |
| Numeric groundedness | 0.968105 | 0.965843 | -0.00226 | -0.2336 |
| Numeric recall | 0.900501 | 0.903364 | 0.002864 | 0.318008 |
| anchor | positive | reference_answer |
|---|---|---|
| What is the primary mechanism of action of BI 3031185 being investigated in this clinical trial? | TITLE: Safety, Tolerability and Pharmacokinetics of Single and Multiple Oral Doses of BI 3031185 in Japanese Healthy Male Trial Participants (Single-blind, Randomised, Placebo-controlled, Parallel Group Design) and Effect of Multiple Doses of BI 3031185 on Pharmacokinetics of a Single Dose of a Combination of Drospirenone and Ethinylestradiol (Oral Contraceptive) in Japanese Healthy Female Trial Participants (Non-randomised, Open-label, Fixed Sequence Design)<br>SUMMARY: Single dose (SD) part: The main objectives of this trial are to investigate safety, tolerability and pharmacokinetics (PK) of BI 3031185 in healthy male trial participants following oral administration of single dose.<br>Multiple doses (MD) part: The main objectives of this trial are to investigate safety, tolerability and pharmacokinetics (PK) of BI 3031185 in healthy male trial participants following oral administration of multiple doses.<br>Oral contraceptives (OC) part: The main objective of this trial is to investigate the effect of multiple oral doses of BI 3031185 on pharmacokinetics of drospirenone (DRSP) and ethinylestradiol (EE) (YAZ®) in Japanese healthy female trial participants.<br>INCLUSION_CRITERIA:<br>Single dose (SD) and multiple doses (MD) part: Healthy male trial participant according to the assessment of the investigator, as based on a complete medical history including a physical examination, vital signs (blood pressure (BP), pulse rate (PR)), 12- lead electrocardiogram (ECG), and clinical laboratory tests Oral contraceptives (OC) part: Women of non-childbearing potential (WONCBP) who meet postmenopausal or surgically sterilised according to the assessment of the investigator, as based on a complete medical history including a physical examination, vital signs (BP, PR), 12-lead ECG, and clinical laboratory tests<br>Postmenopausal, defined as no menses for 1 year without an alternative medical cause.<br>Surgically sterilised (including hysterectomy, bilateral salpingectomy, and bilateral oophorectomy)<br>SD and MD part: Age of 18 to 45 years (inclusive) OC part: Age of 18 to 64 years (inclusive)<br>Body mass index (BMI) of 18.5 to 29.9 kg/m2 (inclusive)<br>Signed and dated written informed consent in accordance with ICH-GCP and local legislation prior to admission to the trial | The provided context does not contain enough information to answer the question about BI 3031185's mechanism of action. The trial evaluates safety, tolerability, and pharmacokinetics after single and multiple oral doses, and examines effects on drospirenone and ethinylestradiol pharmacokinetics, but no mechanism is stated. |
| Are patients aged 50 or older eligible to participate in this observational study? | TITLE: Reduced Cell-mediated Immune Response to 2 Doses of an Adjuvanted Herpes Zoster Subunit Vaccine in Patients With Systemic Lupus Erythematosus\nSUMMARY: The goal of this observational study is to compare the vaccine response to the 2 doses of the adjuvanted herpes zoster subunit vaccine(HZ/su, "Shingrix") in patients with SLE and the age-, sex-, ethnicity-matched controls without autoimmune disease.\nINCLUSION_CRITERIA:\nMales or females ≥ 50 years of age at time of consent\n≥ 4 of the 1997 ACR13 or the 2012 SLICC/ACR criteria for SLE (14, 15)\nClinically stable SLE\nStable dose of one or more of the following immunosuppressive treatment ≥ 4 weeks\nCorticosteroid use: ≥ 5mg/day of prednisolone equivalent\nAntimalarials (≤ 400 mg/day)\nAzathioprine (≤ 3 mg/kg/day)\nMycophenolate mofetil (≤ 3 mg/day)\nTacrolimus (≤ 5mg/day)\nMethotrexate (≤ 20mg/week)\nCyclosphosphamide (≤ 1mg/BSA/month)\nMust be eligible for the indication of adjuvanted herpes zoster subunit vaccine\nMust understand and voluntarily sign an informed consent form including writing consent for data protection | { "could_qualify": true, "criteria": [ "Age ≥50 years", "Clinically stable SLE", "Meet ≥4 of the 1997 ACR or 2012 SLICC/ACR SLE criteria" ], "additional_criteria": [ "Stable qualifying immunosuppressive treatment for ≥4 weeks", "Eligible for HZ/su vaccination", "Provide informed consent" ] } |
| Is this clinical trial open to female football players? | TITLE: Pre- and Post-Training Assessment of Sprint Performance, Agility, Balance and Body Awareness in Football Players Regarding Hamstring Injury<br>SUMMARY: Aim of the study is to examine the impact of a history of hamstring injury on athletes by determining and comparing the pre- and post-training levels of sprint performance, agility, dynamic balance, and body awareness in football players with and without a history of hamstring injury.<br>INCLUSION_CRITERIA:<br>Being a licensed male football player aged 18-35.<br>Having played football actively for at least 2 years.<br>Having attended training sessions regularly within the last 6 months.<br>Having a history of hamstring injury (n=25).<br>Not having a history of hamstring injury (n=25).<br>Voluntarily agreeing to participate in the study. | False. The inclusion criteria specifically require licensed male football players aged 18–35 years. Participants must also have played football actively for at least 2 years, attended training regularly during the previous 6 months, and have either a history or no history of hamstring injury. |
| How many adults with a diagnosis of migraine will be randomized to either the HYlaMI intervention group or a waitlist control group in this study? | TITLE: Self-Hypnosis Training for Migraine Management (HYlaMI): A Pilot and Proof-of-Concept Study of the Intervention Program (ORBIT Phase IIa-IIb)<br>SUMMARY: Migraine is one of the most common and disabling neurological conditions worldwide, affecting approximately 1 billion people. Available pharmacological treatments have significant limitations (side effects, contraindications, medication overuse), highlighting the need for effective non-pharmacological alternatives.<br>The HYlaMI program (Self-Hypnosis Training for Migraine Management) is an 8-session group-based telehealth intervention adapted from HYlaDO, a self-hypnosis program developed for chronic pain management at the Hôpital Maisonneuve-Rosemont Pain Clinic (Montréal, Canada). Building on a refinement study conducted in autumn 2025 (CER: 2026-4061), HYlaMI combines heterohypnosis (guided by a trained clinician) and self-hypnosis (practiced autonomously at home using audio recordings) through weekly one-hour video sessions (Zoom/CIUSSS EMTL platform).<br>This study combines ORBIT Phase IIa (proof of concept) and Phase IIb (pilot study) objectives. The primary aims are to evaluate the feasibility of the HYlaMI program (retention and adherence rates) and to assess whether it can generate a clinically significant change in migraine-related disability compared to a waitlist control group. Secondary aims include evaluating effects on anxiety and depressive symptoms, pain self-efficacy, situational pain/anxiety/relaxation, migraine frequency, intensity and duration, medication intake, work absenteeism, quality of life, and the economic burden of migraine.<br>A mixed-methods design will be used. Forty adults with a diagnosis of migraine for more than one year will be randomized to either the HYlaMI intervention group (n=20) or a waitlist control group (n=20). Participants will complete validated questionnaires at multiple time points (pre-intervention, mid-intervention, post-intervention, and 4-week follow-up), a weekly migraine diary, and self-hypnosis practice logs. Two semi-structured focus groups will be conducted with intervention group participants to inform program improvement.<br>If successful, this study will provide the evidence base required to proceed to a larger randomized controlled trial (ORBIT Phase III).<br>INCLUSION_CRITERIA:<br>Formal diagnosis of migraine for more than one year (physician-issued; self-reported diagnosis accepted)<br>French-speaking<br>No consumption of alcohol or recreational drugs on the morning before group hypnosis sessions (migraine rescue medication is accepted but must be reported if taken before a session)<br>Reliable internet connection<br>Available to follow the 2.5-month self-hypnosis training program | 40 adults. Forty adults with a migraine diagnosis for more than one year will be randomized, with 20 assigned to HYlaMI and 20 to the waitlist control group. Other major criteria include being French-speaking, having reliable internet access, and being available for the 2.5-month self-hypnosis training program. |
The following configurations were used during training:
| Step | Training Loss | Validation Loss | Epochs |
|---|---|---|---|
| 1 | 0.5653 | - | 1 |
| 50 | 0.3279 | - | 1 |
| 100 | 0.2844 | - | 1 |
| 150 | 0.2629 | - | 1 |
| 200 | 0.2761 | - | 1 |
| 250 | 0.2551 | - | 1 |
| 300 | 0.2571 | - | 1 |
| 350 | 0.2497 | - | 1 |
| 400 | 0.2411 | - | 1 |
| 1 | 0.2513 | - | 2 |
| 50 | 0.1835 | - | 2 |
| 100 | 0.1745 | - | 2 |
| 150 | 0.1631 | - | 2 |
| 200 | 0.1848 | - | 2 |
| 250 | 0.1798 | - | 2 |
| 300 | 0.2026 | - | 2 |
| 350 | 0.2232 | - | 2 |
| 400 | 0.2296 | - | 2 |
Training loss:-0.19749066206725402