qiaojin/PubMedQA
Viewer • Updated • 274k • 72.5k • 340
How to use iamaber/mistral-7b-pubmedqa-lora-plus with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="iamaber/mistral-7b-pubmedqa-lora-plus")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("iamaber/mistral-7b-pubmedqa-lora-plus")
model = AutoModelForCausalLM.from_pretrained("iamaber/mistral-7b-pubmedqa-lora-plus", device_map="auto")
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]:]))How to use iamaber/mistral-7b-pubmedqa-lora-plus with PEFT:
Task type is invalid.
How to use iamaber/mistral-7b-pubmedqa-lora-plus with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "iamaber/mistral-7b-pubmedqa-lora-plus"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "iamaber/mistral-7b-pubmedqa-lora-plus",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/iamaber/mistral-7b-pubmedqa-lora-plus
How to use iamaber/mistral-7b-pubmedqa-lora-plus with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "iamaber/mistral-7b-pubmedqa-lora-plus" \
--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": "iamaber/mistral-7b-pubmedqa-lora-plus",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "iamaber/mistral-7b-pubmedqa-lora-plus" \
--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": "iamaber/mistral-7b-pubmedqa-lora-plus",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use iamaber/mistral-7b-pubmedqa-lora-plus with Docker Model Runner:
docker model run hf.co/iamaber/mistral-7b-pubmedqa-lora-plus
This merged artifact fine-tunes mistralai/Mistral-7B-Instruct-v0.3 on qiaojin/PubMedQA / pqa_labeled using LoRA+.
| Field | Value |
|---|---|
| Train examples | 900 |
| Eval examples | 100 |
| Epochs | 3 |
| Train batch size | 4 |
| Eval batch size | 4 |
| Gradient accumulation | 4 |
| Learning rate | 5e-05 |
| Best eval loss | 0.5188 |
| Latest eval loss | 0.5188 |
| Latest train loss | 0.4810 |
| Train runtime (s) | 566.5676 |
| Global step | 171 |
| Metric | Value |
|---|---|
| PubMedQA accuracy | 0.4500 |
| PubMedQA macro F1 | 0.2069 |
| PubMedQA weighted F1 | 0.2793 |
| PubMedQA samples | 100 |
| Medical MMLU accuracy | 0.1600 |
| Medical MMLU samples | 50 |
| Subject | Accuracy | Correct | Total |
|---|---|---|---|
| anatomy | 0.1600 | 8 | 50 |
| clinical_knowledge | 0.0000 | 0 | 0 |
| college_medicine | 0.0000 | 0 | 0 |
| medical_genetics | 0.0000 | 0 | 0 |
| professional_medicine | 0.0000 | 0 | 0 |
| virology | 0.0000 | 0 | 0 |
| Actual \ Predicted | yes | no | maybe |
|---|---|---|---|
| yes | 45 | 0 | 0 |
| no | 40 | 0 | 0 |
| maybe | 15 | 0 | 0 |
Base model
mistralai/Mistral-7B-v0.3