ragpalgit commited on
Commit
0a02155
·
verified ·
1 Parent(s): f60e813

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +72 -0
README.md ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ ---
3
+ title: Pharma Assistant v3
4
+ tags:
5
+ - medical
6
+ - healthcare
7
+ - chatbot
8
+ - RAG
9
+ - fine-tuning
10
+ - unsloth
11
+ - tinyllama
12
+ ---
13
+
14
+ # Pharma Assistant v3
15
+
16
+ This model is a fine-tuned version of `unsloth/tinyllama-bnb-4bit` for pharmaceutical question answering, developed using a 3-stage fine-tuning pipeline with Unsloth.
17
+
18
+ ## Training Pipeline
19
+
20
+ The model was trained using the following stages:
21
+ 1. **Stage 1: Non-instruction continued pretraining** on PDF documents related to Metformin and Lipid Therapy knowledge.
22
+ 2. **Stage 2: Instruction fine-tuning** on a custom `pharma_instruction_dataset.jsonl`.
23
+ 3. **Stage 3: DPO (Direct Preference Optimization)** using a `pharma_preference_dataset.jsonl` to align with preferred responses.
24
+
25
+ ## Model Details
26
+
27
+ - **Base Model**: `unsloth/tinyllama-bnb-4bit`
28
+ - **Fine-tuning Framework**: Unsloth
29
+ - **Architecture**: Llama-based, 4-bit quantized
30
+
31
+ ## Usage
32
+
33
+ To use this model for inference, you can load it using the Hugging Face Transformers library and Unsloth:
34
+
35
+ ```python
36
+ from unsloth import FastLanguageModel
37
+ import torch
38
+
39
+ # Load model
40
+ model, tokenizer = FastLanguageModel.from_pretrained(
41
+ model_name = "ragpalgit/pharma-assistant-v3", # YOUR MODEL_ID
42
+ max_seq_length = 512,
43
+ dtype = None,
44
+ load_in_4bit = True,
45
+ )
46
+
47
+ # Example inference (using generate_answer helper from notebook)
48
+ instruction = "Explain metformin in simple language."
49
+ prompt = f"### Instruction:
50
+ {instruction}
51
+
52
+ ### Response:
53
+ "
54
+
55
+ inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
56
+
57
+ with torch.inference_mode():
58
+ output = model.generate(
59
+ **inputs,
60
+ max_new_tokens=150,
61
+ do_sample=True,
62
+ temperature=0.7,
63
+ top_p=0.9,
64
+ repetition_penalty=1.1,
65
+ pad_token_id=tokenizer.eos_token_id,
66
+ eos_token_id=tokenizer.eos_token_id,
67
+ )
68
+
69
+ input_tokens = inputs["input_ids"].shape[-1]
70
+ generated_tokens = output[0][input_tokens:]
71
+ print(tokenizer.decode(generated_tokens, skip_special_tokens=True).strip())
72
+ ```