模型简介
模型特点
模型能力
使用案例
🚀 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 许可证。



