模型概述
模型特點
模型能力
使用案例
🚀 BioMistral-7B-GGUF
BioMistral-7B-GGUF 是一個以 GGUF 格式存儲的模型,基於 BioMistral-7B 模型,可用於文本生成任務,在醫學、生物學等領域有著廣泛的應用。
🚀 快速開始
模型信息
屬性 | 詳情 |
---|---|
模型創建者 | BioMistral |
原始模型 | BioMistral/BioMistral-7B |
量化者 | MaziyarPanahi |
許可證 | apache-2.0 |
模型標籤
該模型具有以下標籤:量化、2 位、3 位、4 位、5 位、6 位、8 位、GGUF、transformers、pytorch、tensorboard、mistral、文本生成、醫學、生物學、對話、法語、英語、德語、荷蘭語、西班牙語、葡萄牙語、波蘭語、羅馬尼亞語、意大利語、數據集:pubmed、arxiv:2402.10373、與自動訓練兼容、與端點兼容、文本生成推理、地區:美國
✨ 主要特性
- 多語言支持:支持法語、英語、德語等多種語言,適用於不同語言環境下的文本生成任務。
- 量化格式:採用 GGUF 量化格式,相較於舊的 GGML 格式,具有更好的性能和兼容性。
- 多客戶端支持:支持多種客戶端和庫,如 llama.cpp、text-generation-webui 等,方便用戶在不同環境下使用。
📦 安裝指南
安裝 huggingface-hub 庫
pip3 install huggingface-hub
加速下載(可選)
若要在高速網絡(1Gbit/s 或更高)下加速下載,可安裝 hf_transfer
:
pip3 install hf_transfer
設置環境變量(可選,Windows 用戶)
在下載命令前運行以下命令設置環境變量:
set HF_HUB_ENABLE_HF_TRANSFER=1
💻 使用示例
基礎用法
llama.cpp 命令示例
./main -ngl 35 -m BioMistral-7B-GGUF.Q4_K_M.gguf --color -c 32768 --temp 0.7 --repeat_penalty 1.1 -n -1 -p "<|im_start|>system
{system_message}<|im_end|>
<|im_start|>user
{prompt}<|im_end|>
<|im_start|>assistant"
參數說明:
-ngl 35
:將 35 層模型卸載到 GPU 上運行,若無 GPU 加速可移除該參數。-c 32768
:設置所需的序列長度,更長的序列長度需要更多資源,可根據實際情況調整。-p
:設置輸入的提示信息。
Python 代碼示例(使用 llama-cpp-python)
from llama_cpp import Llama
# Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
llm = Llama(
model_path="./BioMistral-7B-GGUF.Q4_K_M.gguf", # Download the model file first
n_ctx=32768, # The max sequence length to use - note that longer sequence lengths require much more resources
n_threads=8, # The number of CPU threads to use, tailor to your system and the resulting performance
n_gpu_layers=35 # The number of layers to offload to GPU, if you have GPU acceleration available
)
# Simple inference example
output = llm(
"<|im_start|>system
{system_message}<|im_end|>
<|im_start|>user
{prompt}<|im_end|>
<|im_start|>assistant", # Prompt
max_tokens=512, # Generate up to 512 tokens
stop=["</s>"], # Example stop token - not necessarily correct for this specific model! Please check before using.
echo=True # Whether to echo the prompt
)
# Chat Completion API
llm = Llama(model_path="./BioMistral-7B-GGUF.Q4_K_M.gguf", chat_format="llama-2") # Set chat_format according to the model you are using
llm.create_chat_completion(
messages = [
{"role": "system", "content": "You are a story writing assistant."},
{
"role": "user",
"content": "Write a story about llamas."
}
]
)
高級用法
多文件下載
huggingface-cli download [MaziyarPanahi/BioMistral-7B-GGUF](https://huggingface.co/MaziyarPanahi/BioMistral-7B-GGUF) --local-dir . --local-dir-use-symlinks False --include='*Q4_K*gguf'
在 text-generation-webui 中使用
在 text-generation-webui
的下載模型界面,輸入模型倉庫地址 MaziyarPanahi/BioMistral-7B-GGUF 和具體文件名,如 BioMistral-7B-GGUF.Q4_K_M.gguf
,然後點擊下載。
📚 詳細文檔
關於 GGUF
GGUF 是 llama.cpp 團隊在 2023 年 8 月 21 日引入的一種新格式,它替代了不再被 llama.cpp 支持的 GGML 格式。
支持 GGUF 的客戶端和庫
- llama.cpp:GGUF 的源項目,提供 CLI 和服務器選項。
- text-generation-webui:最廣泛使用的 Web UI,具有許多功能和強大的擴展,支持 GPU 加速。
- KoboldCpp:功能齊全的 Web UI,支持所有平臺和 GPU 架構的 GPU 加速,尤其適合講故事。
- GPT4All:免費開源的本地運行 GUI,支持 Windows、Linux 和 macOS,具有完整的 GPU 加速。
- LM Studio:易於使用且功能強大的本地 GUI,適用於 Windows 和 macOS(Silicon),支持 GPU 加速,Linux 版本截至 2023 年 11 月 27 日處於測試階段。
- LoLLMS Web UI:一個很棒的 Web UI,具有許多有趣和獨特的功能,包括一個完整的模型庫,方便用戶選擇模型。
- Faraday.dev:一個有吸引力且易於使用的基於角色的聊天 GUI,適用於 Windows 和 macOS(Silicon 和 Intel),支持 GPU 加速。
- llama-cpp-python:一個支持 GPU 加速、LangChain 支持和 OpenAI 兼容 API 服務器的 Python 庫。
- candle:一個注重性能的 Rust ML 框架,包括 GPU 支持和易於使用的特點。
- ctransformers:一個支持 GPU 加速、LangChain 支持和 OpenAI 兼容 AI 服務器的 Python 庫。截至 2023 年 11 月 27 日,ctransformers 已有很長時間未更新,不支持許多最新的模型。
量化方法解釋
點擊查看詳情
新的量化方法如下:
- GGML_TYPE_Q2_K:“類型 1” 的 2 位量化,超級塊包含 16 個塊,每個塊有 16 個權重。塊的縮放和最小值用 4 位量化,最終每個權重有效使用 2.5625 位(bpw)。
- GGML_TYPE_Q3_K:“類型 0” 的 3 位量化,超級塊包含 16 個塊,每個塊有 16 個權重。縮放用 6 位量化,最終使用 3.4375 bpw。
- GGML_TYPE_Q4_K:“類型 1” 的 4 位量化,超級塊包含 8 個塊,每個塊有 32 個權重。縮放和最小值用 6 位量化,最終使用 4.5 bpw。
- GGML_TYPE_Q5_K:“類型 1” 的 5 位量化,與 GGML_TYPE_Q4_K 具有相同的超級塊結構,最終使用 5.5 bpw。
- GGML_TYPE_Q6_K:“類型 0” 的 6 位量化,超級塊有 16 個塊,每個塊有 16 個權重。縮放用 8 位量化,最終使用 6.5625 bpw。
如何下載 GGUF 文件
手動下載注意事項:幾乎不需要克隆整個倉庫!該倉庫提供了多種不同的量化格式,大多數用戶只需要選擇並下載單個文件。
以下客戶端/庫會自動為你下載模型,並提供可用模型列表供你選擇:
- LM Studio
- LoLLMS Web UI
- Faraday.dev
在 text-generation-webui 中下載
在 text-generation-webui
的下載模型界面,輸入模型倉庫地址 MaziyarPanahi/BioMistral-7B-GGUF 和具體文件名,如 BioMistral-7B-GGUF.Q4_K_M.gguf
,然後點擊下載。
命令行下載(包含多個文件)
huggingface-cli download MaziyarPanahi/BioMistral-7B-GGUF BioMistral-7B-GGUF.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
高級下載用法
huggingface-cli download [MaziyarPanahi/BioMistral-7B-GGUF](https://huggingface.co/MaziyarPanahi/BioMistral-7B-GGUF) --local-dir . --local-dir-use-symlinks False --include='*Q4_K*gguf'
加速下載
HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download MaziyarPanahi/BioMistral-7B-GGUF BioMistral-7B-GGUF.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
在 text-generation-webui 中運行
更多說明可在 text-generation-webui 文檔中找到:text-generation-webui/docs/04 ‐ Model Tab.md
與 LangChain 結合使用
🔧 技術細節
llama.cpp 命令參數說明
-ngl
:將指定數量的層卸載到 GPU 上運行,若無 GPU 加速可移除該參數。-c
:設置所需的序列長度,對於擴展序列模型(如 8K、16K、32K),必要的 RoPE 縮放參數會從 GGUF 文件中讀取並由 llama.cpp 自動設置。注意,更長的序列長度需要更多資源,可根據實際情況調整該值。-p
:設置輸入的提示信息。-i -ins
:用於開啟聊天風格的對話。
注意事項
- 確保使用的
llama.cpp
版本為 d0cee0d 或更高。 - 在使用
stop
參數時,需要檢查該停止標記是否適用於當前模型。
📄 許可證
該模型採用 apache-2.0 許可證。



