1. 基本タスク
InternStudioでInternlm2-7bを使用して標準版の茴香豆知識アシスタントを構築し、Gradioインターフェースを使用して2回の質問と回答を行います(質問はチュートリアルと重複しないようにしてください)。スクリーンショットにはGradioインターフェースと茴香豆の回答を含めてください。知識ベースは、金融、医療、法律、音楽、アニメなど、自身の仕事、学習、または興味のある内容に調整できます。
2. 茴香豆のローカル標準版構築
2.1 環境構築
2.1.1 サーバー設定
まず、InternStudioにログインし、開発機を作成します。
ミラーアイメージは`Cuda11.7-conda`を選択し、リソースタイプは`30% A100`を選択します。開発機名を`huixiangdou`と入力し、即時作成をクリックします。
サーバーが準備できたら、開発機に入り、開発環境を構築します。
2.1.2 茴香豆用仮想環境の構築
以下のコマンドを入力して、茴香豆専用のconda環境を作成します:
studio-conda -o internlm-base -t huixiangdou
conda activate huixiangdou
環境がアクティブ化されたことを確認し、すべての茴香豆操作は`huixiangdou`環境下で行うようにしてください。
2.2 茴香豆のインストール
2.2.1 茴香豆のダウンロード
サーバーに茴香豆のコードをクローンします:
cd /root
git clone https://github.com/internlm/huixiangdou && cd huixiangdou
git checkout 79fa810
2.2.2 依存関係のインストール
以下のように依存関係をインストールします:
conda activate huixiangdou
apt update
apt install python-dev libxml2-dev libxslt1-dev antiword unrtf poppler-utils pstotext tesseract-ocr flac ffmpeg lame libmad0 libsox-fmt-mp3 sox libjpeg-dev swig libpulse-dev
pip install BCEmbedding==0.1.5 cmake==3.30.2 lit==18.1.8 sentencepiece==0.2.0 protobuf==5.27.3 accelerate==0.33.0
pip install -r requirements.txt
2.2.3 モデルファイルのダウンロード
必要なモデルファイルをシンボリックリンクで指定します:
cd /root
mkdir models
ln -s /root/share/new_models/maidalun1020/bce-embedding-base_v1 /root/models/bce-embedding-base_v1
ln -s /root/share/new_models/maidalun1020/bce-reranker-base_v1 /root/models/bce-reranker-base_v1
ln -s /root/share/new_models/Shanghai_AI_Laboratory/internlm2-chat-7b /root/models/internlm2-chat-7b
2.2.4 設定ファイルの変更
設定ファイルを変更して、ローカルのモデルを使用するようにします:
sed -i '9s#.*#embedding_model_path = "/root/models/bce-embedding-base_v1"#' /root/huixiangdou/config.ini
sed -i '15s#.*#reranker_model_path = "/root/models/bce-reranker-base_v1"#' /root/huixiangdou/config.ini
sed -i '43s#.*#local_llm_path = "/root/models/internlm2-chat-7b"#' /root/huixiangdou/config.ini
2.3 知識ベースの作成
設定ファイルを修正したら、知識ベースを構築します。以下のリポジトリをクローンします:
conda activate huixiangdou
cd /root/huixiangdou
mkdir repodir
git clone https://github.com/internlm/huixiangdou --depth=1 repodir/huixiangdou
git clone https://github.com/open-mmlab/mmpose --depth=1 repodir/mmpose
git clone https://github.com/dennybritz/reinforcement-learning.git --depth=1 repodir/reinforcement-learning
git clone https://github.com/BradyFU/Awesome-Multimodal-Large-Language-Models.git --depth=1 repodir/awesome-multi-llm
git clone https://github.com/amusi/CVPR2024-Papers-with-Code.git --depth=1 repodir/cvpr2024
git clone https://github.com/fengdu78/Coursera-ML-AndrewNg-Notes.git --depth=1 repodir/ml-learning
git clone https://github.com/krishauser/RoboticSystemsBook.git --depth=1 repodir/rob
mkdir workdir
python3 -m huixiangdou.service.feature_store
2.4 茴香豆知識アシスタントのテスト
2.4.1 コマンドラインでの実行
以下のコマンドを実行して、コマンドラインから知識ベースQAアシスタントをテストします:
conda activate huixiangdou
cd /root/huixiangdou
python3 -m huixiangdou.main --standalone
2.4.2 Gradio UIでのテスト
Gradioを使用してWeb UIテストインターフェースを構築します。ローカルとサーバー間のポートフォワーディングを設定します:
ssh -CNg -L 7860:127.0.0.1:7860 root@ssh.intern-ai.org.cn -p 38964
サーバー側でGradio UIを起動します:
conda activate huixiangdou
cd /root/huixiangdou
python3 -m huixiangdou.gradio
ブラウザで`127.0.0.1:7860`を開き、茴香豆アシスタントのテストページを表示します。