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.
預(yù)期用例 Llama 2預(yù)期用于商業(yè)和研究用途,語言為英語。調(diào)整模型預(yù)期用于類似助手的聊天,而預(yù)訓(xùn)練模型可以適應(yīng)各種自然語言生成任務(wù)。
為了獲得聊天版本的預(yù)期特性和性能,需要遵循特定的格式,包括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.
訓(xùn)練因素 我們使用了定制的訓(xùn)練庫(kù),Meta的研究超級(jí)集群,以及用于預(yù)訓(xùn)練的生產(chǎn)集群。微調(diào)、注釋和評(píng)估也在第三方云計(jì)算上進(jìn)行。
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.
碳足跡 預(yù)訓(xùn)練使用了累計(jì)330萬GPU小時(shí)的計(jì)算,硬件類型為A100-80GB(TDP為350-400W)。估計(jì)的總排放量為539 tCO2eq,其中100%由Meta的可持續(xù)性計(jì)劃抵消。
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
在線體驗(yàn)鏈接:llama.family
為了能夠更加清晰地了解Llama2模型的中文問答能力,我們篩選了一些具有代表性的中文問題,對(duì)Llama2模型進(jìn)行提問。我們測(cè)試的模型包含Meta公開的Llama2-7B-Chat和Llama2-13B-Chat兩個(gè)版本,沒有做任何微調(diào)和訓(xùn)練。測(cè)試問題篩選自AtomBulb,共95個(gè)測(cè)試問題,包含:通用知識(shí)、語言理解、創(chuàng)作能力、邏輯推理、代碼編程、工作技能、使用工具、人格特征八個(gè)大的類別。
測(cè)試中使用的Prompt如下,例如對(duì)于問題“列出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的測(cè)試結(jié)果見meta_eval_7B.md,Llama2-13B-Chat的測(cè)試結(jié)果見meta_eval_13B.md。
通過測(cè)試我們發(fā)現(xiàn),Meta原始的Llama2 Chat模型對(duì)于中文問答的對(duì)齊效果一般,大部分情況下都不能給出中文回答,或者是中英文混雜的形式。因此,基于中文數(shù)據(jù)對(duì)Llama2模型進(jìn)行訓(xùn)練和微調(diào)十分必要,我們的中文版Llama2模型也已經(jīng)在訓(xùn)練中,近期將對(duì)社區(qū)開放。
除了持續(xù)增強(qiáng)大模型內(nèi)在的知識(shí)儲(chǔ)備、通用理解、邏輯推理和想象能力等,未來,我們也會(huì)不斷豐富大模型的外延能力,例如知識(shí)庫(kù)檢索、計(jì)算工具、WolframAlpha、操作軟件等。
我們首先集成了LangChain框架,可以更方便地基于Llama2開發(fā)文檔檢索、問答機(jī)器人和智能體應(yīng)用等,關(guān)于LangChain的更多介紹參見LangChain。
針對(duì)LangChain框架封裝的Llama2 LLM類見examples/llama2_for_langchain.py,簡(jiǎn)單的調(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的訓(xùn)練數(shù)據(jù)達(dá)到了2萬億token,上下文長(zhǎng)度也由之前的2048升級(jí)到4096,可以理解和生成更長(zhǎng)的文本。Llama2 Chat模型基于100萬人類標(biāo)記數(shù)據(jù)微調(diào)得到,在英文對(duì)話上達(dá)到了接近ChatGPT的效果。
感謝原子回聲AtomEcho團(tuán)隊(duì)的技術(shù)和資源支持!
感謝 @xzsGenius 對(duì)Llama2中文社區(qū)的貢獻(xiàn)!
感謝 @Z Potentials社區(qū)對(duì)Llama2中文社區(qū)的支持!
如有問題,請(qǐng)?jiān)贕itHub Issue中提交,在提交問題之前,請(qǐng)先查閱以往的issue是否能解決你的問題。
禮貌地提出問題,構(gòu)建和諧的討論社區(qū)。
加入飛書知識(shí)庫(kù),一起共建社區(qū)文檔。
加入微信群討論????
歡迎來到Llama2中文社區(qū)!
我們是一個(gè)專注于Llama2模型在中文方面的優(yōu)化和上層建設(shè)的高級(jí)技術(shù)社區(qū)。
基于大規(guī)模中文數(shù)據(jù),從預(yù)訓(xùn)練開始對(duì)Llama2模型進(jìn)行中文能力的持續(xù)迭代升級(jí)。
我們熱忱歡迎對(duì)大模型LLM充滿熱情的開發(fā)者和研究者加入我們的行列。