モデル概要
モデル特徴
モデル能力
使用事例
🚀 SpeechGPT: 内在的なクロスモーダル会話能力を備えた大規模言語モデル
🚀 クイックスタート
SpeechGPTは、内在的なクロスモーダル会話能力を備えた大規模言語モデルで、人間の指示に従ってマルチモーダルなコンテンツを知覚し、生成することができます。離散的な音声表現を用いて、まず大規模なクロスモーダル音声指示データセットであるSpeechInstructを構築しました。さらに、モダリティ適応事前学習、クロスモーダル指示微調整、モダリティ連鎖指示微調整を含む3段階の学習戦略を採用しています。実験結果から、SpeechGPTはマルチモーダルな人間の指示に従う能力が高く、1つのモデルで複数のモダリティを扱う可能性が示されています。
SpeechGPTのデモはプロジェクトページで公開されています。デモに示されているように、SpeechGPTは強力なクロスモーダル指示追従能力と音声対話能力を持っています。SpeechGPTは会話する百科事典、パーソナルアシスタント、チャットパートナー、詩人、心理カウンセラー、教育アシスタントなどとして機能することができます。
SpeechGPTの複数のクロスモーダルタスクを処理する能力
左: SpeechInstructの構築プロセス。 右: SpeechGPTのモデル構造
✨ 主な機能
- 内在的なクロスモーダル会話能力を備え、人間の指示に従ってマルチモーダルコンテンツを知覚・生成
- 3段階の学習戦略を用いて、高いモダリティ適応能力と指示追従能力を獲得
- 音声対話、音声認識、テキスト読み上げなどの多様なタスクを処理可能
📦 インストール
ソースコードのクローン
git clone https://github.com/0nutation/SpeechGPT
cd SpeechGPT
仮想環境の作成とアクティベート
conda create --name SpeechGPT python=3.8
conda activate SpeechGPT
依存パッケージのインストール
pip install -r requirements.txt
モデルのダウンロード
SpeechGPTと会話するには、SpeechGPT-7B-cmとSpeechGPT-7B-comをローカルにダウンロードする必要があります。
mHuBERTモデルのダウンロード
s2u_dir="uitls/speech2unit"
cd ${s2u_dir}
wget https://dl.fbaipublicfiles.com/hubert/mhubert_base_vp_en_es_fr_it3.pt
wget https://dl.fbaipublicfiles.com/hubert/mhubert_base_vp_en_es_fr_it3_L11_km1000.bin
ユニットボコーダーのダウンロード
vocoder_dir="utils/vocoder/"
cd ${vocoder_dir}
wget https://dl.fbaipublicfiles.com/fairseq/speech_to_speech/vocoder/code_hifigan/mhubert_vp_en_es_fr_it3_400k_layer11_km1000_lj/config.json -O config.json
wget https://dl.fbaipublicfiles.com/fairseq/speech_to_speech/vocoder/code_hifigan/mhubert_vp_en_es_fr_it3_400k_layer11_km1000_lj/g_00500000 -O vocoder.pt
💻 使用例
CLI推論
python3 speechgpt/src/infer/cli_infer.py \
--model-name-or-path "path/to/SpeechGPT-7B-cm" \
--lora-weights "path/to/SpeechGPT-7B-com" \
--s2u-dir "${s2u_dir}" \
--vocoder-dir "${vocoder_dir} \
--output-dir "output"
Gradio Web UI
python3 speechgpt/src/infer/web_infer.py \
--model-name-or-path "path/to/SpeechGPT-7B-cm" \
--lora-weights "path/to/SpeechGPT-7B-com" \
--s2u-dir "${s2u_dir}" \
--vocoder-dir "${vocoder_dir}" \
--output-dir "output/"
テキスト対話の例
Please talk with SpeechGPT:
Who is Lebron James?
Response:
Lebron James is an American professional basketball player for the Los Angeles Lakers of the National Basketball Association (NBA). He is considered one of the greatest basketball players of all time and is known for his athleticism, scoring ability, and leadership skills. He is a four-time NBA MVP, a 14-time NBA All-Star, a 13-time All-NBA selection, and a two-time Olympic gold medalist.
Response json is saved in output/responses.json
音声対話の例
Please talk with SpeechGPT:
prompts/0.wav
Transcript: What are the main causes of climate change?
Text response: The main causes of climate change are human activities such as burning fossil fuels, deforestation, and agricultural practices. These activities release greenhouse gases, like carbon dioxide and Methane, into the atmosphere which trap heat and cause the Earth's temperature to rise.
Speech repsonse is saved in output/wav/answer_0.wav
Response json is saved in output/responses.json
音声認識の例
Please talk with SpeechGPT:
Recognize this speech, this is input: prompts/1.wav
Response:
today is a sunny day.
Response json is saved in output/responses.json
テキスト読み上げの例
Please talk with SpeechGPT:
Read this sentence aloud, this is input: Today is a sunny day.
Response:
<sosp> <661> <987> <520> <982> <681> <982> <681> <982> <681> <982> <681> <982> <189> <63> <662> <79> <868> <220> <196> <166> <549> <822> <89> <194> <633> <14> <855> <183> <609> <389> <771> <865> <641> <124> <362> <734> <742> <98> <519> <26> <204> <280> <668> <167> <104> <650> <179> <961> <428> <950> <82> <165> <196> <166> <549> <822> <89> <194> <458> <726> <603> <819> <651> <133> <651> <133> <186> <133> <186> <133> <186> <511> <186> <511> <eosp>
Speech repsonse is saved in output/wav/answer_1.wav
Response json is saved in output/responses.json
🔧 技術詳細
第1段階: モダリティ適応事前学習
まず、mHuBERTを利用してLibriLightデータセットを離散化し、第1段階の学習に必要な離散ユニットシーケンスを取得します。データ処理方法については、Speech2unitを参照してください。
次に、離散ユニットを学習セットと開発セットに分割し、以下の形式でdata/stage1/train.txt
とdata/stage1/dev.txt
に保存します。
<sosp><189><247><922><991><821><258><485><974><284><466><969><523><196><202><881><331><822><853><432><32><742><98><519><26><204><280><576><384><879><901><555><944><366><641><124><362><734><156><824><462><761><907><430><81><597><716><205><521><470><821><677><355><483><641><124><243><290><978><82><620><915><470><821><576><384><466><398><212><455><931><579><969><778><45><914><445><469><576><803><6><803><791><377><506><835><67><940><613><417><755><237><224><452><121><736><eosp>
<sosp><300><189><63><6><665><991><881><331><6><384><879><945><29><244><583><874><655><837><81><627><545><124><337><850><412><213><260><41><740><797><211><488><961><428><6><196><555><944><873><32><683><700><955><812><328><915><166><250><56><903><86><233><479><330><776><167><104><764><259><921><366><663><432><431><531><976><314><822><89><664><377><611><479><417><eosp>
<sosp><189><735><991><39><565><734><32><742><98><519><26><204><280><668><576><803><791><660><555><233><787><101><741><466><969><219><107><459><491><556><384><733><219><501><445><137><910><523><793><50><981><230><534><321><948><86><116><281><62><462><104><70><918><743><15><212><455><143><836><173><944><958><390><422><66><776><258><436><139><663><432><742><98><519><589><243><126><260><41><444><6><655><764><969><219><727><85><297><700><362><493><6><493><361><393><946><6><470><821><246><655><837><81><969><916><584><819><544><452><158><452><736><eosp>
最後に、LLaMA 7B(HuggingFace)をllama/hf/7B
にダウンロードします。
これで第1段階の学習を開始することができます。分散学習を行う場合は、NNODE
、NODE_RANK
、MASTER_ADDR
、MASTER_PORT
の正しい値を指定する必要があります。
bash scripts/ma_pretrain.sh ${NNODE} ${NODE_RANK} ${MASTER_ADDR} ${MASTER_PORT}
第2段階: クロスモーダル指示微調整
SpeechInstruct Cross-modal Instruction setをダウンロードし、微調整を行います。
📄 ライセンス
本プロジェクトのライセンスについては、リポジトリ内のLICENSE
ファイルを参照してください。











