Instructions to use medalpaca/medalpaca-lora-7b-16bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use medalpaca/medalpaca-lora-7b-16bit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="medalpaca/medalpaca-lora-7b-16bit")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("medalpaca/medalpaca-lora-7b-16bit", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use medalpaca/medalpaca-lora-7b-16bit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "medalpaca/medalpaca-lora-7b-16bit" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "medalpaca/medalpaca-lora-7b-16bit", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/medalpaca/medalpaca-lora-7b-16bit
- SGLang
How to use medalpaca/medalpaca-lora-7b-16bit 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 "medalpaca/medalpaca-lora-7b-16bit" \ --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": "medalpaca/medalpaca-lora-7b-16bit", "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 "medalpaca/medalpaca-lora-7b-16bit" \ --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": "medalpaca/medalpaca-lora-7b-16bit", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use medalpaca/medalpaca-lora-7b-16bit with Docker Model Runner:
docker model run hf.co/medalpaca/medalpaca-lora-7b-16bit
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,61 @@
|
|
| 1 |
---
|
| 2 |
license: cc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: cc
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
library_name: transformers
|
| 6 |
+
pipeline_tag: text-generation
|
| 7 |
+
tags:
|
| 8 |
+
- medical
|
| 9 |
---
|
| 10 |
+
# MedAlpaca LoRA 7b 16bit
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
## Table of Contents
|
| 14 |
+
|
| 15 |
+
[Model Description](#model-description)
|
| 16 |
+
- [Architecture](#architecture)
|
| 17 |
+
- [Training Data](#trainig-data)
|
| 18 |
+
[Model Usage](#model-usage)
|
| 19 |
+
[Limitations](#limitations)
|
| 20 |
+
|
| 21 |
+
## Model Description
|
| 22 |
+
### Architecture
|
| 23 |
+
`medalpaca-lora-7b-16bit` is a large language model specifically fine-tuned for medical domain tasks.
|
| 24 |
+
It is based on LLaMA (Large Language Model Meta AI) and contains 7 billion parameters.
|
| 25 |
+
The primary goal of this model is to improve question-answering and medical dialogue tasks.
|
| 26 |
+
It was trained using [LoRA](https://arxiv.org/abs/2106.09685).
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
### Training Data
|
| 30 |
+
The training data for this project was sourced from various resources.
|
| 31 |
+
Firstly, we used Anki flashcards to automatically generate questions,
|
| 32 |
+
from the front of the cards and anwers from the back of the card.
|
| 33 |
+
Secondly, we generated medical question-answer pairs from [Wikidoc](https://www.wikidoc.org/index.php/Main_Page).
|
| 34 |
+
We extracted paragraphs with relevant headings, and used Chat-GPT 3.5
|
| 35 |
+
to generate questions from the headings and using the corresponding paragraphs
|
| 36 |
+
as answers. This dataset is still under development and we believe
|
| 37 |
+
that approximately 70% of these question answer pairs are factual correct.
|
| 38 |
+
Thirdly, we used StackExchange to extract question-answer pairs, taking the
|
| 39 |
+
top-rated question from five categories: Academia, Bioinformatics, Biology,
|
| 40 |
+
Fitness, and Health. Additionally, we used a dataset from [ChatDoctor](https://arxiv.org/abs/2303.14070)
|
| 41 |
+
consisting of 200,000 question-answer pairs, available at https://github.com/Kent0n-Li/ChatDoctor.
|
| 42 |
+
|
| 43 |
+
| Source | n items |
|
| 44 |
+
|------------------------------|--------|
|
| 45 |
+
| ChatDoc large | 200000 |
|
| 46 |
+
| wikidoc | 67704 |
|
| 47 |
+
| Stackexchange academia | 40865 |
|
| 48 |
+
| Anki flashcards | 33955 |
|
| 49 |
+
| Stackexchange biology | 27887 |
|
| 50 |
+
| Stackexchange fitness | 9833 |
|
| 51 |
+
| Stackexchange health | 7721 |
|
| 52 |
+
| Wikidoc patient information | 5942 |
|
| 53 |
+
| Stackexchange bioinformatics | 5407 |
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
## Limitations
|
| 57 |
+
The model may not perform effectively outside the scope of the medical domain.
|
| 58 |
+
The training data primarily targets the knowledge level of medical students,
|
| 59 |
+
which may result in limitations when addressing the needs of board-certified physicians.
|
| 60 |
+
The model has not been tested in real-world applications, so its efficacy and accuracy are currently unknown.
|
| 61 |
+
It should never be used as a substitute for a doctor's opinion and must be treated as a research tool only.
|