Instructions to use QuantFactory/BioMistral-7B-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use QuantFactory/BioMistral-7B-GGUF with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="QuantFactory/BioMistral-7B-GGUF", filename="BioMistral-7B.Q2_K.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use QuantFactory/BioMistral-7B-GGUF with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf QuantFactory/BioMistral-7B-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf QuantFactory/BioMistral-7B-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf QuantFactory/BioMistral-7B-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf QuantFactory/BioMistral-7B-GGUF:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf QuantFactory/BioMistral-7B-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf QuantFactory/BioMistral-7B-GGUF:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf QuantFactory/BioMistral-7B-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf QuantFactory/BioMistral-7B-GGUF:Q4_K_M
Use Docker
docker model run hf.co/QuantFactory/BioMistral-7B-GGUF:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use QuantFactory/BioMistral-7B-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "QuantFactory/BioMistral-7B-GGUF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "QuantFactory/BioMistral-7B-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/QuantFactory/BioMistral-7B-GGUF:Q4_K_M
- Ollama
How to use QuantFactory/BioMistral-7B-GGUF with Ollama:
ollama run hf.co/QuantFactory/BioMistral-7B-GGUF:Q4_K_M
- Unsloth Studio new
How to use QuantFactory/BioMistral-7B-GGUF 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 QuantFactory/BioMistral-7B-GGUF 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 QuantFactory/BioMistral-7B-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for QuantFactory/BioMistral-7B-GGUF to start chatting
- Docker Model Runner
How to use QuantFactory/BioMistral-7B-GGUF with Docker Model Runner:
docker model run hf.co/QuantFactory/BioMistral-7B-GGUF:Q4_K_M
- Lemonade
How to use QuantFactory/BioMistral-7B-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull QuantFactory/BioMistral-7B-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.BioMistral-7B-GGUF-Q4_K_M
List all available models
lemonade list
Install from WinGet (Windows)
winget install llama.cpp
# Start a local OpenAI-compatible server with a web UI:
llama-server -hf QuantFactory/BioMistral-7B-GGUF:# Run inference directly in the terminal:
llama-cli -hf QuantFactory/BioMistral-7B-GGUF:Use pre-built binary
# Download pre-built binary from:
# https://github.com/ggerganov/llama.cpp/releases# Start a local OpenAI-compatible server with a web UI:
./llama-server -hf QuantFactory/BioMistral-7B-GGUF:# Run inference directly in the terminal:
./llama-cli -hf QuantFactory/BioMistral-7B-GGUF:Build from source code
git clone https://github.com/ggerganov/llama.cpp.git
cd llama.cpp
cmake -B build
cmake --build build -j --target llama-server llama-cli# Start a local OpenAI-compatible server with a web UI:
./build/bin/llama-server -hf QuantFactory/BioMistral-7B-GGUF:# Run inference directly in the terminal:
./build/bin/llama-cli -hf QuantFactory/BioMistral-7B-GGUF:Use Docker
docker model run hf.co/QuantFactory/BioMistral-7B-GGUF:QuantFactory/BioMistral-7B-GGUF
This is quantized version of BioMistral/BioMistral-7B created using llama.cpp
Original Model Card
BioMistral: A Collection of Open-Source Pretrained Large Language Models for Medical Domains
Abstract:
Large Language Models (LLMs) have demonstrated remarkable versatility in recent years, offering potential applications across specialized domains such as healthcare and medicine. Despite the availability of various open-source LLMs tailored for health contexts, adapting general-purpose LLMs to the medical domain presents significant challenges. In this paper, we introduce BioMistral, an open-source LLM tailored for the biomedical domain, utilizing Mistral as its foundation model and further pre-trained on PubMed Central. We conduct a comprehensive evaluation of BioMistral on a benchmark comprising 10 established medical question-answering (QA) tasks in English. We also explore lightweight models obtained through quantization and model merging approaches. Our results demonstrate BioMistral's superior performance compared to existing open-source medical models and its competitive edge against proprietary counterparts. Finally, to address the limited availability of data beyond English and to assess the multilingual generalization of medical LLMs, we automatically translated and evaluated this benchmark into 7 other languages. This marks the first large-scale multilingual evaluation of LLMs in the medical domain. Datasets, multilingual evaluation benchmarks, scripts, and all the models obtained during our experiments are freely released.
Advisory Notice! Although BioMistral is intended to encapsulate medical knowledge sourced from high-quality evidence, it hasn't been tailored to effectively, safely, or suitably convey this knowledge within professional parameters for action. We advise refraining from utilizing BioMistral in medical contexts unless it undergoes thorough alignment with specific use cases and undergoes further testing, notably including randomized controlled trials in real-world medical environments. BioMistral 7B may possess inherent risks and biases that have not yet been thoroughly assessed. Additionally, the model's performance has not been evaluated in real-world clinical settings. Consequently, we recommend using BioMistral 7B strictly as a research tool and advise against deploying it in production environments for natural language generation or any professional health and medical purposes.
1. BioMistral models
BioMistral is a suite of Mistral-based further pre-trained open source models suited for the medical domains and pre-trained using textual data from PubMed Central Open Access (CC0, CC BY, CC BY-SA, and CC BY-ND). All the models are trained using the CNRS (French National Centre for Scientific Research) Jean Zay French HPC.
| Model Name | Base Model | Model Type | Sequence Length | Download |
|---|---|---|---|---|
| BioMistral-7B | Mistral-7B-Instruct-v0.1 | Further Pre-trained | 2048 | HuggingFace |
| BioMistral-7B-DARE | Mistral-7B-Instruct-v0.1 | Merge DARE | 2048 | HuggingFace |
| BioMistral-7B-TIES | Mistral-7B-Instruct-v0.1 | Merge TIES | 2048 | HuggingFace |
| BioMistral-7B-SLERP | Mistral-7B-Instruct-v0.1 | Merge SLERP | 2048 | HuggingFace |
2. Quantized Models
| Base Model | Method | q_group_size | w_bit | version | VRAM GB | Time | Download |
|---|---|---|---|---|---|---|---|
| BioMistral-7B | FP16/BF16 | 15.02 | x1.00 | HuggingFace | |||
| BioMistral-7B | AWQ | 128 | 4 | GEMM | 4.68 | x1.41 | HuggingFace |
| BioMistral-7B | AWQ | 128 | 4 | GEMV | 4.68 | x10.30 | HuggingFace |
| BioMistral-7B | BnB.4 | 4 | 5.03 | x3.25 | HuggingFace | ||
| BioMistral-7B | BnB.8 | 8 | 8.04 | x4.34 | HuggingFace | ||
| BioMistral-7B-DARE | AWQ | 128 | 4 | GEMM | 4.68 | x1.41 | HuggingFace |
| BioMistral-7B-TIES | AWQ | 128 | 4 | GEMM | 4.68 | x1.41 | HuggingFace |
| BioMistral-7B-SLERP | AWQ | 128 | 4 | GEMM | 4.68 | x1.41 | HuggingFace |
2. Using BioMistral
You can use BioMistral with Hugging Face's Transformers library as follow.
Loading the model and tokenizer :
from transformers import AutoModel, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("BioMistral/BioMistral-7B")
model = AutoModel.from_pretrained("BioMistral/BioMistral-7B")
3. Supervised Fine-tuning Benchmark
| Clinical KG | Medical Genetics | Anatomy | Pro Medicine | College Biology | College Medicine | MedQA | MedQA 5 opts | PubMedQA | MedMCQA | Avg. | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| BioMistral 7B | 59.9 | 64.0 | 56.5 | 60.4 | 59.0 | 54.7 | 50.6 | 42.8 | 77.5 | 48.1 | 57.3 |
| Mistral 7B Instruct | 62.9 | 57.0 | 55.6 | 59.4 | 62.5 | 57.2 | 42.0 | 40.9 | 75.7 | 46.1 | 55.9 |
| BioMistral 7B Ensemble | 62.8 | 62.7 | 57.5 | 63.5 | 64.3 | 55.7 | 50.6 | 43.6 | 77.5 | 48.8 | 58.7 |
| BioMistral 7B DARE | 62.3 | 67.0 | 55.8 | 61.4 | 66.9 | 58.0 | 51.1 | 45.2 | 77.7 | 48.7 | 59.4 |
| BioMistral 7B TIES | 60.1 | 65.0 | 58.5 | 60.5 | 60.4 | 56.5 | 49.5 | 43.2 | 77.5 | 48.1 | 57.9 |
| BioMistral 7B SLERP | 62.5 | 64.7 | 55.8 | 62.7 | 64.8 | 56.3 | 50.8 | 44.3 | 77.8 | 48.6 | 58.8 |
| MedAlpaca 7B | 53.1 | 58.0 | 54.1 | 58.8 | 58.1 | 48.6 | 40.1 | 33.7 | 73.6 | 37.0 | 51.5 |
| PMC-LLaMA 7B | 24.5 | 27.7 | 35.3 | 17.4 | 30.3 | 23.3 | 25.5 | 20.2 | 72.9 | 26.6 | 30.4 |
| MediTron-7B | 41.6 | 50.3 | 46.4 | 27.9 | 44.4 | 30.8 | 41.6 | 28.1 | 74.9 | 41.3 | 42.7 |
| BioMedGPT-LM-7B | 51.4 | 52.0 | 49.4 | 53.3 | 50.7 | 49.1 | 42.5 | 33.9 | 76.8 | 37.6 | 49.7 |
| GPT-3.5 Turbo 1106* | 74.71 | 74.00 | 65.92 | 72.79 | 72.91 | 64.73 | 57.71 | 50.82 | 72.66 | 53.79 | 66.0 |
Supervised Fine-Tuning (SFT) performance of BioMistral 7B models compared to baselines, measured by accuracy (↑) and averaged across 3 random seeds of 3-shot. DARE, TIES, and SLERP are model merging strategies that combine BioMistral 7B and Mistral 7B Instruct. Best model in bold, and second-best underlined. *GPT-3.5 Turbo performances are reported from the 3-shot results without SFT.
Citation BibTeX
Arxiv : https://arxiv.org/abs/2402.10373
@misc{labrak2024biomistral,
title={BioMistral: A Collection of Open-Source Pretrained Large Language Models for Medical Domains},
author={Yanis Labrak and Adrien Bazoge and Emmanuel Morin and Pierre-Antoine Gourraud and Mickael Rouvier and Richard Dufour},
year={2024},
eprint={2402.10373},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
CAUTION! Both direct and downstream users need to be informed about the risks, biases, and constraints inherent in the model. While the model can produce natural language text, our exploration of its capabilities and limitations is just beginning. In fields such as medicine, comprehending these limitations is crucial. Hence, we strongly advise against deploying this model for natural language generation in production or for professional tasks in the realm of health and medicine.
- Downloads last month
- 691
2-bit
3-bit
4-bit
5-bit
6-bit
8-bit
Install from brew
# Start a local OpenAI-compatible server with a web UI: llama-server -hf QuantFactory/BioMistral-7B-GGUF:# Run inference directly in the terminal: llama-cli -hf QuantFactory/BioMistral-7B-GGUF: