?

BaixiaOyingアプリが正式に起動されました!質問を検索して質問する方法を知っているAIアシスタント、主要なアプリケーションストアでBaixiaoを検索し、ダウンロードして体験することを歓迎しますか?
中国語|
[ 2023.12.29 ] ???で:
リリースバージョンとダウンロードリンクを次の表に示します。
| ベースモデル | モデルを揃えます | アライメントモデル4ビット量子化 | |
|---|---|---|---|
| 7b | ? | ? | ?Baichuan2-7b-chat-4bits |
| 13b | ? | ? | ?baichuan2-13b-chat-4bits |
一般、法律、医療、数学、コード、多言語翻訳の6つの分野の中国語および英語および多言語の権威あるデータセットのモデルを広範囲にテストしました。
一般的なドメインでは、次のデータセットで5ショットテストを実行しました。
| C-EVAL | mmlu | cmmlu | ガカオ | アギーバル | BBH | |
|---|---|---|---|---|---|---|
| 5ショット | 5ショット | 5ショット | 5ショット | 5ショット | 3ショット | |
| GPT-4 | 68.40 | 83.93 | 70.33 | 66.15 | 63.27 | 75.12 |
| GPT-3.5ターボ | 51.10 | 68.54 | 54.06 | 47.07 | 46.13 | 61.59 |
| llama-7b | 27.10 | 35.10 | 26.75 | 27.81 | 28.17 | 32.38 |
| llama2-7b | 28.90 | 45.73 | 31.38 | 25.97 | 26.53 | 39.16 |
| MPT-7B | 27.15 | 27.93 | 26.00 | 26.54 | 24.83 | 35.20 |
| ファルコン-7b | 24.23 | 26.03 | 25.66 | 24.24 | 24.10 | 28.77 |
| chatglm2-6b | 50.20 | 45.90 | 49.00 | 49.44 | 45.28 | 31.65 |
| Baichuan-7b | 42.80 | 42.30 | 44.02 | 36.34 | 34.44 | 32.48 |
| Baichuan2-7b-base | 54.00 | 54.16 | 57.07 | 47.47 | 42.73 | 41.56 |
| C-EVAL | mmlu | cmmlu | ガカオ | アギーバル | BBH | |
|---|---|---|---|---|---|---|
| 5ショット | 5ショット | 5ショット | 5ショット | 5ショット | 3ショット | |
| GPT-4 | 68.40 | 83.93 | 70.33 | 66.15 | 63.27 | 75.12 |
| GPT-3.5ターボ | 51.10 | 68.54 | 54.06 | 47.07 | 46.13 | 61.59 |
| llama-13b | 28.50 | 46.30 | 31.15 | 28.23 | 28.22 | 37.89 |
| llama2-13b | 35.80 | 55.09 | 37.99 | 30.83 | 32.29 | 46.98 |
| Vicuna-13b | 32.80 | 52.00 | 36.28 | 30.11 | 31.55 | 43.04 |
| 中国アルパカ-Plus-13B | 38.80 | 43.90 | 33.43 | 34.78 | 35.46 | 28.94 |
| vsverse-13b | 53.70 | 55.21 | 58.44 | 44.69 | 42.54 | 38.06 |
| Baichuan-13b-base | 52.40 | 51.60 | 55.30 | 49.69 | 43.20 | 43.01 |
| Baichuan2-13b-base | 58.10 | 59.17 | 61.97 | 54.33 | 48.17 | 48.78 |
法律の分野では、JEC-QAデータセットを使用しました。 JEC-QAデータセットは、中国国立司法試験から派生しています。単一の選択の質問のみを保持しました。 C-Evalと同様の評価スキームを採用しました。
医療分野は、一般的なドメインデータセット(C-Eval、MMLU、CMMLU)で医療関連の分野であるMEDQAおよびMEDMCQAを使用しています。 C-Evalと同様の評価スキームを採用しました。
上記のデータセットで5ショットテストを実行しました。
| jec-qa | ceval-mmlu-cmmlu | Medqa-usmle | Medqa-mcmle | Medmcqa | |
|---|---|---|---|---|---|
| 5ショット | 5ショット | 5ショット | 5ショット | 5ショット | |
| GPT-4 | 59.32 | 77.16 | 80.28 | 74.58 | 72.51 |
| GPT-3.5ターボ | 42.31 | 61.17 | 53.81 | 52.92 | 56.25 |
| llama-7b | 27.45 | 33.34 | 24.12 | 21.72 | 27.45 |
| llama2-7b | 29.20 | 36.75 | 27.49 | 24.78 | 37.93 |
| MPT-7B | 27.45 | 26.67 | 16.97 | 19.79 | 31.96 |
| ファルコン-7b | 23.66 | 25.33 | 21.29 | 18.07 | 33.88 |
| chatglm2-6b | 40.76 | 44.54 | 26.24 | 45.53 | 30.22 |
| Baichuan-7b | 34.64 | 42.37 | 27.42 | 39.46 | 31.39 |
| Baichuan2-7b-base | 44.46 | 56.39 | 32.68 | 54.93 | 41.73 |
| jec-qa | ceval-mmlu-cmmlu | Medqa-usmle | Medqa-mcmle | Medmcqa | |
|---|---|---|---|---|---|
| 5ショット | 5ショット | 5ショット | 5ショット | 5ショット | |
| GPT-4 | 59.32 | 77.16 | 80.28 | 74.58 | 72.51 |
| GPT-3.5ターボ | 42.31 | 61.17 | 53.81 | 52.92 | 56.25 |
| llama-13b | 27.54 | 35.14 | 28.83 | 23.38 | 39.52 |
| llama2-13b | 34.08 | 47.42 | 35.04 | 29.74 | 42.12 |
| Vicuna-13b | 28.38 | 40.99 | 34.80 | 27.67 | 40.66 |
| 中国アルパカ-Plus-13B | 35.32 | 46.31 | 27.49 | 32.66 | 35.87 |
| vsverse-13b | 46.42 | 58.08 | 32.99 | 58.76 | 41.34 |
| Baichuan-13b-base | 41.34 | 51.77 | 29.07 | 43.67 | 39.60 |
| Baichuan2-13b-base | 47.40 | 59.33 | 40.38 | 61.62 | 42.86 |
数学の分野では、OpenCompass評価フレームワークを使用して、GSM8Kと数学データセット4ショットをテストしました。
コードフィールドは、HumanValおよびMBPPデータセットを使用します。 OpenCompassを使用して、Humaneval 0-ShotおよびMBPPデータセット3ショットをテストしました。
| GSM8K | 数学 | 人間 | MBPP | |
|---|---|---|---|---|
| 4ショット | 4ショット | 0ショット | 3ショット | |
| GPT-4 | 89.99 | 40.20 | 69.51 | 63.60 |
| GPT-3.5ターボ | 57.77 | 13.96 | 52.44 | 61.40 |
| llama-7b | 9.78 | 3.02 | 11.59 | 14.00 |
| llama2-7b | 16.22 | 3.24 | 12.80 | 14.80 |
| MPT-7B | 8.64 | 2.90 | 14.02 | 23.40 |
| ファルコン-7b | 5.46 | 1.68 | - | 10.20 |
| chatglm2-6b | 28.89 | 6.40 | 9.15 | 9.00 |
| Baichuan-7b | 9.17 | 2.54 | 9.20 | 6.60 |
| Baichuan2-7b-base | 24.49 | 5.58 | 18.29 | 24.20 |
| GSM8K | 数学 | 人間 | MBPP | |
|---|---|---|---|---|
| 4ショット | 4ショット | 0ショット | 3ショット | |
| GPT-4 | 89.99 | 40.20 | 69.51 | 63.60 |
| GPT-3.5ターボ | 57.77 | 13.96 | 52.44 | 61.40 |
| llama-13b | 20.55 | 3.68 | 15.24 | 21.40 |
| llama2-13b | 28.89 | 4.96 | 15.24 | 27.00 |
| Vicuna-13b | 28.13 | 4.36 | 16.46 | 15.00 |
| 中国アルパカ-Plus-13B | 11.98 | 2.50 | 16.46 | 20.00 |
| vsverse-13b | 18.20 | 2.18 | 15.85 | 16.80 |
| Baichuan-13b-base | 26.76 | 4.84 | 11.59 | 22.80 |
| Baichuan2-13b-base | 52.77 | 10.08 | 17.07 | 30.20 |
Flores-101データセットを使用して、モデルの多言語機能を評価しました。 Flores-101は世界中の101の言語をカバーしています。そのデータは、ニュース、旅行ガイド、書籍などのさまざまな分野に由来しています。公式の国連言語(アラビア語、中国語、英語、フランス語、ロシア語、スペイン語)とドイツ語と日本語をテスト言語として選択しました。 OpenCompassを使用して、中国英語、中国 - フランス、中国スペイン、中国アラブ、中国ロシア、中国 - ドイツ、中国のドイツを含む、Flores-101の7つのサブタスクで8ショットのテストを実施しました。
| CN-en | CN-FR | cn-es | CN-AR | CN-RU | CN-JP | cn-de | 平均 | |
|---|---|---|---|---|---|---|---|---|
| GPT-4 | 29.94 | 29.56 | 20.01 | 10.76 | 18.62 | 13.26 | 20.83 | 20.43 |
| GPT-3.5ターボ | 27.67 | 26.15 | 19.58 | 10.73 | 17.45 | 1.82 | 19.70 | 17.59 |
| llama-7b | 17.27 | 12.02 | 9.54 | 0.00 | 4.47 | 1.41 | 8.73 | 7.63 |
| llama2-7b | 25.76 | 15.14 | 11.92 | 0.79 | 4.99 | 2.20 | 10.15 | 10.14 |
| MPT-7B | 20.77 | 9.53 | 8.96 | 0.10 | 3.54 | 2.91 | 6.54 | 7.48 |
| ファルコン-7b | 22.13 | 15.67 | 9.28 | 0.11 | 1.35 | 0.41 | 6.41 | 7.91 |
| chatglm2-6b | 22.28 | 9.42 | 7.77 | 0.64 | 1.78 | 0.26 | 4.61 | 6.68 |
| Baichuan-7b | 25.07 | 16.51 | 12.72 | 0.41 | 6.66 | 2.24 | 9.86 | 10.50 |
| Baichuan2-7b-base | 27.27 | 20.87 | 16.17 | 1.39 | 11.21 | 3.11 | 12.76 | 13.25 |
| CN-en | CN-FR | cn-es | CN-AR | CN-RU | CN-JP | cn-de | 平均 | |
|---|---|---|---|---|---|---|---|---|
| GPT-4 | 29.94 | 29.56 | 20.01 | 10.76 | 18.62 | 13.26 | 20.83 | 20.43 |
| GPT-3.5ターボ | 27.67 | 26.15 | 19.58 | 10.73 | 17.45 | 1.82 | 19.70 | 17.59 |
| llama-13b | 21.75 | 16.16 | 13.29 | 0.58 | 7.61 | 0.41 | 10.66 | 10.07 |
| llama2-13b | 25.44 | 19.25 | 17.49 | 1.38 | 10.34 | 0.13 | 11.13 | 12.17 |
| Vicuna-13b | 22.63 | 18.04 | 14.67 | 0.70 | 9.27 | 3.59 | 10.25 | 11.31 |
| 中国アルパカ-Plus-13B | 22.53 | 13.82 | 11.29 | 0.28 | 1.52 | 0.31 | 8.13 | 8.27 |
| vsverse-13b | 29.26 | 24.03 | 16.67 | 2.78 | 11.61 | 3.08 | 14.26 | 14.53 |
| Baichuan-13b-base | 30.24 | 20.90 | 15.92 | 0.98 | 9.65 | 2.64 | 12.00 | 13.19 |
| Baichuan2-13b-base | 30.61 | 22.11 | 17.27 | 2.39 | 14.17 | 11.58 | 14.53 | 16.09 |
推論に必要なモデルの重み、ソースコード、および構成は、このドキュメントの最初の表を参照してください。ここで推論するさまざまな方法を示しています。このプログラムは、抱きしめる顔から必要なリソースを自動的にダウンロードします。
pip install -r requirements.txt >> > import torch
>> > from transformers import AutoModelForCausalLM , AutoTokenizer
>> > from transformers . generation . utils import GenerationConfig
>> > tokenizer = AutoTokenizer . from_pretrained ( "baichuan-inc/Baichuan2-13B-Chat" , use_fast = False , trust_remote_code = True )
>> > model = AutoModelForCausalLM . from_pretrained ( "baichuan-inc/Baichuan2-13B-Chat" , device_map = "auto" , torch_dtype = torch . bfloat16 , trust_remote_code = True )
>> > model . generation_config = GenerationConfig . from_pretrained ( "baichuan-inc/Baichuan2-13B-Chat" )
>> > messages = []
>> > messages . append ({ "role" : "user" , "content" : "解释一下“温故而知新”" })
>> > response = model . chat ( tokenizer , messages )
>> > print ( response )
"温故而知新"是一句中国古代的成语,出自《论语·为政》篇。这句话的意思是:通过回顾过去,我们可以发现新的知识和理解。换句话说,学习历史和经验可以让我们更好地理解现在和未来。
这句话鼓励我们在学习和生活中不断地回顾和反思过去的经验,从而获得新的启示和成长。通过重温旧的知识和经历,我们可以发现新的观点和理解,从而更好地应对不断变化的世界和挑战。 >> > from transformers import AutoModelForCausalLM , AutoTokenizer
>> > tokenizer = AutoTokenizer . from_pretrained ( "baichuan-inc/Baichuan2-13B-Base" , trust_remote_code = True )
>> > model = AutoModelForCausalLM . from_pretrained ( "baichuan-inc/Baichuan2-13B-Base" , 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 ))
登鹳雀楼- >王之涣
夜雨寄北- >李商隐上記の2つのコードでは、モデルは指定された
device_map='auto'をロードし、利用可能なすべてのグラフィックカードが使用されます。使用するデバイスを指定する必要がある場合は、export CUDA_VISIBLE_DEVICES=0,1(グラフィックカード0と1が使用されるなどのメソッドを使用できます。
python cli_demo.pyこのコマンドラインツールはチャットシナリオ用に設計されているため、このツールを使用してベースモデルの呼び出しをサポートしていません。
次のコマンドを実行するためにRiremlitに依存すると、Webサービスがローカルで開始され、コンソールで与えられたアドレスがアクセスするためにブラウザに配置されます。このWebデモツールはチャットシナリオ用に設計されているため、このツールを使用してベースモデルの呼び出しをサポートしていません。
streamlit run web_demo.py用户:找到下列数组的中位数[3.1,6.2,1.3,8.4,10.5,11.6,2.1],请用python代码完成以上功能
Baichuan 2:def find_median(numbers):
numbers.sort()
length = len(numbers)
if length % 2 == 0:
return (numbers[length // 2 - 1] + numbers[length // 2]) / 2
else:
return numbers[length // 2]
numbers = [3.1, 6.2, 1.3, 8.4, 10.5, 11.6, 2.1]
print(find_median(numbers))
用户:鸡和兔在一个笼子里,共有26个头,68只脚,那么鸡有多少只,兔有多少只?
Baichuan 2:我们可以用代数方法来解决这个问题。假设鸡的数量为x,兔子的数量为y。根据题目给出的信息,我们可以得到以下两个方程:
1. x + y = 26 (头的总数)
2. 2x + 4y = 68 (脚的总数)
现在我们需要解这个二元一次方程组。首先从第一个方程中解出x:
x = 26 - y
然后将x的表达式代入第二个方程:
2(26 - y) + 4y = 68
52 - 2y + 4y = 68
2y = 16
接下来我们求解y的值:
y = 16 / 2
y = 8
现在我们得到了兔子的数量是8只。将y的值代入x的表达式求得鸡的数量:
x = 26 - 8
x = 18
所以鸡有18只,兔子有8只。
用户:从现在开始,请你将我接下来说的每一句话翻译成英语,准备好了吗?
Baichuan 2:I'm ready to translate every word you say next into English.
用户:你好
Baichuan 2:Hello
用户:我是Baichuan 2,很高兴认识大家
Baichuan 2:I am Baichuan 2, and I am very happy to meet everyone.
用户:希望通过大家的共同努力,早日迎接AGI时代的到来
Baichuan 2:I hope through the joint efforts of all of us, we can welcome the arrival of the AGI era as soon as possible.
用户:以下物理常识题目,哪一个是错误的?A.在自然环境下,声音在固体中传播速度最快。B.牛顿第一定律:一个物体如果不受力作用,将保持静止或匀速直线运动的状态。C.牛顿第三定律:对于每个作用力,都有一个相等而反向的反作用力。D.声音在空气中的传播速度为1000m/s。
Baichuan 2:本题考查物理基本概念和原理的理解和应用能力。
A项:声音的传播需要介质,在固体、液体和气体的三种介质中,声音在固体中的传播速度是最快的,故A正确; B项:牛顿第一定律是惯性定律,其内容是:一个物体如果没有受到外力的作用,要么保持静止状态,要么保持匀速直线运动状态,直到有外力迫使它改变运动状态为止,故B正确; C项:牛顿第三定律的内容是:对于每一个作用力,都有一个大小相等、方向相反的反作用力,这两个力分别作用在两个相互作用的物体上,故C错误; D项:声音在空气中以波的形式传播,其传播速度与介质的温度、湿度等因素有关,一般情况下,声音在空气中的传播速度约为340m/s左右,而不是1000m/s,故D错误。 因此,本题的正确答案是 D 。
用户:I'm Mike 。I am going to have a busy weekend。On Saturday,I am going to learn how to swim。I will go with my father。Then we are going to have lunch in the restaurant。In the afternoon,we are going to the zoo。We are going to see the pandas。On Sunday,I will finish my homework in the morning。In the afternoon,my parents and I are going to visit my grandparents。We will have dinner together。
阅读短文,判断正确和错误!正确请写T,错误请写F:
1.Mike is going to have a busy weekend()
2.Mike is going to learn how to swim with his father()
3.They are going to have lunch at home()
Baichuan 2:1. T(正确的)
2. T(正确的)
3. F(错误的)
さまざまなユーザーとさまざまなプラットフォームがBaichuan 2モデルを実行できるようにするために、Baichuan 2モデル(Baichuan2-7b-chatおよびBaichuan2-13b-chatを含む)に対応する定量的作業を行い、ユーザーが独自のプラットフォームで迅速かつ効率的に展開できるようになりました。
Baichuan 2は、コミュニティの主流の定量的アプローチであるBitsandBytesを採用しています。この方法では、量子化効果が基本的に失われていないことを保証します。 BitsandBytesは、4ビットのFP4およびNF4形式をサポートしている8ビットと4ビットの量子化をサポートしています。
この量子化法に基づいて、Baichuan 2はオンライン量子化とオフライン量子化の2つのモードをサポートしています。
オンラインの量子化の場合、8ビットと4ビットの量子化は、 quantize() - cuda()プロジェクトに似ています。モデル全体の読み込みを実装するコードは非常に簡単です。
8ビットオンライン定量化:
model = AutoModelForCausalLM . from_pretrained ( "baichuan-inc/Baichuan2-7B-Chat" , torch_dtype = torch . float16 , trust_remote_code = True )
model = model . quantize ( 8 ). cuda () 4ビットオンライン量子化:
model = AutoModelForCausalLM . from_pretrained ( "baichuan-inc/Baichuan2-7B-Chat" , torch_dtype = torch . float16 , trust_remote_code = True )
model = model . quantize ( 4 ). cuda () from_pretrainedインターフェイスを使用する場合、ユーザーは通常、 device_map="auto"を追加する場合、このパラメーターを削除する必要があります。
ユーザーの使用を容易にするために、ユーザーがダウンロードできるオフラインの量子化バージョンbaichuan2-7b-chat-4bitsを提供します。 ユーザーがbaichuan2-7b-chat-4bitsモデルをロードするのは非常に簡単です。実行する必要があります。
model = AutoModelForCausalLM . from_pretrained ( "baichuan-inc/Baichuan2-7B-Chat-4bits" , device_map = "auto" , trust_remote_code = True )8ビットのオフラインの量子化の場合、対応するバージョンを提供することはできません。FaceFaceTransformersライブラリは、8ビットの定量モデルのストレージとロードを簡単に実装できる対応するAPIインターフェイスを提供するためです。ユーザーは、次の方法で8ビットモデルの保存と読み込みを実現できます。
# Model saving: model_id is the original model directory, and quant8_saved_dir is the directory where the 8bits quantized model is saved.
model = AutoModelForCausalLM . from_pretrained ( model_id , load_in_8bit = True , device_map = "auto" , trust_remote_code = True )
model . save_pretrained ( quant8_saved_dir )
model = AutoModelForCausalLM . from_pretrained ( quant8_saved_dir , device_map = "auto" , trust_remote_code = True )量子化前後のビデオメモリ使用量の比較(GBのGPU MEM):
| 精度 | Baichuan2-7b | Baichuan2-13b |
|---|---|---|
| BF16 / FP16 | 15.3 | 27.5 |
| 8ビット | 8.0 | 16.1 |
| 4ビット | 5.1 | 8.6 |
量子化後の各ベンチマークの結果と元のバージョンを以下に示します。
| モデル5ショット | C-EVAL | mmlu | cmmlu |
|---|---|---|---|
| Baichuan2-13b-chat | 56.74 | 57.32 | 59.68 |
| Baichuan2-13b-chat-4bits | 56.05 | 56.24 | 58.82 |
| Baichuan2-7b-chat | 54.35 | 52.93 | 54.99 |
| Baichuan2-7b-chat-4bits | 53.04 | 51.72 | 52.84 |
C-EVALは、VALセットで実施される評価です
ご覧のとおり、BFLOAT16に対する4ビットの精度損失は、約1〜2パーセントポイントです。
Baichuan 2モデルはCPU推論をサポートしていますが、CPU推論速度が比較的遅いことを強調する必要があります。モデル読み込み方法は、次のように変更する必要があります。
# Taking Baichuan2-7B-Chat as an example
model = AutoModelForCausalLM . from_pretrained ( "baichuan-inc/Baichuan2-7B-Chat" , torch_dtype = torch . float32 , trust_remote_code = True )多くのユーザーが、コンピレーションの最適化、量子化など、バイヒアン1(Baichuan-7B、Baichuan-13B)で多くの最適化作業を行っているため、これらの作業をゼロコストでBaichuan 2に適用するために、ユーザーはBaichuan 2モデルのオフライン変換を実行できます。具体的には、ユーザーは次のスクリプトを使用して、Baichuan 2モデルのLM_headの最後のレイヤーをオフラインで正規化し、 lm_head.weightを置き換えるだけです。交換後、Baichuan 1モデルのような変換されたモデルをコンパイルして最適化できます。
import torch
import os
ori_model_dir = 'your Baichuan 2 model directory'
# To avoid overwriting the original model, it's best to save the converted model to another directory before replacing it
new_model_dir = 'your normalized lm_head weight Baichuan 2 model directory'
model = torch . load ( os . path . join ( ori_model_dir , 'pytorch_model.bin' ))
lm_head_w = model [ 'lm_head.weight' ]
lm_head_w = torch . nn . functional . normalize ( lm_head_w )
model [ 'lm_head.weight' ] = lm_head_w
torch . save ( model , os . path . join ( new_model_dir , 'pytorch_model.bin' ))git clone https://github.com/baichuan-inc/Baichuan2.git
cd Baichuan2/fine-tune
pip install -r requirements.txt以下に、微調整Baichuan2-7Bベースのスタンドアロンのトレーニング例を示します。
トレーニングデータ: data/belle_chat_ramdon_10k.json 、サンプルデータはmultiTurn_chat_0.8mからサンプリングされ、フォーマット変換が実行されます。それは主に複数のラウンドのデータをトレーニングする方法を示しており、効果を保証しません。
hostfile= " "
deepspeed --hostfile= $hostfile fine-tune.py
--report_to " none "
--data_path " data/belle_chat_ramdon_10k.json "
--model_name_or_path " baichuan-inc/Baichuan2-7B-Base "
--output_dir " output "
--model_max_length 512
--num_train_epochs 4
--per_device_train_batch_size 16
--gradient_accumulation_steps 1
--save_strategy epoch
--learning_rate 2e-5
--lr_scheduler_type constant
--adam_beta1 0.9
--adam_beta2 0.98
--adam_epsilon 1e-8
--max_grad_norm 1.0
--weight_decay 1e-4
--warmup_ratio 0.0
--logging_steps 1
--gradient_checkpointing True
--deepspeed ds_config.json
--bf16 True
--tf32 Trueマルチマシントレーニングの場合、ホストファイルを与えるだけで、コンテンツは次のようになります。
ip1 slots=8
ip2 slots=8
ip3 slots=8
ip4 slots=8
....
同時に、トレーニングスクリプトのHosftfileへのパスを指定します。
hostfile= " /path/to/hostfile "
deepspeed --hostfile= $hostfile fine-tune.py
--report_to " none "
--data_path " data/belle_chat_ramdon_10k.json "
--model_name_or_path " baichuan-inc/Baichuan2-7B-Base "
--output_dir " output "
--model_max_length 512
--num_train_epochs 4
--per_device_train_batch_size 16
--gradient_accumulation_steps 1
--save_strategy epoch
--learning_rate 2e-5
--lr_scheduler_type constant
--adam_beta1 0.9
--adam_beta2 0.98
--adam_epsilon 1e-8
--max_grad_norm 1.0
--weight_decay 1e-4
--warmup_ratio 0.0
--logging_steps 1
--gradient_checkpointing True
--deepspeed ds_config.json
--bf16 True
--tf32 Trueコードは、LORAなどの軽量の微調整を既にサポートしています。上記のスクリプトに次のパラメーターを追加する必要があります。
--use_lora True LORAの特定の構成は、 fine-tune.pyスクリプトに記載されています。
LORAで微調整した後、次のコマンドを使用してモデルをロードできます。
from peft import AutoPeftModelForCausalLM
model = AutoPeftModelForCausalLM . from_pretrained ( "output" , trust_remote_code = True )2.6兆トークンでBaichuan2-7Bベースモデルをトレーニングすることに加えて、コミュニティ調査のためにさらに11の中間チェックポイント(それぞれ約0.2〜2.4兆トークン)を提供します(それぞれダウンロードアドレス)。次の図は、C-Eval、MMLU、およびCMMLUの3つのベンチマークに対するこれらのチェックポイントの効果の変化を示しています。

???私たちはここでBaichuan 2のコミュニティとエコシステムのサポートを更新し続けますか?
baichuan2-7b/chat、baichuan2-13b/チャットモデルをCore™/xiang®スケーラブルプロセッサまたはruixuan™gpusを使用して展開します。
BIGDL-LLM(CPU、GPU)は、より良い推論パフォーマンスを実現するために推奨されます。
ノートブックサポートを含む中国の操作マニュアル
読み込み、最適化、保存方法など。
モデルの微調整:Baichuan 2(7b)は、Pytorch(2.1.0) + Transformers(4.36.0) + Deepspeed(0.12.4) + Accelerate(0.25.0)モデルの微調整をネイティブにサポートしています。
推論の展開:Baichuan 2(7b)は、Ascend NPU推論をネイティブにサポートしており、追加の適応なしで使用できます。
Mindformersは、MindSpore Frameworkに基づいたフルプロセス開発キットであり、大規模なモデルトレーニング、評価、推論、展開をサポートしています。
Shengsi Big Model Platformは、Shengsi Mindspore AIフレームワーク、Mindformers Big Model Development Kit、Ascend Hardware Computing Powerに基づいており、Baichuan2-7Bのビッグモデル機能を一般に公開します。
Llama-efficient-Tuningは、Baichuan 2モデルの微調整と継続的なトレーニングをサポートしています。
Baichuan2(7b/13b)は、太平洋T100アクセラレーションカードの推論をサポートしており、試行チャネルが公式に公開されています。
ここで、開発チームは、iOS、Android、Webページ、またはその他のプラットフォームであろうと、Baichuan 2モデルに基づいてアプリを開発していないことを宣言します。私たちは、すべてのユーザーに、Baichuan 2モデルを使用して、国の社会保障や違法を危険にさらす活動を実施しないように強く呼びかけています。さらに、ユーザーは、適切にセキュリティレビューおよび登録されていないインターネットサービスにBaichuan 2モデルを使用しないように求められます。すべてのユーザーがこの原則を順守し、科学技術の開発を標準化された法的環境で実施できるようにすることができることを願っています。
モデルトレーニング中に使用されるデータのコンプライアンスを確保するために、できる限りのことをしました。しかし、私たちの多大な努力にもかかわらず、モデルとデータの複雑さのために、まだいくつかの予期せぬ問題があります。したがって、データセキュリティの問題、世論のリスク、またはモデルの誤解を招く、虐待、普及、普及、または不適切な使用から生じるリスクや問題を含むがこれらに限定されない、Baichuan 2オープンソースモデルの使用から生じる問題について、責任を負いません。
コミュニティは、Baichuan 2モデルを使用して、Apache 2.0とBaichuan 2モデルコミュニティライセンス契約に従います。 Baichuan 2モデルは、商業的に商業的に役立ちます。
上記の条件が満たされている場合は、次のメールアドレス[email protected]を通じて、Baichuan 2モデルコミュニティライセンス契約に必要な申請資料を提出する必要があります。レビューが承認された後、Baichuanはこれにより、非独占的、グローバル、非譲渡不可能な、非公開、取り消し可能な商業著作権ライセンスを付与します。
私たちの仕事を引用するには、次の参照を使用してください。
@article{baichuan2023baichuan2,
title={Baichuan 2: Open Large-scale Language Models},
author={Baichuan},
journal={arXiv preprint arXiv:2309.10305},
url={https://arxiv.org/abs/2309.10305},
year={2023}
}