Text Generation
Transformers
Safetensors
English
gemma3_text
text-generation-inference
unsloth
conversational
Instructions to use yasserrmd/PharmaQA-270M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yasserrmd/PharmaQA-270M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="yasserrmd/PharmaQA-270M") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("yasserrmd/PharmaQA-270M") model = AutoModelForMultimodalLM.from_pretrained("yasserrmd/PharmaQA-270M") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use yasserrmd/PharmaQA-270M with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "yasserrmd/PharmaQA-270M" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yasserrmd/PharmaQA-270M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/yasserrmd/PharmaQA-270M
- SGLang
How to use yasserrmd/PharmaQA-270M 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 "yasserrmd/PharmaQA-270M" \ --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": "yasserrmd/PharmaQA-270M", "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 "yasserrmd/PharmaQA-270M" \ --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": "yasserrmd/PharmaQA-270M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio
How to use yasserrmd/PharmaQA-270M 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 yasserrmd/PharmaQA-270M 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 yasserrmd/PharmaQA-270M to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for yasserrmd/PharmaQA-270M to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="yasserrmd/PharmaQA-270M", max_seq_length=2048, ) - Docker Model Runner
How to use yasserrmd/PharmaQA-270M with Docker Model Runner:
docker model run hf.co/yasserrmd/PharmaQA-270M
PharmaQA‑270M
PharmaQA‑270M is a compact, instruction-tuned language model for pharmacology and pharmacy domains. Based on Gemma3 (270M parameters), it was fine-tuned using LoRA and merged into a single model checkpoint for easy deployment. This model is optimized for educational and research use cases, especially where compute constraints are present.
Model Details
| Property | Value |
|---|---|
| Base Model | Google Gemma3 (270M parameters) |
| Fine-tuning Method | LoRA using Unsloth |
| Dataset Used | 25,000 Q&A pairs from MIRIAD-4.4M |
| Epochs | 3 |
| Final Format | Merged (base + LoRA weights) |
| Model Size | 270M |
| License | ODC-BY v1.0 dataset license (non-commercial) |
| Author | Mohamed Yasser |
⚠️ Caution & Intended Use
- Do not use this model for real-world medical diagnosis, treatment, or care decisions.
- The model was trained on MIRIAD Q&A pairs generated via LLMs from biomedical literature.
- MIRIAD and this model must be used for educational, research, and academic exploration only.
- This model inherits all OpenAI and ODC-BY v1.0 usage limitations associated with the dataset.
Performance Summary
From evaluation on 50 unseen pharma questions:
| Metric | Value |
|---|---|
| Average Answer Length | 40.3 words |
| Longest Answer | 95 words |
| Shortest Answer | 12 words |
| Empty / Short Responses | 0 |
| Clinical Accuracy | ✅ Consistent terminology |
| Depth in Short Responses | ⚠️ Limited |
| Best Use Case | Lightweight educational deployment (MCQs, tutoring) |
Sample Inference Code
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model_name = "yasserrmd/PharmaQA-270M"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto")
model.eval()
question = "What is the mechanism of action of metformin?"
messages = [{"role": "user", "content": f"Q: {question} A:"}]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
return_tensors="pt",
tokenize=True,
return_dict=True
).to(model.device)
if "token_type_ids" in inputs:
del inputs["token_type_ids"]
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=128,
temperature=0.7,
top_p=0.95,
repetition_penalty=1.05
)
response = tokenizer.decode(outputs[0], skip_special_tokens=True).strip()
answer = response.split("A:")[-1].strip()
print("💊 Question:", question)
print("🧠 Answer:", answer)
License
- Model: Open for academic and non-commercial use
- Dataset: MIRIAD-4.4M under ODC-BY v1.0
Acknowledgements
- MIRIAD creators for making the dataset openly accessible.
- Unsloth team for enabling fast LoRA tuning on small GPUs.
- Hugging Face and Google for Gemma3 base model.
- Downloads last month
- 5
