Instructions to use NayanPal/truthtriage-llama2-7b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use NayanPal/truthtriage-llama2-7b with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("unsloth/llama-2-7b-bnb-4bit") model = PeftModel.from_pretrained(base_model, "NayanPal/truthtriage-llama2-7b") - Transformers
How to use NayanPal/truthtriage-llama2-7b with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("NayanPal/truthtriage-llama2-7b", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Unsloth Studio
How to use NayanPal/truthtriage-llama2-7b with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for NayanPal/truthtriage-llama2-7b to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for NayanPal/truthtriage-llama2-7b to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for NayanPal/truthtriage-llama2-7b to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="NayanPal/truthtriage-llama2-7b", max_seq_length=2048, )
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,32 +1,110 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
#
|
| 4 |
-
unsloth/llama-2-7b-bnb-4bit
|
| 5 |
|
| 6 |
-
##
|
| 7 |
-
- LoRA (rank=16)
|
| 8 |
-
- 4-bit quantization
|
| 9 |
-
- Trained using Unsloth + TRL SFTTrainer
|
| 10 |
-
- GPU: Tesla T4
|
| 11 |
|
| 12 |
-
|
| 13 |
-
FreedomIntelligence/medical-o1-reasoning-SFT
|
| 14 |
|
| 15 |
-
## Purpose
|
| 16 |
-
TruthTriage is designed to:
|
| 17 |
- Analyze pharmaceutical safety queries
|
| 18 |
-
-
|
| 19 |
-
- Provide
|
| 20 |
-
- Avoid hallucinated medical
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
```python
|
| 25 |
from unsloth import FastLanguageModel
|
| 26 |
|
|
|
|
| 27 |
model, tokenizer = FastLanguageModel.from_pretrained(
|
| 28 |
"unsloth/llama-2-7b-bnb-4bit",
|
| 29 |
load_in_4bit=True,
|
| 30 |
)
|
| 31 |
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
base_model: unsloth/llama-2-7b-bnb-4bit
|
| 5 |
+
tags:
|
| 6 |
+
- medical
|
| 7 |
+
- safety
|
| 8 |
+
- lora
|
| 9 |
+
- peft
|
| 10 |
+
- transformers
|
| 11 |
+
- unsloth
|
| 12 |
+
- sft
|
| 13 |
+
- hackathon
|
| 14 |
+
---
|
| 15 |
|
| 16 |
+
# TruthTriage β Safety-Tuned Medical Assistant (LoRA)
|
|
|
|
| 17 |
|
| 18 |
+
## π©Ί Overview
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
TruthTriage is a safety-aligned medical assistant fine-tuned to:
|
|
|
|
| 21 |
|
|
|
|
|
|
|
| 22 |
- Analyze pharmaceutical safety queries
|
| 23 |
+
- Classify risk levels (Low / Moderate / High)
|
| 24 |
+
- Provide structured, grounded responses
|
| 25 |
+
- Avoid hallucinated medical advice
|
| 26 |
+
- Escalate emergency scenarios appropriately
|
| 27 |
+
|
| 28 |
+
This model is a LoRA adapter built on top of:
|
| 29 |
+
|
| 30 |
+
**Base Model:** `unsloth/llama-2-7b-bnb-4bit`
|
| 31 |
+
|
| 32 |
+
---
|
| 33 |
+
|
| 34 |
+
## π§ Fine-Tuning Details
|
| 35 |
+
|
| 36 |
+
- Method: LoRA (Low-Rank Adaptation)
|
| 37 |
+
- Quantization: 4-bit
|
| 38 |
+
- Framework: Unsloth + TRL SFTTrainer
|
| 39 |
+
- GPU: Tesla T4
|
| 40 |
+
- Trainable Parameters: ~0.3% of total model
|
| 41 |
+
- Training Samples: 662
|
| 42 |
+
|
| 43 |
+
---
|
| 44 |
+
|
| 45 |
+
## π Dataset Overview
|
| 46 |
+
|
| 47 |
+
### Dataset: TruthTriage Safety-Tuned Medical Dataset
|
| 48 |
+
**Total Examples: 662**
|
| 49 |
+
|
| 50 |
+
This dataset was designed and curated by our team specifically for safety-aligned medical AI fine-tuning.
|
| 51 |
+
|
| 52 |
+
### πΉ Dataset Composition
|
| 53 |
|
| 54 |
+
| Source | Count |
|
| 55 |
+
|--------|-------|
|
| 56 |
+
| ChatDoctor (Reformatted & Structured) | 500 |
|
| 57 |
+
| Refusal (High-Risk Queries) | 20 |
|
| 58 |
+
| Clarification β Ask | 20 |
|
| 59 |
+
| Clarification β Answer | 20 |
|
| 60 |
+
| Escalation (Emergency Cases) | 20 |
|
| 61 |
+
| General Knowledge | 20 |
|
| 62 |
+
| Out of Scope | 20 |
|
| 63 |
+
| Identity / System Persona | 20 |
|
| 64 |
+
| No Source Found | 22 |
|
| 65 |
+
| **Total** | **662** |
|
| 66 |
+
|
| 67 |
+
---
|
| 68 |
+
|
| 69 |
+
## π‘οΈ Safety Design
|
| 70 |
+
|
| 71 |
+
The dataset explicitly teaches:
|
| 72 |
+
|
| 73 |
+
- Controlled refusal for unsafe requests
|
| 74 |
+
- Emergency escalation behavior
|
| 75 |
+
- Clarification when information is missing
|
| 76 |
+
- Identity transparency
|
| 77 |
+
- Handling out-of-scope questions
|
| 78 |
+
- Risk-level classification
|
| 79 |
+
|
| 80 |
+
### Tone Strategy
|
| 81 |
+
|
| 82 |
+
| Situation | Emoji |
|
| 83 |
+
|------------|--------|
|
| 84 |
+
| Danger / Disclaimer | π |
|
| 85 |
+
| Out of Scope (Light Tone) | π |
|
| 86 |
+
| Serious Cases (Refusal / Clarification / Identity) | None |
|
| 87 |
+
|
| 88 |
+
---
|
| 89 |
+
|
| 90 |
+
## π How to Use
|
| 91 |
|
| 92 |
```python
|
| 93 |
from unsloth import FastLanguageModel
|
| 94 |
|
| 95 |
+
# Load base model
|
| 96 |
model, tokenizer = FastLanguageModel.from_pretrained(
|
| 97 |
"unsloth/llama-2-7b-bnb-4bit",
|
| 98 |
load_in_4bit=True,
|
| 99 |
)
|
| 100 |
|
| 101 |
+
# Load TruthTriage adapter
|
| 102 |
+
model.load_adapter("NayanPal/truthtriage-llama2-7b")
|
| 103 |
+
|
| 104 |
+
# Inference
|
| 105 |
+
FastLanguageModel.for_inference(model)
|
| 106 |
+
|
| 107 |
+
inputs = tokenizer("Can I take Ibuprofen with Warfarin?", return_tensors="pt").to("cuda")
|
| 108 |
+
outputs = model.generate(**inputs, max_new_tokens=200)
|
| 109 |
+
|
| 110 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|