Baichuan-7B is an open-source large-scale pre-trained model developed by Baichuan Intelligent Technology. Based on the Transformer architecture, it is a model with 7 billion parameters trained on approximately 1.2 trillion tokens. It supports both Chinese and English, with a context window length of 4096. It achieves the best performance of its size on standard Chinese and English authoritative benchmarks (C-EVAL/MMLU).
If you wish to use Baichuan-7B (for inference, finetuning, etc.), we recommend using the accompanying code library
Baichuan-7B
.
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))
The following is a task of performing 1-shot inference using Baichuan-7B, where the author's name is given based on the work, with the correct output being "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))
Model Details
Model Description
Developed by:
百川智能(Baichuan Intelligent Technology)
The overall model is based on the standard Transformer structure, and we have adopted the same model design as LLaMA:
Position Embedding: We use rotary-embedding, which is the position encoding scheme adopted by most models at this stage, and it has excellent extrapolation capabilities.
Feedforward Layer: We use SwiGLU. The feedforward changes to (8/3) times the size of the hidden layer, that is, 11008.
Layer Normalization: Pre-Normalization based on
RMSNorm
.
We have also open-sourced the training code that accompanies this model, allowing for efficient finetuning for downstream tasks. For more details, please refer to
Baichuan-7B
.
Out-of-Scope Use
在没有充分评估风险和采取缓解措施的情况下投入生产使用;任何可能被视为不负责任或有害的使用案例。
Production use without adequate assessment of risks and mitigation; any use cases which may be considered irresponsible or harmful.
Baichuan-7B can produce factually incorrect output, and should not be relied on to produce factually accurate information. Baichuan-7B was trained on various public datasets. While great efforts have been taken to clean the pretraining data, it is possible that this model could generate lewd, biased or otherwise offensive outputs.
In addition to Chinese, we also tested the model's performance in English.
MMLU
MMLU
is an English evaluation dataset that includes 57 multiple-choice tasks, covering elementary mathematics, American history, computer science, law, etc. The difficulty ranges from high school level to expert level, making it a mainstream LLM evaluation dataset.
We adopted the
open-source
evaluation scheme, and the final 5-shot results are as follows:
Model
Humanities
Social Sciences
STEM
Other
Average
LLaMA-7B
2
34.0
38.3
30.5
38.1
35.1
Falcon-7B
1
-
-
-
-
35.0
mpt-7B
1
-
-
-
-
35.6
ChatGLM-6B
0
35.4
41.0
31.3
40.5
36.9
BLOOM 7B
0
25.0
24.4
26.5
26.4
25.5
BLOOMZ 7B
0
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-7B
0
38.4
48.9
35.6
48.1
42.3
The superscript in the Model column indicates the source of the results.
Runs of baichuan-inc Baichuan-7B on huggingface.co
37.2K
Total runs
-206
24-hour runs
-652
3-day runs
-3.0K
7-day runs
9.8K
30-day runs
More Information About Baichuan-7B huggingface.co Model
Baichuan-7B huggingface.co
Baichuan-7B huggingface.co is an AI model on huggingface.co that provides Baichuan-7B's model effect (), which can be used instantly with this baichuan-inc Baichuan-7B model. huggingface.co supports a free trial of the Baichuan-7B model, and also provides paid use of the Baichuan-7B. Support call Baichuan-7B model through api, including Node.js, Python, http.
Baichuan-7B huggingface.co is an online trial and call api platform, which integrates Baichuan-7B's modeling effects, including api services, and provides a free online trial of Baichuan-7B, you can try Baichuan-7B online for free by clicking the link below.
baichuan-inc Baichuan-7B online free url in huggingface.co:
Baichuan-7B is an open source model from GitHub that offers a free installation service, and any user can find Baichuan-7B on GitHub to install. At the same time, huggingface.co provides the effect of Baichuan-7B install, users can directly use Baichuan-7B installed effect in huggingface.co for debugging and trial. It also supports api for free installation.