模型概述
模型特點
模型能力
使用案例
🚀 Llama 2 13B Chat - GPTQ
本項目提供了 Meta公司的Llama 2 13B-chat 的GPTQ模型文件,可用於高效的推理任務。
🚀 快速開始
下載模型
- text-generation-webui:在下載名稱後添加
:branch
,例如TheBloke/Llama-2-13B-chat-GPTQ:main
。 - Git:使用以下命令克隆指定分支:
git clone --single-branch --branch main https://huggingface.co/TheBloke/Llama-2-13B-chat-GPTQ
- Python Transformers代碼:使用
revision
參數指定分支。
在text-generation-webui中使用
- 確保使用的是 text-generation-webui 的最新版本。
- 點擊 Model tab。
- 在 Download custom model or LoRA 中輸入
TheBloke/Llama-2-13B-chat-GPTQ
。若要從特定分支下載,可輸入如TheBloke/Llama-2-13B-chat-GPTQ:main
。 - 點擊 Download,模型開始下載,完成後顯示 "Done"。
- 點擊左上角 Model 旁邊的刷新圖標。
- 在 Model 下拉菜單中選擇剛下載的模型
Llama-2-13B-chat-GPTQ
,模型將自動加載,即可使用。 - 若需要自定義設置,設置完成後點擊 Save settings for this model,再點擊右上角的 Reload the Model。
- 點擊 Text Generation tab 並輸入提示詞開始使用。
在Python代碼中使用
安裝必要的包
需要安裝Transformers 4.32.0或更高版本、Optimum 1.12.0或更高版本以及AutoGPTQ 0.4.2或更高版本:
pip3 install transformers>=4.32.0 optimum>=1.12.0
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
pip3 install .
對於CodeLlama模型
必須使用Transformers 4.33.0或更高版本。若4.33.0尚未發佈,需要從源代碼安裝Transformers:
pip3 uninstall -y transformers
pip3 install git+https://github.com/huggingface/transformers.git
使用代碼示例
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
model_name_or_path = "TheBloke/Llama-2-13B-chat-GPTQ"
# 若要使用不同的分支,修改revision參數
# 例如:revision="main"
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'''[INST] <<SYS>>
You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature. If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.
<</SYS>>
{prompt}[/INST]
'''
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量化參數排列,可根據硬件和需求選擇最佳參數。
- 多平臺兼容性:與AutoGPTQ、Occ4m's GPTQ-for-LLaMa fork、ExLlama(4位Llama模型)和Huggingface Text Generation Inference (TGI)兼容。
📦 安裝指南
安裝必要的包
pip3 install transformers>=4.32.0 optimum>=1.12.0
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
pip3 install .
📚 詳細文檔
模型信息
- 模型創建者:Meta Llama 2
- 原始模型:Llama 2 13B Chat
可用的模型倉庫
- 用於GPU推理的AWQ模型
- 具有多個量化參數選項的GPU推理GPTQ模型
- 用於CPU+GPU推理的2、3、4、5、6和8位GGUF模型
- Meta Llama 2的原始未量化fp16 PyTorch格式模型,用於GPU推理和進一步轉換
提示詞模板:Llama-2-Chat
[INST] <<SYS>>
You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature. If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.
<</SYS>>
{prompt}[/INST]
提供的文件和GPTQ參數
提供多個量化參數,可根據硬件和需求選擇最佳參數。每個單獨的量化版本位於不同的分支中。所有近期的GPTQ文件都使用AutoGPTQ製作,非主分支中的所有文件也使用AutoGPTQ製作。主分支中2023年8月之前上傳的文件使用GPTQ-for-LLaMa製作。
分支 | 比特數 | 分組大小 | 激活順序 | 阻尼百分比 | GPTQ數據集 | 序列長度 | 大小 | ExLlama兼容性 | 描述 |
---|---|---|---|---|---|---|---|---|---|
main | 4 | 128 | 否 | 0.01 | wikitext | 4096 | 7.26 GB | 是 | 4位,無激活順序,分組大小128g。 |
gptq-4bit-32g-actorder_True | 4 | 32 | 是 | 0.01 | wikitext | 4096 | 8.00 GB | 是 | 4位,有激活順序,分組大小32g。推理質量最高,但VRAM使用量最大。 |
gptq-4bit-64g-actorder_True | 4 | 64 | 是 | 0.01 | wikitext | 4096 | 7.51 GB | 是 | 4位,有激活順序,分組大小64g。VRAM使用量比32g小,但精度略低。 |
gptq-4bit-128g-actorder_True | 4 | 128 | 是 | 0.01 | wikitext | 4096 | 7.26 GB | 是 | 4位,有激活順序,分組大小128g。VRAM使用量比64g更小,但精度略低。 |
gptq-8bit-128g-actorder_True | 8 | 128 | 是 | 0.01 | wikitext | 4096 | 13.65 GB | 否 | 8位,分組大小128g以提高推理質量,有激活順序以提高精度。 |
gptq-8bit-64g-actorder_True | 8 | 64 | 是 | 0.01 | wikitext | 4096 | 13.95 GB | 否 | 8位,分組大小64g和激活順序以提高推理質量。AutoGPTQ CUDA速度較慢。 |
gptq-8bit-128g-actorder_False | 8 | 128 | 否 | 0.01 | wikitext | 4096 | 13.65 GB | 否 | 8位,分組大小128g以提高推理質量,無激活順序以提高AutoGPTQ速度。 |
gptq-8bit--1g-actorder_True | 8 | 無 | 是 | 0.01 | wikitext | 4096 | 13.36 GB | 否 | 8位,有激活順序。無分組大小,以降低VRAM需求。 |
GPTQ參數解釋
- 比特數:量化模型的比特大小。
- 分組大小:GPTQ分組大小。數值越高,VRAM使用量越少,但量化精度越低。“無”是最低可能值。
- 激活順序:真或假。也稱為
desc_act
。真會導致更好的量化精度。一些GPTQ客戶端在使用激活順序和分組大小的模型時遇到過問題,但現在一般已解決。 - 阻尼百分比:影響量化樣本處理的GPTQ參數。默認值為0.01,但0.1會導致略高的精度。
- GPTQ數據集:用於量化的數據集。使用更適合模型訓練的數據集可以提高量化精度。請注意,GPTQ數據集與用於訓練模型的數據集不同,請參考原始模型倉庫瞭解訓練數據集的詳細信息。
- 序列長度:用於量化的數據集序列長度。理想情況下,這與模型序列長度相同。對於一些非常長序列的模型(16K以上),可能需要使用較低的序列長度。請注意,較低的序列長度不會限制量化模型的序列長度,它隻影響較長推理序列的量化精度。
- ExLlama兼容性:該文件是否可以使用ExLlama加載,目前ExLlama僅支持4位的Llama模型。
🔧 技術細節
訓練因素
使用自定義訓練庫、Meta的研究超級集群和生產集群進行預訓練。微調、註釋和評估也在第三方雲計算上進行。
碳足跡
預訓練在A100 - 80GB類型的硬件上累計使用了330萬個GPU小時的計算資源(TDP為350 - 400W)。估計總排放量為539 tCO2eq,其中100%由Meta的可持續發展計劃抵消。
模型 | 時間(GPU小時) | 功耗(W) | 碳排放(tCO₂eq) |
---|---|---|---|
Llama 2 7B | 184320 | 400 | 31.22 |
Llama 2 13B | 368640 | 400 | 62.44 |
Llama 2 70B | 1720320 | 400 | 291.42 |
總計 | 3311616 | 539.00 |
訓練數據
Llama 2在來自公開可用來源的2萬億個標記的數據上進行了預訓練。微調數據包括公開可用的指令數據集,以及超過一百萬個新的人工註釋示例。預訓練和微調數據集均不包括Meta用戶數據。預訓練數據截止到2022年9月,但一些微調數據更新至2023年7月。
評估結果
模型 | 大小 | 代碼 | 常識推理 | 世界知識 | 閱讀理解 | 數學 | MMLU | BBH | AGI評估 |
---|---|---|---|---|---|---|---|---|---|
Llama 1 | 7B | 14.1 | 60.8 | 46.2 | 58.5 | 6.95 | 35.1 | 30.3 | 23.9 |
Llama 1 | 13B | 18.9 | 66.1 | 52.6 | 62.3 | 10.9 | 46.9 | 37.0 | 33.9 |
Llama 1 | 33B | 26.0 | 70.0 | 58.4 | 67.6 | 21.4 | 57.8 | 39.8 | 41.7 |
Llama 1 | 65B | 30.7 | 70.7 | 60.5 | 68.6 | 30.8 | 63.4 | 43.5 | 47.6 |
Llama 2 | 7B | 16.8 | 63.9 | 48.9 | 61.3 | 14.6 | 45.3 | 32.6 | 29.3 |
Llama 2 | 13B | 24.5 | 66.9 | 55.4 | 65.8 | 28.7 | 54.8 | 39.4 | 39.1 |
Llama 2 | 70B | 37.5 | 71.9 | 63.6 | 69.4 | 35.2 | 68.9 | 51.2 | 54.2 |
真實問答 | 毒性生成 | ||
---|---|---|---|
Llama 1 | 7B | 27.42 | 23.00 |
Llama 1 | 13B | 41.74 | 23.08 |
Llama 1 | 33B | 44.19 | 22.57 |
Llama 1 | 65B | 48.71 | 21.77 |
Llama 2 | 7B | 33.29 | 21.25 |
Llama 2 | 13B | 41.86 | 26.10 |
Llama 2 | 70B | 50.18 | 24.60 |
真實問答 | 毒性生成 | ||
---|---|---|---|
Llama - 2 - 聊天 | 7B | 57.04 | 0.00 |
Llama - 2 - 聊天 | 13B | 62.18 | 0.00 |
Llama - 2 - 聊天 | 70B | 64.14 | 0.01 |
📄 許可證
使用此模型受Meta許可證的約束。若要下載模型權重和分詞器,請訪問 網站 並接受許可協議後再申請訪問。
Discord
如需進一步支持,或討論這些模型和人工智能相關話題,歡迎加入: TheBloke AI的Discord服務器
感謝與貢獻方式
感謝 chirper.ai 團隊!感謝 [gpus.llm - utils.org](llm - utils) 的Clay!
很多人詢問是否可以進行貢獻。我喜歡提供模型並幫助他人,也希望能花更多時間做這些事,以及開展新的項目,如微調/訓練。
如果您有能力且願意貢獻,我將不勝感激,這將幫助我提供更多模型,並開展新的人工智能項目。捐贈者將在所有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的慷慨資助。
原始模型卡片:Meta的Llama 2 13B - 聊天
Llama 2簡介
Llama 2是一系列預訓練和微調的生成式文本模型,參數規模從70億到700億不等。這是13B微調模型的倉庫,針對對話用例進行了優化,並轉換為Hugging Face Transformers格式。其他模型的鏈接可在底部索引中找到。
模型詳情
- 模型開發者:Meta
- 變體:Llama 2有7B、13B和70B等不同參數規模,以及預訓練和微調版本。
- 輸入:模型僅接受文本輸入。
- 輸出:模型僅生成文本輸出。
- 模型架構:Llama 2是一種自迴歸語言模型,使用優化的Transformer架構。微調版本使用監督微調(SFT)和基於人類反饋的強化學習(RLHF)來符合人類對有用性和安全性的偏好。
- 訓練數據:新的公開可用在線數據混合。
- 參數數量:7B、13B、70B。
- 內容長度:4k。
- 分組查詢注意力(GQA):70B模型使用GQA以提高推理可擴展性。
- 標記數量:預訓練數據為2.0T。
- 學習率:7B和13B模型為3.0 x 10⁻⁴,70B模型為1.5 x 10⁻⁴。
- 模型日期:Llama 2於2023年1月至7月期間進行訓練。
- 狀態:這是一個在離線數據集上訓練的靜態模型。隨著我們根據社區反饋改進模型安全性,未來將發佈微調模型的新版本。
- 許可證:可在 此處 獲取自定義商業許可證。
- 研究論文:"Llama - 2: Open Foundation and Fine - tuned Chat Models"
預期用途
- 預期用例:Llama 2旨在用於英語的商業和研究用途。微調模型適用於類似助手的聊天,而預訓練模型可用於各種自然語言生成任務。為獲得聊天版本的預期功能和性能,需要遵循特定的格式,包括
INST
和<<SYS>>
標籤、BOS
和EOS
標記,以及它們之間的空格和換行符(建議對輸入調用strip()
以避免雙空格)。詳細信息請參閱github上的參考代碼:chat_completion
。 - 超出範圍的用途:以任何違反適用法律法規(包括貿易合規法律)的方式使用;使用英語以外的語言;以Llama 2的可接受使用政策和許可協議禁止的任何其他方式使用。
硬件和軟件
- 訓練因素:使用自定義訓練庫、Meta的研究超級集群和生產集群進行預訓練。微調、註釋和評估也在第三方雲計算上進行。
- 碳足跡:預訓練在A100 - 80GB類型的硬件上累計使用了330萬個GPU小時的計算資源(TDP為350 - 400W)。估計總排放量為539 tCO₂eq,其中100%由Meta的可持續發展計劃抵消。
訓練數據
- 概述:Llama 2在來自公開可用來源的2萬億個標記的數據上進行了預訓練。微調數據包括公開可用的指令數據集,以及超過一百萬個新的人工註釋示例。預訓練和微調數據集均不包括Meta用戶數據。
- 數據新鮮度:預訓練數據截止到2022年9月,但一些微調數據更新至2023年7月。
評估結果
在標準學術基準測試中,Llama 2在多個指標上表現優於Llama 1。具體評估結果見上文表格。
倫理考慮和侷限性
Llama 2是一項新技術,使用時存在風險。到目前為止的測試僅在英語中進行,無法涵蓋所有場景。因此,與所有大語言模型一樣,Llama 2的潛在輸出無法提前預測,在某些情況下,模型可能會對用戶提示產生不準確、有偏見或其他令人反感的響應。因此,在部署Llama 2的任何應用程序之前,開發者應針對特定應用進行安全測試和調優。請參閱 負責任使用指南。
問題報告
請通過以下方式報告模型的任何軟件“漏洞”或其他問題:
- 報告模型問題:github.com/facebookresearch/llama
- 報告模型生成的有問題內容:developers.facebook.com/llama_output_feedback
- 報告漏洞和安全問題:facebook.com/whitehat/info
Llama模型索引
模型 | Llama2 | Llama2 - hf | Llama2 - 聊天 | Llama2 - 聊天 - hf |
---|---|---|---|---|
7B | [鏈接](https://huggingface.co/llamaste/Llama - 2 - 7b) | [鏈接](https://huggingface.co/llamaste/Llama - 2 - 7b - hf) | [鏈接](https://huggingface.co/llamaste/Llama - 2 - 7b - chat) | [鏈接](https://huggingface.co/llamaste/Llama - 2 - 7b - chat - hf) |
13B | [鏈接](https://huggingface.co/llamaste/Llama - 2 - 13b) | [鏈接](https://huggingface.co/llamaste/Llama - 2 - 13b - hf) | [鏈接](https://huggingface.co/llamaste/Llama - 2 - 13b - chat) | [鏈接](https://huggingface.co/llamaste/Llama - 2 - 13b - hf) |
70B | [鏈接](https://huggingface.co/llamaste/Llama - 2 - 70b) | [鏈接](https://huggingface.co/llamaste/Llama - 2 - 70b - hf) | [鏈接](https://huggingface.co/llamaste/Llama - 2 - 70b - chat) | [鏈接](https://huggingface.co/llamaste/Llama - 2 - 70b - hf) |



