rtsh13 commited on
Commit
5ccf67f
·
verified ·
1 Parent(s): 00fcb0c

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +106 -0
README.md ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: llama3.2
3
+ base_model: unsloth/Llama-3.2-1B-Instruct
4
+ tags:
5
+ - llama
6
+ - lora
7
+ - qlora
8
+ - gguf
9
+ - health
10
+ - biological-age
11
+ - epigenetics
12
+ - rag
13
+ language:
14
+ - en
15
+ ---
16
+
17
+ # epigenetics-slm
18
+
19
+ A Llama 3.2 1B Instruct model fine-tuned via QLoRA to generate five-category
20
+ epigenetic health assessments from wearable/biomarker data, grounded in a
21
+ Bio-RAG evidence retrieval pipeline.
22
+
23
+ Given a patient's biomarkers (HbA1c, NLR, circadian rest-activity metrics,
24
+ sleep architecture, CosinorAge acceleration) and retrieved evidence chunks,
25
+ the model produces a structured report with five sections: **AGING**,
26
+ **STRESS**, **METABOLISM**, **INFLAMMATION**, **SLEEP** — each citing the
27
+ evidence it was given.
28
+
29
+ ## Files in this repo
30
+
31
+ | File | Description |
32
+ |---|---|
33
+ | `slm.q4_k_m.gguf` | Quantized model (q4_k_m), ~771MB, for CPU inference via `llama-cpp-python` |
34
+ | `slm_lora/` | Full LoRA adapter + tokenizer + all training checkpoints (100–1491 steps), with optimizer/scheduler state for resuming training |
35
+ | `chroma_db/` | Populated Bio-RAG vector store (47 chunks, `all-MiniLM-L6-v2` embeddings) — required alongside the model for grounded generation |
36
+
37
+ ## Training details
38
+
39
+ - **Base model:** `unsloth/llama-3.2-1b-instruct-unsloth-bnb-4bit`
40
+ - **Method:** QLoRA via Unsloth + TRL `SFTTrainer`
41
+ - **Trainable params:** 11.2M / 1.25B (0.90%)
42
+ - **Dataset:** 4,415 examples derived from NHANES 2011-2012 biomarkers +
43
+ Bio-RAG evidence (3,973 train / 442 eval)
44
+ - **Epochs:** 3 (1,491 steps), effective batch size 8
45
+ - **Hardware:** RTX 4070 Laptop GPU (8GB VRAM), WSL2 Ubuntu 22.04
46
+ - **Precision:** bf16 training, fp32 LoRA adapter weights
47
+
48
+ ## Eval results (442-row held-out split)
49
+
50
+ | Metric | Score |
51
+ |---|---|
52
+ | Category coverage (all 5 headers present) | 99.8% |
53
+ | Classification match rate | 98.5% |
54
+ | ROUGE-L | 0.822 |
55
+
56
+ These metrics check structural adherence (all five sections present) and
57
+ classification-label accuracy against the training data's target
58
+ responses. They do **not** measure citation faithfulness — see
59
+ Limitations.
60
+
61
+ ## Usage
62
+
63
+ Requires the model to be prompted via the exact training-time template
64
+ (see `slm_prompt.py` in the [source repo](https://github.com/rtsh13/epigenetics-slm)
65
+ for the canonical `build_prompt()`/`build_inference_prompt()` functions —
66
+ byte-identical prompt formatting between training and inference is
67
+ required for output quality).
68
+
69
+ ```python
70
+ from llama_cpp import Llama
71
+
72
+ llm = Llama(model_path="slm.q4_k_m.gguf", n_ctx=4096, verbose=False)
73
+
74
+ # prompt must be built via build_prompt() + build_inference_prompt()
75
+ # from the source repo — see link above
76
+ out = llm(prompt, max_tokens=512, temperature=0.2, stop=["<|eot_id|>"])
77
+ print(out["choices"][0]["text"])
78
+ ```
79
+
80
+ For full end-to-end usage (XGBoost baseline + Bio-RAG retrieval + this
81
+ SLM), see `scripts/demo.py` in the source repo.
82
+
83
+ ## Limitations
84
+
85
+ - **Requires Bio-RAG evidence to ground citations.** When run without
86
+ retrieved evidence chunks (empty RAG context), the model fabricates
87
+ plausible-sounding but nonexistent citations (invented author names,
88
+ journals, and DOIs). Always pass real retrieved evidence chunks.
89
+ - **Citation precision, not just presence.** Even with real evidence
90
+ available, the model sometimes reuses the same citation pair across
91
+ multiple report sections rather than mapping each specific claim to its
92
+ most relevant source chunk. This is an attribution-precision issue, not
93
+ fabrication.
94
+ - **1B parameter model.** Domain-specific acronym/definition accuracy
95
+ (e.g. circadian rest-activity metrics) is not guaranteed to be robust;
96
+ spot-check outputs before use in any downstream decision-making
97
+ context.
98
+ - **Not a medical device.** This is a research/prototype system trained
99
+ on NHANES survey data. Outputs should not be used for clinical
100
+ decision-making.
101
+
102
+ ## Source code
103
+
104
+ Training, export, and evaluation pipeline:
105
+ [github.com/rtsh13/epigenetics-slm](https://github.com/rtsh13/epigenetics-slm)
106
+ (branch `feat/week7-slm-finetuning`)