Instructions to use ritakurban/DistilGPT_PubMedQA with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ritakurban/DistilGPT_PubMedQA with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ritakurban/DistilGPT_PubMedQA")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ritakurban/DistilGPT_PubMedQA") model = AutoModelForCausalLM.from_pretrained("ritakurban/DistilGPT_PubMedQA", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ritakurban/DistilGPT_PubMedQA with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ritakurban/DistilGPT_PubMedQA" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ritakurban/DistilGPT_PubMedQA", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ritakurban/DistilGPT_PubMedQA
- SGLang
How to use ritakurban/DistilGPT_PubMedQA 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 "ritakurban/DistilGPT_PubMedQA" \ --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": "ritakurban/DistilGPT_PubMedQA", "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 "ritakurban/DistilGPT_PubMedQA" \ --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": "ritakurban/DistilGPT_PubMedQA", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use ritakurban/DistilGPT_PubMedQA with Docker Model Runner:
docker model run hf.co/ritakurban/DistilGPT_PubMedQA
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
DistilGPT2 Fine-Tuned on PubMedQA Artificial Subset
This model is a fine-tuned version of the DistilGPT2 for question-answering tasks in the biomedical domain. The model was trained on a subset of 50,000 artificial samples from the PubMedQA dataset.
Model Details
- Model architecture: DistilGPT2
- Training dataset: 50,000 samples from PubMedQA artificial subset
- Training epochs: 3
- Tokenizer maximum length: 512
- Fine-Tuning Details: Model finetuning was done for three epochs using a standard model training pipeline provided by the Huggingface library. During training, the tokenizer was configured with a maximum token length of 512.
Example Usage
You can use this model for medical question-answering tasks by simply loading it with the Huggingface transformers library and providing a prompt.
from transformers import GPT2LMHeadModel, GPT2Tokenizer
tokenizer = GPT2Tokenizer.from_pretrained("ritakurban/DistilGPT_PubMedQA")
model = GPT2LMHeadModel.from_pretrained("ritakurban/DistilGPT_PubMedQA")
prompt = "question: What is the primary function of the liver? context: The liver is a vital organ that performs several essential functions, including detoxification, protein synthesis, and the production of biochemicals necessary for digestion."
input_ids = tokenizer.encode(prompt, return_tensors="pt")
output = model.generate(input_ids, max_length=100, num_return_sequences=1, no_repeat_ngram_size=2)
response = tokenizer.decode(output[0], skip_special_tokens=True)
print(response)
Evaluation Metrics Model performance was evaluated using Semantic Textual Similarity, Word Mover's Distance, and Grammar Errors. Detailed evaluation results can be found in the accompanying paper.
Limitations While this model has been fine-tuned on a specific biomedical dataset, it may not perform equally well on other medical or general domain questions. Additionally, the model may generate plausible-sounding but incorrect answers. Always verify the generated answers with reliable sources before using them for critical decision-making.
Acknowledgements We want to thank Huggingface for their excellent transformers library and the creators of the original DistilGPT2 model. We also thank the authors of the PubMedQA dataset for providing a valuable resource for training and evaluating biomedical question-answering models.
- Downloads last month
- 43