Text Generation
PEFT
Safetensors
Transformers
lora
sft
trl
medicine
medical
clinical
multilingual
conversational
Instructions to use Aman0026/ArogyaAI-LLaMA3-8B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use Aman0026/ArogyaAI-LLaMA3-8B with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("meta-llama/Meta-Llama-3-8B-Instruct") model = PeftModel.from_pretrained(base_model, "Aman0026/ArogyaAI-LLaMA3-8B") - Transformers
How to use Aman0026/ArogyaAI-LLaMA3-8B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Aman0026/ArogyaAI-LLaMA3-8B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Aman0026/ArogyaAI-LLaMA3-8B", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Aman0026/ArogyaAI-LLaMA3-8B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Aman0026/ArogyaAI-LLaMA3-8B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Aman0026/ArogyaAI-LLaMA3-8B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Aman0026/ArogyaAI-LLaMA3-8B
- SGLang
How to use Aman0026/ArogyaAI-LLaMA3-8B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Aman0026/ArogyaAI-LLaMA3-8B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Aman0026/ArogyaAI-LLaMA3-8B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Aman0026/ArogyaAI-LLaMA3-8B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Aman0026/ArogyaAI-LLaMA3-8B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Aman0026/ArogyaAI-LLaMA3-8B with Docker Model Runner:
docker model run hf.co/Aman0026/ArogyaAI-LLaMA3-8B
Update fine-tuned model weights (97.3% RAG accuracy)
Browse files
README.md
CHANGED
|
@@ -8,55 +8,66 @@ tags:
|
|
| 8 |
- sft
|
| 9 |
- transformers
|
| 10 |
- trl
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
pipeline_tag: text-generation
|
| 13 |
---
|
| 14 |
|
| 15 |
-
#
|
| 16 |
|
| 17 |
-
This
|
| 18 |
-
It has been trained using [TRL](https://github.com/huggingface/trl).
|
| 19 |
|
| 20 |
-
##
|
| 21 |
|
| 22 |
-
|
| 23 |
-
from transformers import pipeline
|
| 24 |
-
|
| 25 |
-
question = "If you had a time machine, but could only go to the past or the future once and never return, which would you choose and why?"
|
| 26 |
-
generator = pipeline("text-generation", model="None", device="cuda")
|
| 27 |
-
output = generator([{"role": "user", "content": question}], max_new_tokens=128, return_full_text=False)[0]
|
| 28 |
-
print(output["generated_text"])
|
| 29 |
-
```
|
| 30 |
-
|
| 31 |
-
## Training procedure
|
| 32 |
-
|
| 33 |
-
|
| 34 |
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
| 38 |
|
| 39 |
### Framework versions
|
| 40 |
|
| 41 |
-
- PEFT 0.19.1
|
| 42 |
-
- TRL: 1.6.0
|
| 43 |
-
- Transformers: 5.12.1
|
| 44 |
-
- Pytorch: 2.5.1+cu121
|
| 45 |
-
- Datasets: 5.0.0
|
| 46 |
-
- Tokenizers: 0.22.2
|
| 47 |
|
| 48 |
-
##
|
| 49 |
|
|
|
|
| 50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
```bibtex
|
| 55 |
-
@software{vonwerra2020trl,
|
| 56 |
-
title = {{TRL: Transformers Reinforcement Learning}},
|
| 57 |
-
author = {von Werra, Leandro and Belkada, Younes and Tunstall, Lewis and Beeching, Edward and Thrush, Tristan and Lambert, Nathan and Huang, Shengyi and Rasul, Kashif and Gallouédec, Quentin},
|
| 58 |
-
license = {Apache-2.0},
|
| 59 |
-
url = {https://github.com/huggingface/trl},
|
| 60 |
-
year = {2020}
|
| 61 |
-
}
|
| 62 |
-
```
|
|
|
|
| 8 |
- sft
|
| 9 |
- transformers
|
| 10 |
- trl
|
| 11 |
+
- medicine
|
| 12 |
+
- medical
|
| 13 |
+
- clinical
|
| 14 |
+
- multilingual
|
| 15 |
+
licence: mit
|
| 16 |
pipeline_tag: text-generation
|
| 17 |
---
|
| 18 |
|
| 19 |
+
# 🏥 ArogyaAI - LLaMA3 8B Fine-Tuned (QLoRA)
|
| 20 |
|
| 21 |
+
This is the fine-tuned LLaMA3 8B Instruct model adapter developed as part of **ArogyaAI** (India's First Multimodal AI Health Intelligence Platform). It has been SFT fine-tuned to synthesize unified prescriptions and diagnosis advice combining **Allopathy**, **Ayurveda**, and **Homeopathy** across 7 Indian languages.
|
|
|
|
| 22 |
|
| 23 |
+
## 📊 Fine-Tuning Performance & Metrics
|
| 24 |
|
| 25 |
+
The model was fine-tuned on a dual NVIDIA H100 GPU cluster. Below are the final metrics achieved during SFT training:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
+
* **Training Dataset Size:** 1,705 medical Q&A instruction pairs
|
| 28 |
+
* **Training Duration:** 19 minutes, 59 seconds (5 epochs)
|
| 29 |
+
* **Final Training Loss:** **`0.2194`**
|
| 30 |
+
* **Final Evaluation Loss:** **`0.3728`**
|
| 31 |
+
* **Mean Token Evaluation Accuracy:** **`92.15%`** (Significantly exceeding the 80% thesis target!)
|
| 32 |
|
| 33 |
### Framework versions
|
| 34 |
|
| 35 |
+
- **PEFT:** 0.19.1
|
| 36 |
+
- **TRL:** 1.6.0
|
| 37 |
+
- **Transformers:** 5.12.1
|
| 38 |
+
- **Pytorch:** 2.5.1+cu121
|
| 39 |
+
- **Datasets:** 5.0.0
|
| 40 |
+
- **Tokenizers:** 0.22.2
|
| 41 |
|
| 42 |
+
## 🧬 Direct Usage (PEFT & Transformers)
|
| 43 |
|
| 44 |
+
To load and use this model locally with the base LLaMA3 model:
|
| 45 |
|
| 46 |
+
```python
|
| 47 |
+
import torch
|
| 48 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 49 |
+
from peft import PeftModel
|
| 50 |
+
|
| 51 |
+
base_model_name = "meta-llama/Meta-Llama-3-8B-Instruct"
|
| 52 |
+
adapter_model_name = "Aman0026/ArogyaAI-LLaMA3-8B"
|
| 53 |
+
|
| 54 |
+
# Load base model in 4-bit
|
| 55 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 56 |
+
base_model_name,
|
| 57 |
+
load_in_4bit=True,
|
| 58 |
+
torch_dtype=torch.float16,
|
| 59 |
+
device_map="auto"
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
+
# Load tokenizer and merge PEFT adapter
|
| 63 |
+
tokenizer = AutoTokenizer.from_pretrained(base_model_name)
|
| 64 |
+
model = PeftModel.from_pretrained(model, adapter_model_name)
|
| 65 |
+
|
| 66 |
+
# Run inference
|
| 67 |
+
inputs = tokenizer("Patient presents with severe cold and coughing. Suggest remedy.", return_tensors="pt").to("cuda")
|
| 68 |
+
outputs = model.generate(**inputs, max_new_tokens=256)
|
| 69 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 70 |
+
```
|
| 71 |
|
| 72 |
+
## 📜 Citations & License
|
| 73 |
+
This project is licensed under the MIT License.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|