CoolFace
Modelpublic

SivaSai8143/pharma-tinyllama-instruction-merged

sourceHugging Faceapache-2.0updated 3mo agoView on Hugging Face
0likes23downloads
Model Card

pharma-tinyllama-instruction-merged

Model Summary

This is the Stage 2 merged model from the llm-finetuning-playbook pipeline.

It is produced by instruction fine-tuning (SFT) of the Stage-1 domain-adapted model (SivaSai8143/pharma-tinyllama-non-instruction-merged) on Alpaca-style pharma instruction/response pairs, using QLoRA (4-bit, nf4), then merging the LoRA adapter back into the base weights.

This merged model is the base for Stage 3 (preference tuning / DPO).


Pipeline Position

text
TinyLlama-1.1B (base)
        ↓  Stage 1: Non-Instruction FT
pharma-tinyllama-non-instruction-merged
        ↓  Stage 2: Instruction FT / SFT (this model)
pharma-tinyllama-instruction-merged  ← you are here
        ↓  Stage 3: Preference Tuning (DPO)
pharma-tinyllama-dpo-merged

Training Details

ParameterValue
Base modelSivaSai8143/pharma-tinyllama-non-instruction-merged
MethodQLoRA (4-bit nf4, double quant)
LoRA rank16
LoRA alpha32
LoRA dropout0.05
Target modulesq/k/v/oproj, gate/up/downproj
Max sequence length512 tokens
Epochs5
Max steps5
Batch size1 (grad accum 8, effective = 8)
Learning rate1e-4
Warmup steps2
Weight decay0.01
EnvironmentGoogle Colab T4 GPU

Training Data

Trained on `SivaSai8143/pharma-finetuning-data` (config: instruction).

48 instruction/response pairs formatted in Alpaca style:

text
### Instruction:
<instruction>

### Response:
<output>

Covering:

  • Metformin pharmacology, pharmacokinetics, safety & clinical use
  • Lipid-lowering therapy (Atorvastatin + Ezetimibe), familial hypercholesterolemia
  • mRNA vaccine platforms and immune response
  • AI in drug discovery, lead optimization, ADME/toxicology
  • Clinical trial terminology and pharmacovigilance

Related Artifacts


Usage

python
from transformers import AutoTokenizer, AutoModelForCausalLM

model_id = "SivaSai8143/pharma-tinyllama-instruction-merged"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")

prompt = \"\"\"### Instruction:
Explain the primary mechanism of action of metformin.

### Response:
\"\"\"

inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=150, do_sample=True, temperature=0.7)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))

Disclaimer

Educational fine-tuning project for demonstrating LLM training pipelines. The pharma content is for technical demonstration only and is not medical advice. """

with open("/content/pharmatinyllamainstructionmergedmodel/README.md", "w") as f: f.write(model_card) print("Model card written.")