模型概述
模型特點
模型能力
使用案例
🚀 Xwin-LM 13B V0.1 - GPTQ
Xwin-LM 13B V0.1 - GPTQ 是對 Xwin-LM 13B V0.1 模型進行量化處理後的版本。提供了多種 GPTQ 參數排列組合,可根據不同硬件和需求選擇合適的量化模型,支持 GPU 和 CPU+GPU 推理。
🚀 快速開始
本倉庫包含 Xwin-LM 的 Xwin-LM 13B V0.1 的 GPTQ 模型文件。提供了多種 GPTQ 參數排列組合,詳情見下方的“提供的文件和 GPTQ 參數”部分。
✨ 主要特性
- 多版本支持:提供 AWQ 模型用於 GPU 推理、多種量化參數選項的 GPTQ 模型用於 GPU 推理、2 - 8 位的 GGUF 模型用於 CPU+GPU 推理,以及原始未量化的 fp16 模型。
- 參數豐富:不同的 GPTQ 參數組合,如位大小、組大小、Act Order 等,可根據硬件和需求選擇最合適的量化模型。
- 廣泛兼容:與 AutoGPTQ、Occ4m's GPTQ - for - LLaMa 分叉、ExLlama(4 位 Llama 模型)、Huggingface Text Generation Inference (TGI) 等工具兼容。
📦 安裝指南
在 text - generation - webui 中下載
- 從
main
分支下載:在“下載模型”框中輸入TheBloke/Xwin-LM-13B-V0.1-GPTQ
。 - 從其他分支下載:在下載名稱末尾添加
:branchname
,例如TheBloke/Xwin-LM-13B-V0.1-GPTQ:gptq-4bit-32g-actorder_True
。
從命令行下載
推薦使用 huggingface - hub
Python 庫:
pip3 install huggingface-hub
下載 main
分支到名為 Xwin-LM-13B-V0.1-GPTQ
的文件夾:
mkdir Xwin-LM-13B-V0.1-GPTQ
huggingface-cli download TheBloke/Xwin-LM-13B-V0.1-GPTQ --local-dir Xwin-LM-13B-V0.1-GPTQ --local-dir-use-symlinks False
從不同分支下載,添加 --revision
參數:
mkdir Xwin-LM-13B-V0.1-GPTQ
huggingface-cli download TheBloke/Xwin-LM-13B-V0.1-GPTQ --revision gptq-4bit-32g-actorder_True --local-dir Xwin-LM-13B-V0.1-GPTQ --local-dir-use-symlinks False
💻 使用示例
在 text - generation - webui 中使用
- 點擊“模型”標籤。
- 在“下載自定義模型或 LoRA”下,輸入
TheBloke/Xwin-LM-13B-V0.1-GPTQ
。若從特定分支下載,輸入如TheBloke/Xwin-LM-13B-V0.1-GPTQ:gptq-4bit-32g-actorder_True
。 - 點擊“下載”。
- 模型開始下載,完成後顯示“完成”。
- 在左上角,點擊“模型”旁邊的刷新圖標。
- 在“模型”下拉菜單中,選擇剛下載的模型
Xwin-LM-13B-V0.1-GPTQ
。 - 模型將自動加載,即可使用。
- 若需要自定義設置,設置後點擊“保存此模型的設置”,然後點擊右上角的“重新加載模型”。
- 準備好後,點擊“文本生成”標籤,輸入提示詞開始使用。
從 Python 代碼使用
安裝必要的包
pip3 install transformers optimum
pip3 install auto-gptq --extra-index-url https://huggingface.github.io/autogptq-index/whl/cu118/ # 若使用 CUDA 11.7,使用 cu117
若使用預構建的輪子安裝 AutoGPTQ 有問題,可從源代碼安裝:
pip3 uninstall -y auto-gptq
git clone https://github.com/PanQiWei/AutoGPTQ
cd AutoGPTQ
git checkout v0.4.2
pip3 install .
使用代碼示例
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
model_name_or_path = "TheBloke/Xwin-LM-13B-V0.1-GPTQ"
# 若使用不同分支,更改 revision
# 例如: revision="gptq-4bit-32g-actorder_True"
model = AutoModelForCausalLM.from_pretrained(model_name_or_path,
device_map="auto",
trust_remote_code=False,
revision="main")
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
prompt = "Tell me about AI"
prompt_template=f'''A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions. USER: {prompt} ASSISTANT:
'''
print("\n\n*** Generate:")
input_ids = tokenizer(prompt_template, return_tensors='pt').input_ids.cuda()
output = model.generate(inputs=input_ids, temperature=0.7, do_sample=True, top_p=0.95, top_k=40, max_new_tokens=512)
print(tokenizer.decode(output[0]))
# 也可以使用 transformers 的 pipeline 進行推理
print("*** Pipeline:")
pipe = pipeline(
"text-generation",
model=model,
tokenizer=tokenizer,
max_new_tokens=512,
do_sample=True,
temperature=0.7,
top_p=0.95,
top_k=40,
repetition_penalty=1.1
)
print(pipe(prompt_template)[0]['generated_text'])
📚 詳細文檔
提供的文件和 GPTQ 參數
提供了多種量化參數,可根據硬件和需求選擇最佳參數。每個單獨的量化版本位於不同的分支中。所有 2023 年 8 月之後的 GPTQ 文件使用 AutoGPTQ 生成,main
分支中 2023 年 8 月之前上傳的文件使用 GPTQ - for - LLaMa 生成。
分支 | 位大小 | 組大小 | Act Order | Damp % | GPTQ 數據集 | 序列長度 | 大小 | ExLlama 兼容性 | 描述 |
---|---|---|---|---|---|---|---|---|---|
main | 4 | 128 | 是 | 0.1 | wikitext | 4096 | 7.26 GB | 是 | 4 位,有 Act Order 和組大小 128g,比 64g 更省 VRAM,但量化精度稍低。 |
gptq-4bit-32g-actorder_True | 4 | 32 | 是 | 0.1 | wikitext | 4096 | 8.00 GB | 是 | 4 位,有 Act Order 和組大小 32g,推理質量最高,但 VRAM 使用最大。 |
gptq-8bit--1g-actorder_True | 8 | 無 | 是 | 0.1 | wikitext | 4096 | 13.36 GB | 否 | 8 位,有 Act Order,無組大小,降低 VRAM 需求。 |
gptq-8bit-128g-actorder_True | 8 | 128 | 是 | 0.1 | wikitext | 4096 | 13.65 GB | 否 | 8 位,組大小 128g 以提高推理質量,有 Act Order 以提高精度。 |
gptq-8bit-32g-actorder_True | 8 | 32 | 是 | 0.1 | wikitext | 4096 | 14.54 GB | 否 | 8 位,組大小 32g 和 Act Order 以實現最大推理質量。 |
GPTQ 參數解釋
- 位大小:量化模型的位大小。
- 組大小(GS):GPTQ 組大小,較高的數字使用較少的 VRAM,但量化精度較低,“無”是最低可能值。
- Act Order:真或假,也稱為
desc_act
,真會帶來更好的量化精度。一些 GPTQ 客戶端在使用 Act Order 加組大小的模型時曾有問題,但現在通常已解決。 - Damp %:影響量化樣本處理的 GPTQ 參數,默認值為 0.01,但 0.1 會帶來稍高的精度。
- GPTQ 數據集:量化期間使用的校準數據集,使用更適合模型訓練的數據集可以提高量化精度。注意 GPTQ 校準數據集與訓練模型的數據集不同,請參考原始模型倉庫瞭解訓練數據集詳情。
- 序列長度:量化使用的數據集序列長度,理想情況下應與模型序列長度相同。對於一些非常長序列的模型(16K 以上),可能需要使用較低的序列長度。較低的序列長度不會限制量化模型的序列長度,僅影響較長推理序列的量化精度。
- ExLlama 兼容性:該文件是否可以用 ExLlama 加載,目前 ExLlama 僅支持 4 位的 Llama 模型。
🔧 技術細節
本項目基於 Xwin-LM 13B V0.1 模型進行 GPTQ 量化處理。GPTQ 是一種量化技術,通過對模型參數進行量化,減少模型的存儲空間和推理時的內存使用,同時儘量保持模型的性能。不同的量化參數(如位大小、組大小、Act Order 等)會影響量化的精度和內存使用。
📄 許可證
本項目使用 Llama 2 許可證。
原模型信息
原模型概述
Xwin-LM 旨在開發和開源大語言模型的對齊技術,包括監督微調(SFT)、獎勵模型(RM)、拒絕採樣、基於人類反饋的強化學習(RLHF)等。其第一個版本基於 Llama2 基礎模型構建,在 AlpacaEval 上排名第一,是首個在該基準上超越 GPT - 4 的模型。
新聞動態
- 💥 [2023 年 9 月] 發佈 Xwin-LM-70B-V0.1,在 AlpacaEval 基準上對 Text - Davinci - 003 的勝率達到 95.57%,排名第一,首次超越 GPT - 4,對 GPT - 4 的勝率為 60.61。
- 🔍 [2023 年 9 月] RLHF 在 Xwin-LM - V0.1 版本的出色表現中起著關鍵作用。
- 💥 [2023 年 9 月] 發佈 Xwin-LM-13B-V0.1,在 AlpacaEval 上的勝率達到 91.76%,在所有 13B 模型中排名第一。
- 💥 [2023 年 9 月] 發佈 Xwin-LM-7B-V0.1,在 AlpacaEval 上的勝率達到 87.82%,在所有 7B 模型中排名第一。
模型卡片
模型 | 檢查點 | 報告 | 許可證 |
---|---|---|---|
Xwin-LM-7B-V0.1 | 🤗 HF 鏈接 | 📃即將推出(敬請關注) | Llama 2 許可證 |
Xwin-LM-13B-V0.1 | 🤗 HF 鏈接 | Llama 2 許可證 | |
Xwin-LM-70B-V0.1 | 🤗 HF 鏈接 | Llama 2 許可證 |
基準測試
在 AlpacaEval 上的表現
模型 | AlpacaEval(勝率 %) | AlpacaEval(勝率 %) | AlpacaEval(勝率 %) |
---|---|---|---|
對比 Text - Davinci - 003 | 對比 ChatGPT | 對比 GPT4 | |
Xwin-LM-70B-V0.1 | 95.57 | 87.50 | 60.61 |
GPT - 4 | 95.28 | 84.66 | 50.00 |
WizardLM - 70B - V1.0 | 92.91 | 80.19 | 46.70 |
Llama - 2 - 70B - Chat | 92.66 | 81.97 | 51.19 |
Xwin-LM-13B-V0.1 | 91.76 | 81.79 | 55.30 |
ChatGPT | 89.37 | 50.00 | 16.60 |
WizardLM - 13B - V1.2 | 89.17 | 75.75 | 41.91 |
Xwin-LM-7B-V0.1 | 87.35 | 76.40 | 47.57 |
Llama - 2 - 13B - Chat | 81.09 | 64.22 | 30.92 |
AlpacaEval 案例研究
提示詞 | GPT4 響應 | Xwin-LM 響應 |
---|---|---|
我把一個盤子放在蘋果上面,然後把盤子從廚房拿到餐廳,蘋果現在在哪裡 | 蘋果現在在餐廳,因為你把盤子從廚房拿到餐廳時,蘋果在盤子下面。 | 蘋果還在廚房,因為你只移動了盤子。蘋果在盤子下面,所以如果你想把蘋果拿到餐廳,你應該直接移動蘋果或者把蘋果放在盤子上再把盤子移到餐廳。 |
回答以下問題。 法語中“晚上好”怎麼說。 |
法語中,“晚上好”是“bonsoir”。 | 法語中,“晚上好”翻譯為“bonsoir”。這個問候語用於晚上和夜間,通常在下午 6 點之後。它是“bon”(意思是“好”)和“soir”(意思是“晚上”)的組合。發音為“bone - swahr”。 |
在 NLP 基礎任務上的表現
模型 | MMLU 5 - shot | ARC 25 - shot | TruthfulQA 0 - shot | HellaSwag 10 - shot | 平均 |
---|---|---|---|---|---|
Text - davinci - 003 | 56.9 | 85.2 | 59.3 | 82.2 | 70.9 |
Vicuna - 13b 1.1 | 51.3 | 53.0 | 51.8 | 80.1 | 59.1 |
Guanaco 30B | 57.6 | 63.7 | 50.7 | 85.1 | 64.3 |
WizardLM - 7B 1.0 | 42.7 | 51.6 | 44.7 | 77.7 | 54.2 |
WizardLM - 13B 1.0 | 52.3 | 57.2 | 50.5 | 81.0 | 60.2 |
WizardLM - 30B 1.0 | 58.8 | 62.5 | 52.4 | 83.3 | 64.2 |
Llama - 2 - 7B - Chat | 48.3 | 52.9 | 45.6 | 78.6 | 56.4 |
Llama - 2 - 13B - Chat | 54.6 | 59.0 | 44.1 | 81.9 | 59.9 |
Llama - 2 - 70B - Chat | 63.9 | 64.6 | 52.8 | 85.9 | 66.8 |
Xwin-LM-7B-V0.1 | 49.7 | 56.2 | 48.1 | 79.5 | 58.4 |
Xwin-LM-13B-V0.1 | 56.6 | 62.4 | 45.5 | 83.0 | 61.9 |
Xwin-LM-70B-V0.1 | 69.6 | 70.5 | 60.1 | 87.1 | 71.8 |
推理
對話模板
使用模型進行推理時,請嚴格遵循以下對話模板。模型採用 [Vicuna](https://github.com/lm - sys/FastChat) 建立的提示格式,支持多輪對話。
A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions. USER: Hi! ASSISTANT: Hello.</s>USER: Who are you? ASSISTANT: I am Xwin-LM.</s>......
HuggingFace 示例
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
model = AutoModelForCausalLM.from_pretrained("Xwin-LM/Xwin-LM-7B-V0.1")
tokenizer = AutoTokenizer.from_pretrained("Xwin-LM/Xwin-LM-7B-V0.1")
(
prompt := "A chat between a curious user and an artificial intelligence assistant. "
"The assistant gives helpful, detailed, and polite answers to the user's questions. "
"USER: Hello, can you help me? "
"ASSISTANT:"
)
inputs = tokenizer(prompt, return_tensors="pt")
samples = model.generate(**inputs, max_new_tokens=4096, temperature=0.7)
output = tokenizer.decode(samples[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
print(output)
# Of course! I'm here to help. Please feel free to ask your question or describe the issue you're having, and I'll do my best to assist you.
vllm 示例
由於 Xwin-LM 基於 Llama2,它也支持使用 [vllm](https://github.com/vllm - project/vllm) 進行快速推理。詳細安裝說明請參考 [vllm](https://github.com/vllm - project/vllm)。
from vllm import LLM, SamplingParams
(
prompt := "A chat between a curious user and an artificial intelligence assistant. "
"The assistant gives helpful, detailed, and polite answers to the user's questions. "
"USER: Hello, can you help me? "
"ASSISTANT:"
)
sampling_params = SamplingParams(temperature=0.7, max_tokens=4096)
llm = LLM(model="Xwin-LM/Xwin-LM-7B-V0.1")
outputs = llm.generate([prompt,], sampling_params)
for output in outputs:
prompt = output.prompt
generated_text = output.outputs[0].text
print(generated_text)
待辦事項
- [ ] 發佈源代碼
- [ ] 發佈更多能力,如數學、推理等
引用
如果使用本倉庫中的數據或代碼,請考慮引用我們的工作:
@software{xwin-lm,
title = {Xwin-LM},
author = {Xwin-LM Team},
url = {https://github.com/Xwin-LM/Xwin-LM},
version = {pre-release},
year = {2023},
month = {9},
}
致謝
感謝 Llama 2、[FastChat](https://github.com/lm - sys/FastChat)、[AlpacaFarm](https://github.com/tatsu - lab/alpaca_farm) 和 [vllm](https://github.com/vllm - project/vllm)。
社區與貢獻
Discord
如需進一步支持,或參與關於這些模型和 AI 的討論,請加入:TheBloke AI 的 Discord 服務器
感謝與貢獻方式
感謝 chirper.ai 團隊和 [gpus.llm - utils.org](llm - utils) 的 Clay。
很多人詢問是否可以貢獻。我喜歡提供模型並幫助他人,也希望能花更多時間做這些事,以及開展新的項目,如微調/訓練。
如果您有能力並願意貢獻,將不勝感激,這將幫助我提供更多模型,並開展新的 AI 項目。
捐贈者將在所有 AI/LLM/模型問題和請求上獲得優先支持,訪問私人 Discord 房間,以及其他福利。
- Patreon: https://patreon.com/TheBlokeAI
- Ko - Fi: https://ko - fi.com/TheBlokeAI
特別感謝:Aemon Algiz。
Patreon 特別提及:Alicia Loh, Stephen Murray, K, Ajan Kanaga, RoA, Magnesian, Deo Leter, Olakabola, Eugene Pentland, zynix, Deep Realms, Raymond Fosdick, Elijah Stavena, Iucharbius, Erik Bjäreholt, Luis Javier Navarrete Lozano, Nicholas, theTransient, John Detwiler, alfie_i, knownsqashed, Mano Prime, Willem Michiel, Enrico Ros, LangChain4j, OG, Michael Dempsey, Pierre Kircher, Pedro Madruga, James Bentley, Thomas Belote, Luke @flexchar, Leonard Tan, Johann - Peter Hartmann, Illia Dulskyi, Fen Risland, Chadd, S_X, Jeff Scroggin, Ken Nordquist, Sean Connelly, Artur Olbinski, Swaroop Kallakuri, Jack West, Ai Maven, David Ziegler, Russ Johnson, transmissions 11, John Villwock, Alps Aficionado, Clay Pascal, Viktor Bowallius, Subspace Studios, Rainer Wilmers, Trenton Dambrowitz, vamX, Michael Levine, 준교 김, Brandon Frisco, Kalila, Trailburnt, Randy H, Talal Aujan, Nathan Dryer, Vadim, 阿明, ReadyPlayerEmma, Tiffany J. Kim, George Stoitzev, Spencer Kim, Jerry Meng, Gabriel Tamborski, Cory Kujawski, Jeffrey Morgan, Spiking Neurons AB, Edmond Seymore, Alexandros Triantafyllidis, Lone Striker, Cap'n Zoog, Nikolai Manek, danny, ya boyyy, Derek Yates, usrbinkat, Mandus, TL, Nathan LeClaire, subjectnull, Imad Khwaja, webtim, Raven Klaugh, Asp the Wyvern, Gabriel Puliatti, Caitlyn Gatomon, Joseph William Delisle, Jonathan Leane, Luke Pendergrass, SuperWojo, Sebastain Graf, Will Dee, Fred von Graf, Andrey, Dan Guido, Daniel P. Andersen, Nitin Borwankar, Elle, Vitor Caleffi, biorpg, jjj, NimbleBox.ai, Pieter, Matthew Berman, terasurfer, Michael Davis, Alex, Stanislav Ovsiannikov
感謝所有慷慨的贊助者和捐贈者!再次感謝 a16z 的慷慨資助。



