Views
No views yet
meta-llama/Llama-3.2-3B-Instruct for evaluating predicted clinical discharge diagnoses against ground-truth diagnoses. Given a predicted diagnosis list (JSON) and a ground-truth list, the model returns a structured JSON evaluation including primary/top-5 correctness, missed diagnoses, and improvement suggestions.checkpoint-50) was selected because it reached the lowest eval loss before the model began overfitting.PREDICTED OUTPUT (JSON), GROUND TRUTH DIAGNOSES, and the requested output schema.1{
2 "diagnosis_evaluation": {
3 "primary_correct": true/false,
4 "any_top5_correct": true/false,
5 "missed_diagnoses": ["..."],
6 "why_missed": "..."
7 },
8 "improvement_suggestions": "..."
9}1from transformers import AutoTokenizer, AutoModelForCausalLM
2from peft import PeftModel
3import torch
4
5base = AutoModelForCausalLM.from_pretrained(
6 "meta-llama/Llama-3.2-3B-Instruct",
7 torch_dtype=torch.bfloat16,
8 device_map="auto",
9)
10tok = AutoTokenizer.from_pretrained("meta-llama/Llama-3.2-3B-Instruct")
11model = PeftModel.from_pretrained(base, "JinR/sft_llama3.2_3b")
12
13messages = [{"role": "user", "content": "<your evaluation prompt here>"}]
14inputs = tok.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True).to(model.device)
15out = model.generate(inputs, max_new_tokens=512, do_sample=False)
16print(tok.decode(out[0][inputs.shape[-1]:], skip_special_tokens=True))val_size=0.1)| Setting | Value |
|---|---|
| LoRA rank | 8 |
| LoRA target | all linear modules |
| cutoff_len | 2048 |
| packing | false |
| learning rate | 3e-4 |
| lr scheduler | cosine |
| warmup ratio | 0.1 |
| epochs | 5 |
| per-device batch size | 4 |
| gradient accumulation | 2 |
| effective batch size | 24 (4 × 2 × 3 GPUs) |
| precision | bf16 |
| optimizer | AdamW |
| gradient checkpointing | yes |
| attention | torch SDPA |
c301-002)| Step | Epoch | train_loss | eval_loss |
|---|---|---|---|
| 10 | 0.54 | 1.186 | — |
| 25 | 1.32 | — | 0.6742 |
| 50 | 2.65 | 0.5099 | 0.6034 (best) |
| 75 | 3.97 | — | 0.6171 |
| 95 | 5.00 | 0.3155 | 0.6187 |
checkpoint-50 as the best-generalization checkpoint.TRAINING_LOG_sft_llama3.2_3b.md in this repo for full reproducibility details (environment, data statistics, exact commands, file sizes, caveats).