模型概述
模型特點
模型能力
使用案例
🚀 百川大模型-7B
百川大模型-7B是由百川智能開發的開源大規模預訓練模型,基於Transformer結構,在約1.2萬億tokens上訓練,支持中英雙語,上下文窗口達4096。在C-EVAL和MMLU等權威評測中,取得同尺寸模型最佳效果。
🚀 快速開始
如果希望使用Baichuan-7B(如進行推理、Finetune等),我們推薦使用配套代碼庫Baichuan-7B。
代碼示例
如下是一個使用Baichuan-7B進行1-shot推理的任務,根據作品給出作者名,正確輸出為"夜雨寄北->李商隱"
from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("baichuan-inc/Baichuan-7B", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("baichuan-inc/Baichuan-7B", device_map="auto", trust_remote_code=True)
inputs = tokenizer('登鸛雀樓->王之渙\n夜雨寄北->', return_tensors='pt')
inputs = inputs.to('cuda:0')
pred = model.generate(**inputs, max_new_tokens=64,repetition_penalty=1.1)
print(tokenizer.decode(pred.cpu()[0], skip_special_tokens=True))
下面是英文示例,根據作品給出作者名,正確輸出為 "One Hundred Years of Solitude->Gabriel Garcia Marquez"
from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("baichuan-inc/Baichuan-7B", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("baichuan-inc/Baichuan-7B", device_map="auto", trust_remote_code=True)
inputs = tokenizer('Hamlet->Shakespeare\nOne Hundred Years of Solitude->', return_tensors='pt')
inputs = inputs.to('cuda:0')
pred = model.generate(**inputs, max_new_tokens=64,repetition_penalty=1.1)
print(tokenizer.decode(pred.cpu()[0], skip_special_tokens=True))
✨ 主要特性
- 性能卓越:在同尺寸模型中Baichuan-7B達到了目前SOTA的水平,參考MMLU指標。
- 雙語優化:使用自有的中英文雙語語料進行訓練,在中文上進行優化,在C-Eval達到SOTA水平。
- 商業友好:不同於LLaMA完全禁止商業使用,Baichuan-7B使用更寬鬆的開源協議,允許用於商業目的。
📚 詳細文檔
模型描述
- 開發者:百川智能(Baichuan Intelligent Technology)
- 郵箱:opensource@baichuan-inc.com
- 支持語言:中文/英文
- 許可證:Baichuan-7B License
模型來源
整體模型基於標準的Transformer結構,採用了和LLaMA一樣的模型設計:
- 位置編碼:採用rotary-embedding,是現階段被大多數模型採用的位置編碼方案,具有很好的外推性。
- 前饋層:採用SwiGLU,Feedforward變化為(8/3)倍的隱含層大小,即11008。
- 層歸一化:基於RMSNorm的Pre-Normalization。
具體參數如下表:
超參數 | 值 |
---|---|
參數量 | 7000559616 |
層數 | 32 |
頭數 | 32 |
模型維度 | 4096 |
詞表大小 | 64000 |
序列長度 | 4096 |
模型用途
下游任務
我們同時開源出了和本模型配套的訓練代碼,允許進行高效的Finetune用於下游任務,具體參見Baichuan-7B。
非預期使用
在沒有充分評估風險和採取緩解措施的情況下投入生產使用;任何可能被視為不負責任或有害的使用案例。
潛在風險
Baichuan-7B可能會產生事實上不正確的輸出,不應依賴它產生事實上準確的信息。Baichuan-7B是在各種公共數據集上進行訓練的。儘管我們已經做出了巨大的努力來清洗預訓練數據,但這個模型可能會生成淫穢、偏見或其他冒犯性的輸出。
訓練詳情
訓練具體設置參見Baichuan-7B。
🔧 技術細節
中文評測
C-Eval
CEval數據集是一個全面的中文基礎模型評測數據集,涵蓋了52個學科和四個難度的級別。我們使用該數據集的dev集作為few-shot的來源,在test集上進行了5-shot測試。
模型5-shot | 平均分 | 困難平均分 | STEM | 社會科學 | 人文科學 | 其他 |
---|---|---|---|---|---|---|
GPT-4 | 68.7 | 54.9 | 67.1 | 77.6 | 64.5 | 67.8 |
ChatGPT | 54.4 | 41.4 | 52.9 | 61.8 | 50.9 | 53.6 |
Claude-v1.3 | 54.2 | 39.0 | 51.9 | 61.7 | 52.1 | 53.7 |
Claude-instant-v1.0 | 45.9 | 35.5 | 43.1 | 53.8 | 44.2 | 45.4 |
moss-moon-003-base (16B) | 27.4 | 24.5 | 27.0 | 29.1 | 27.2 | 26.9 |
Ziya-LLaMA-13B-pretrain | 30.2 | 22.7 | 27.7 | 34.4 | 32.0 | 28.9 |
LLaMA-7B-hf | 27.1 | 25.9 | 27.1 | 26.8 | 27.9 | 26.3 |
ChatGLM-6B | 34.5 | 23.1 | 30.4 | 39.6 | 37.4 | 34.5 |
Falcon-7B | 25.8 | 24.3 | 25.8 | 26.0 | 25.8 | 25.6 |
Open-LLaMA-v2-pretrain (7B) | 24.0 | 22.5 | 23.1 | 25.3 | 25.2 | 23.2 |
TigerBot-7B-base | 25.7 | 27.0 | 27.3 | 24.7 | 23.4 | 26.1 |
Aquila-7B* | 25.5 | 25.2 | 25.6 | 24.6 | 25.2 | 26.6 |
BLOOM-7B | 22.8 | 20.2 | 21.8 | 23.3 | 23.9 | 23.3 |
BLOOMZ-7B | 35.7 | 25.8 | 31.3 | 43.5 | 36.6 | 35.6 |
Baichuan-7B | 42.8 | 31.5 | 38.2 | 52.0 | 46.2 | 39.3 |
Gaokao
Gaokao 是一個以中國高考題作為評測大語言模型能力的數據集,用以評估模型的語言能力和邏輯推理能力。我們只保留了其中的單項選擇題,並對所有模型進行統一5-shot測試。
模型 | 平均分 |
---|---|
Open-LLaMA-v2-pretrain | 21.41 |
Ziya-LLaMA-13B-pretrain | 23.17 |
Falcon-7B | 23.98 |
TigerBot-7B-base | 25.94 |
LLaMA-7B | 27.81 |
ChatGLM-6B | 21.41 |
BLOOM-7B | 26.96 |
BLOOMZ-7B | 28.72 |
Aquila-7B* | 24.39 |
Baichuan-7B | 36.24 |
AGIEval
AGIEval 旨在評估模型的認知和解決問題相關的任務中的一般能力。我們只保留了其中的四選一單項選擇題,隨機劃分後對所有模型進行了統一5-shot測試。
模型 | 平均分 |
---|---|
Open-LLaMA-v2-pretrain | 23.49 |
Ziya-LLaMA-13B-pretrain | 27.64 |
Falcon-7B | 27.18 |
TigerBot-7B-base | 25.19 |
LLaMA-7B | 28.17 |
ChatGLM-6B | 23.49 |
BLOOM-7B | 26.55 |
BLOOMZ-7B | 30.27 |
Aquila-7B* | 25.58 |
Baichuan-7B | 34.44 |
*其中Aquila模型來源於智源官方網站,僅做參考
英文評測
MMLU
MMLU 是一個英文評估數據集,包括57個多項選擇題任務,涵蓋基礎數學、美國曆史、計算機科學、法律等。難度從高中水平到專家水平,是主流的大語言模型評估數據集。
我們採用了開源的評估方案,最終5-shot結果如下:
模型 | 人文學科 | 社會科學 | STEM | 其他 | 平均分 |
---|---|---|---|---|---|
LLaMA-7B2 | 34.0 | 38.3 | 30.5 | 38.1 | 35.1 |
Falcon-7B1 | - | - | - | - | 35.0 |
mpt-7B1 | - | - | - | - | 35.6 |
ChatGLM-6B0 | 35.4 | 41.0 | 31.3 | 40.5 | 36.9 |
BLOOM 7B0 | 25.0 | 24.4 | 26.5 | 26.4 | 25.5 |
BLOOMZ 7B0 | 31.3 | 42.1 | 34.4 | 39.0 | 36.1 |
moss-moon-003-base (16B)0 | 24.2 | 22.8 | 22.4 | 24.4 | 23.6 |
moss-moon-003-sft (16B)0 | 30.5 | 33.8 | 29.3 | 34.4 | 31.9 |
Baichuan-7B0 | 38.4 | 48.9 | 35.6 | 48.1 | 42.3 |
模型列中的上標表示結果來源:
0: 重新實現
1: https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard
2: https://paperswithcode.com/sota/multi-task-language-understanding-on-mmlu
📄 許可證
本項目使用Baichuan-7B License。
🏢 團隊信息



