Phi 2 Super GGUF
模型简介
该模型是 phi-2-super 的量化版本,支持多种比特量化选项,适用于文本生成和对话AI应用。
模型特点
多比特量化
支持2比特、3比特、4比特、5比特、6比特和8比特量化,适用于不同硬件需求。
本地运行
GGUF格式支持在本地设备上高效运行,无需依赖云端服务。
高性能文本生成
适用于对话AI和文本生成任务,支持长上下文处理。
模型能力
文本生成
对话AI
自定义代码生成
使用案例
对话AI
智能聊天助手
用于构建本地运行的智能聊天助手,支持自然语言对话。
文本生成
故事创作
用于生成创意故事或内容创作。
🚀 MaziyarPanahi/phi-2-super-GGUF
本项目提供了 abacaj/phi-2-super 模型的 GGUF 格式文件,方便用户在不同客户端和库中使用该模型进行文本生成等任务。
🚀 快速开始
模型信息
- 模型创建者:abacaj
- 原始模型:abacaj/phi-2-super
✨ 主要特性
- 多种量化格式:支持 2-bit、3-bit、4-bit、5-bit、6-bit、8-bit 等多种量化格式。
- 广泛的兼容性:与多个客户端和库兼容,如 llama.cpp、text-generation-webui 等。
📦 安装指南
安装依赖库
pip3 install huggingface-hub
若要加速下载(网络速度 1Gbit/s 或更高),可安装 hf_transfer
:
pip3 install hf_transfer
下载模型文件
在 text-generation-webui
中下载
在“Download Model”处输入模型仓库地址 MaziyarPanahi/phi-2-super-GGUF,并在下方输入具体文件名,如 phi-2-super-GGUF.Q4_K_M.gguf
,然后点击“Download”。
在命令行下载单个文件
huggingface-cli download MaziyarPanahi/phi-2-super-GGUF phi-2-super-GGUF.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
命令行批量下载
huggingface-cli download [MaziyarPanahi/phi-2-super-GGUF](https://huggingface.co/MaziyarPanahi/phi-2-super-GGUF) --local-dir . --local-dir-use-symlinks False --include='*Q4_K*gguf'
加速下载
设置环境变量 HF_HUB_ENABLE_HF_TRANSFER
为 1
:
HF_HUB_ENABLE_HF_TRANSFER=1 huggingface-cli download MaziyarPanahi/phi-2-super-GGUF phi-2-super-GGUF.Q4_K_M.gguf --local-dir . --local-dir-use-symlinks False
Windows 命令行用户,可在下载命令前运行 set HF_HUB_ENABLE_HF_TRANSFER=1
来设置环境变量。
💻 使用示例
基础用法
llama.cpp
命令示例
确保使用的 llama.cpp
版本为 d0cee0d 或更高。
./main -ngl 35 -m phi-2-super-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 32
:将其改为要卸载到 GPU 的层数,若没有 GPU 加速则移除该参数。-c 32768
:改为所需的序列长度,对于扩展序列模型(如 8K、16K、32K),必要的 RoPE 缩放参数会从 GGUF 文件中读取并由 llama.cpp 自动设置。注意,更长的序列长度需要更多资源,可能需要减小该值。 若要进行聊天式对话,将-p <PROMPT>
参数替换为-i -ins
。
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="./phi-2-super-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="./phi-2-super-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."
}
]
)
高级用法
安装不同加速选项的 llama-cpp-python
# Base ctransformers with no GPU acceleration
pip install llama-cpp-python
# With NVidia CUDA acceleration
CMAKE_ARGS="-DLLAMA_CUBLAS=on" pip install llama-cpp-python
# Or with OpenBLAS acceleration
CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS" pip install llama-cpp-python
# Or with CLBLast acceleration
CMAKE_ARGS="-DLLAMA_CLBLAST=on" pip install llama-cpp-python
# Or with AMD ROCm GPU acceleration (Linux only)
CMAKE_ARGS="-DLLAMA_HIPBLAS=on" pip install llama-cpp-python
# Or with Metal GPU acceleration for macOS systems only
CMAKE_ARGS="-DLLAMA_METAL=on" pip install llama-cpp-python
# In windows, to set the variables CMAKE_ARGS in PowerShell, follow this format; eg for NVidia CUDA:
$env:CMAKE_ARGS = "-DLLAMA_OPENBLAS=on"
pip install llama-cpp-python
📚 详细文档
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:适用于 Windows 和 macOS(Silicon)的易用且强大的本地 GUI,支持 GPU 加速,截至 2023 年 11 月 27 日,Linux 版本处于测试阶段。
- 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:“type-1” 2 位量化,超级块包含 16 个块,每个块有 16 个权重。块的缩放和最小值用 4 位量化,最终每个权重有效使用 2.5625 位(bpw)。
- GGML_TYPE_Q3_K:“type-0” 3 位量化,超级块包含 16 个块,每个块有 16 个权重。缩放用 6 位量化,最终使用 3.4375 bpw。
- GGML_TYPE_Q4_K:“type-1” 4 位量化,超级块包含 8 个块,每个块有 32 个权重。缩放和最小值用 6 位量化,最终使用 4.5 bpw。
- GGML_TYPE_Q5_K:“type-1” 5 位量化,与 GGML_TYPE_Q4_K 具有相同的超级块结构,最终使用 5.5 bpw。
- GGML_TYPE_Q6_K:“type-0” 6 位量化,超级块有 16 个块,每个块有 16 个权重。缩放用 8 位量化,最终使用 6.5625 bpw。
在 text-generation-webui
中运行
更多说明可在 text-generation-webui 文档中找到,地址为:text-generation-webui/docs/04 ‚Äê Model Tab.md。
使用 LangChain
以下是使用 llama-cpp-python 和 ctransformers 与 LangChain 的指南:
📄 许可证
本项目采用 MIT 许可证。
Phi 2 GGUF
其他
Phi-2是微软开发的一个小型但强大的语言模型,具有27亿参数,专注于高效推理和高质量文本生成。
大型语言模型 支持多种语言
P
TheBloke
41.5M
205
Roberta Large
MIT
基于掩码语言建模目标预训练的大型英语语言模型,采用改进的BERT训练方法
大型语言模型 英语
R
FacebookAI
19.4M
212
Distilbert Base Uncased
Apache-2.0
DistilBERT是BERT基础模型的蒸馏版本,在保持相近性能的同时更轻量高效,适用于序列分类、标记分类等自然语言处理任务。
大型语言模型 英语
D
distilbert
11.1M
669
Llama 3.1 8B Instruct GGUF
Meta Llama 3.1 8B Instruct 是一个多语言大语言模型,针对多语言对话用例进行了优化,在常见的行业基准测试中表现优异。
大型语言模型 英语
L
modularai
9.7M
4
Xlm Roberta Base
MIT
XLM-RoBERTa是基于100种语言的2.5TB过滤CommonCrawl数据预训练的多语言模型,采用掩码语言建模目标进行训练。
大型语言模型 支持多种语言
X
FacebookAI
9.6M
664
Roberta Base
MIT
基于Transformer架构的英语预训练模型,通过掩码语言建模目标在海量文本上训练,支持文本特征提取和下游任务微调
大型语言模型 英语
R
FacebookAI
9.3M
488
Opt 125m
其他
OPT是由Meta AI发布的开放预训练Transformer语言模型套件,参数量从1.25亿到1750亿,旨在对标GPT-3系列性能,同时促进大规模语言模型的开放研究。
大型语言模型 英语
O
facebook
6.3M
198
1
基于transformers库的预训练模型,适用于多种NLP任务
大型语言模型
Transformers

1
unslothai
6.2M
1
Llama 3.1 8B Instruct
Llama 3.1是Meta推出的多语言大语言模型系列,包含8B、70B和405B参数规模,支持8种语言和代码生成,优化了多语言对话场景。
大型语言模型
Transformers 支持多种语言

L
meta-llama
5.7M
3,898
T5 Base
Apache-2.0
T5基础版是由Google开发的文本到文本转换Transformer模型,参数规模2.2亿,支持多语言NLP任务。
大型语言模型 支持多种语言
T
google-t5
5.4M
702
精选推荐AI模型
Llama 3 Typhoon V1.5x 8b Instruct
专为泰语设计的80亿参数指令模型,性能媲美GPT-3.5-turbo,优化了应用场景、检索增强生成、受限生成和推理任务
大型语言模型
Transformers 支持多种语言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一个基于SODA数据集训练的超小型对话模型,专为边缘设备推理设计,体积仅为Cosmo-3B模型的2%左右。
对话系统
Transformers 英语

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基于RoBERTa架构的中文抽取式问答模型,适用于从给定文本中提取答案的任务。
问答系统 中文
R
uer
2,694
98