ThakrePranjal commited on
Commit
d613629
·
verified ·
1 Parent(s): 220379e

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +78 -0
README.md ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: TinyLlama/TinyLlama-1.1B-intermediate-step-1431k-3T
3
+ tags:
4
+ - instruction-tuning
5
+ - pharma
6
+ - causal-lm
7
+ - merged
8
+ datasets:
9
+ - ThakrePranjal/pharma-instruction-dataset
10
+ ---
11
+
12
+ # Pharma TinyLlama — Instruction Merged Model (Stage 2)
13
+
14
+ This is the **fully merged standalone instruction-tuned model**:
15
+ `TinyLlama/TinyLlama-1.1B-intermediate-step-1431k-3T` with both:
16
+
17
+ 1. Stage 1 domain LoRA merged in (pharma-domain pretraining)
18
+ 2. Stage 2 instruction LoRA merged in (pharma instruction tuning)
19
+
20
+ No PEFT/LoRA library needed at inference time — load directly with 🤗 Transformers.
21
+
22
+ ## Usage
23
+
24
+ ```python
25
+ from transformers import AutoModelForCausalLM, AutoTokenizer
26
+ import torch
27
+
28
+ model = AutoModelForCausalLM.from_pretrained("ThakrePranjal/pharma-tinyllama-instruct-merged")
29
+ tokenizer = AutoTokenizer.from_pretrained("ThakrePranjal/pharma-tinyllama-instruct-merged")
30
+ model.eval()
31
+
32
+ def generate(instruction, input_text="", max_new_tokens=150):
33
+ if input_text.strip():
34
+ prompt = (
35
+ f"### Instruction:\n{instruction}\n\n"
36
+ f"### Input:\n{input_text}\n\n"
37
+ f"### Response:\n"
38
+ )
39
+ else:
40
+ prompt = (
41
+ f"### Instruction:\n{instruction}\n\n"
42
+ f"### Response:\n"
43
+ )
44
+ inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
45
+ with torch.no_grad():
46
+ out = model.generate(
47
+ **inputs,
48
+ max_new_tokens=max_new_tokens,
49
+ do_sample=True,
50
+ temperature=0.7,
51
+ top_p=0.9,
52
+ repetition_penalty=1.1,
53
+ pad_token_id=tokenizer.eos_token_id,
54
+ )
55
+ return tokenizer.decode(out[0], skip_special_tokens=True)
56
+
57
+ print(generate("Explain the primary mechanism of action of metformin."))
58
+ ```
59
+
60
+ ## Full training pipeline
61
+
62
+ ```
63
+ TinyLlama (base)
64
+ → Stage 1: Domain Pretraining LoRA [ThakrePranjal/pharma-tinyllama-domain-lora]
65
+ → Merge → Stage 1 Merged Model [ThakrePranjal/pharma-tinyllama-domain-lora]
66
+ → Stage 2: Instruction LoRA [ThakrePranjal/pharma-tinyllama-instruct-lora]
67
+ → Merge → THIS MODEL (Stage 2 Merged)
68
+ → Stage 3: Preference Tuning (DPO) (upcoming)
69
+ ```
70
+
71
+ ## Dataset
72
+
73
+ [ThakrePranjal/pharma-instruction-dataset](https://huggingface.co/datasets/ThakrePranjal/pharma-instruction-dataset)
74
+
75
+ ## Limitations
76
+
77
+ Trained on a small pharma corpus. Not validated for clinical or production use.
78
+ Intended for educational/research purposes only.