Intended Use Cases Llama 2 is intended for commercial and research use in English. Tuned models are intended for assistant-like chat, whereas pretrained models can be adapted for a variety of natural language generation tasks.
To get the expected features and performance for the chat versions, a specific formatting needs to be followed, including the INST
and <<SYS>>
tags, BOS
and EOS
tokens, and the whitespaces and breaklines in between (we recommend calling strip()
on inputs to avoid double-spaces). See our reference code in github for details: chat_completion
.
Out-of-scope Uses Use in any manner that violates applicable laws or regulations (including trade compliance laws).Use in languages other than English. Use in any other way that is prohibited by the Acceptable Use Policy and Licensing Agreement for Llama 2.
預期用例 Llama 2預期用于商業(yè)和研究用途,語言為英語。調(diào)整模型預期用于類似助手的聊天,而預訓練模型可以適應各種自然語言生成任務。
為了獲得聊天版本的預期特性和性能,需要遵循特定的格式,包括INST和<
超出范圍的用途 以任何違反適用法律或法規(guī)(包括貿(mào)易合規(guī)法)的方式使用。使用英語以外的語言。以任何其他方式使用,這被Llama 2的可接受使用政策和許可協(xié)議所禁止。
Training Factors We used custom training libraries, Meta’s Research Super Cluster, and production clusters for pretraining. Fine-tuning, annotation, and evaluation were also performed on third-party cloud compute.
訓練因素 我們使用了定制的訓練庫,Meta的研究超級集群,以及用于預訓練的生產(chǎn)集群。微調(diào)、注釋和評估也在第三方云計算上進行。
Carbon Footprint Pretraining utilized a cumulative 3.3M GPU hours of computation on hardware of type A100-80GB (TDP of 350-400W). Estimated total emissions were 539 tCO2eq, 100% of which were offset by Meta’s sustainability program.
碳足跡 預訓練使用了累計330萬GPU小時的計算,硬件類型為A100-80GB(TDP為350-400W)。估計的總排放量為539 tCO2eq,其中100%由Meta的可持續(xù)性計劃抵消。
from modelscope.utils.constant import Tasks
import torch
from modelscope.pipelines import pipeline
from modelscope import snapshot_download, Model
pipe = pipeline(task=Tasks.text_generation, model=model_dir, device_map='auto',torch_dtype=torch.float16)
inputs="咖啡的作用是什么?"
result = pipe(inputs)
print(result['text'])
Github:Llama2-Chinese
在線體驗鏈接:llama.family
為了能夠更加清晰地了解Llama2模型的中文問答能力,我們篩選了一些具有代表性的中文問題,對Llama2模型進行提問。我們測試的模型包含Meta公開的Llama2-7B-Chat和Llama2-13B-Chat兩個版本,沒有做任何微調(diào)和訓練。測試問題篩選自AtomBulb,共95個測試問題,包含:通用知識、語言理解、創(chuàng)作能力、邏輯推理、代碼編程、工作技能、使用工具、人格特征八個大的類別。
測試中使用的Prompt如下,例如對于問題“列出5種可以改善睡眠質(zhì)量的方法”:
[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. The answer always been translate into Chinese language.
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.
The answer always been translate into Chinese language.
<</SYS>>
列出5種可以改善睡眠質(zhì)量的方法
[/INST]
Llama2-7B-Chat的測試結(jié)果見meta_eval_7B.md,Llama2-13B-Chat的測試結(jié)果見meta_eval_13B.md。
通過測試我們發(fā)現(xiàn),Meta原始的Llama2 Chat模型對于中文問答的對齊效果一般,大部分情況下都不能給出中文回答,或者是中英文混雜的形式。因此,基于中文數(shù)據(jù)對Llama2模型進行訓練和微調(diào)十分必要,我們的中文版Llama2模型也已經(jīng)在訓練中,近期將對社區(qū)開放。
除了持續(xù)增強大模型內(nèi)在的知識儲備、通用理解、邏輯推理和想象能力等,未來,我們也會不斷豐富大模型的外延能力,例如知識庫檢索、計算工具、WolframAlpha、操作軟件等。
我們首先集成了LangChain框架,可以更方便地基于Llama2開發(fā)文檔檢索、問答機器人和智能體應用等,關于LangChain的更多介紹參見LangChain。
針對LangChain框架封裝的Llama2 LLM類見examples/llama2_for_langchain.py,簡單的調(diào)用代碼示例如下:
from llama2_for_langchain import Llama2
# 這里以調(diào)用4bit量化壓縮的Llama2-Chinese參數(shù)FlagAlpha/Llama2-Chinese-13b-Chat-4bit為例
llm = Llama2(model_name_or_path='FlagAlpha/Llama2-Chinese-13b-Chat-4bit', bit4=True)
while True:
human_input = input("Human: ")
response = llm(human_input)
print(f"Llama2: {response}")
自從Meta公司發(fā)布第一代LLaMA模型以來,羊駝模型家族繁榮發(fā)展。近期Meta發(fā)布了Llama2版本,開源可商用,在模型和效果上有了重大更新。Llama2總共公布了7B、13B和70B三種參數(shù)大小的模型。相比于LLaMA,Llama2的訓練數(shù)據(jù)達到了2萬億token,上下文長度也由之前的2048升級到4096,可以理解和生成更長的文本。Llama2 Chat模型基于100萬人類標記數(shù)據(jù)微調(diào)得到,在英文對話上達到了接近ChatGPT的效果。
感謝原子回聲AtomEcho團隊的技術和資源支持!
感謝 @xzsGenius 對Llama2中文社區(qū)的貢獻!
感謝 @Z Potentials社區(qū)對Llama2中文社區(qū)的支持!
如有問題,請在GitHub Issue中提交,在提交問題之前,請先查閱以往的issue是否能解決你的問題。
禮貌地提出問題,構建和諧的討論社區(qū)。
加入飛書知識庫,一起共建社區(qū)文檔。
加入微信群討論????
歡迎來到Llama2中文社區(qū)!
我們是一個專注于Llama2模型在中文方面的優(yōu)化和上層建設的高級技術社區(qū)。
基于大規(guī)模中文數(shù)據(jù),從預訓練開始對Llama2模型進行中文能力的持續(xù)迭代升級。
我們熱忱歡迎對大模型LLM充滿熱情的開發(fā)者和研究者加入我們的行列。