Instructions to use Ellio98/doctor-gemma-2-2b-it with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Ellio98/doctor-gemma-2-2b-it with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Ellio98/doctor-gemma-2-2b-it")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Ellio98/doctor-gemma-2-2b-it") model = AutoModelForCausalLM.from_pretrained("Ellio98/doctor-gemma-2-2b-it") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Ellio98/doctor-gemma-2-2b-it with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Ellio98/doctor-gemma-2-2b-it" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Ellio98/doctor-gemma-2-2b-it", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Ellio98/doctor-gemma-2-2b-it
- SGLang
How to use Ellio98/doctor-gemma-2-2b-it 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 "Ellio98/doctor-gemma-2-2b-it" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Ellio98/doctor-gemma-2-2b-it", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "Ellio98/doctor-gemma-2-2b-it" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Ellio98/doctor-gemma-2-2b-it", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Ellio98/doctor-gemma-2-2b-it with Docker Model Runner:
docker model run hf.co/Ellio98/doctor-gemma-2-2b-it
Model Card for Model ID
Model Details
Model Description
Uses
Below we share some code snippets on how to get quickly started with running the model. First, install the Transformers library with:
pip install -U transformers
pip install -U torch
Then, copy the snippet from the section that is relevant for your usecase.
Direct Use
Running the model on Single/Multi GPU
# pip install accelerate
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
tokenizer = AutoTokenizer.from_pretrained("Ellio98/doctor-gemma-2-2b-it")
model = AutoModelForCausalLM.from_pretrained(
"Ellio98/doctor-gemma-2-2b-it",
device_map="auto",
torch_dtype=torch.bfloat16,
)
query = "I have a high fever and coughing since morning. What should I do ?"
prompt = [{"role": "user", "content": query}]
model_input = tokenizer(tokenizer.apply_chat_template(prompt, tokenize=False), return_tensors="pt")
outputs = model.generate(
input_ids=model_input["input_ids"].to("cuda"),
attention_mask=model_input["attention_mask"].to("cuda"),
max_new_tokens=32
)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
# user
# I have a high fever and coughing since morning. What should I do ?
# model
# Hi,From history it seems that you might be having viral infection giving this problem of fever with cough.
# Take paracetamol or ibuprofen for pain due to fever. Take plenty of water.
# If require take one antispasmodic medicine like Meftal spas as needed.
# Ok and take care.
Bias, Risks, and Limitations
The model might not be good at generating the desired output and might suggest some weird medical practices that does not make sense. It is highly recommended to use this model just for research purpose and not as a commercial use. Also, as no data anonymization was performed, the model will be generating random names, addresses or terms that are not intended.
Future Works
Need to perform data anonymization to refine the model output to be generic.
Training Details
Training Data
For fine-tuning the model, 5000 samples were indiced from the sid6i7/patient-doctor dataset, out of which 4500 were used for training, 250 were used for validation and testing.
Training Hyperparameters
- Training regime: [More Information Needed]
- precision: bfloat16
- alpha: 32
- rank: 16
- lora dropout: 0.05
- target modules: 'o_proj', 'v_proj', 'up_proj', 'q_proj', 'down_proj', 'gate_proj', and 'k_proj'
- optimizer: paged_adamw_32bit
- learning rate: 2e-4
Results
The loss progression during fine-tuning of gemma-2-2b on the dataset is as follows:
Hardware
The model was trained on 2 x T4 GPU. The total training time taken was 6 hours.
- Downloads last month
- -
