huggingface-cli.exe login
コマンドは1回実行するだけでよいかもしれません。(未検証)Text generation web UIで Japanese StableLM Instruct Alpha 7B (japanese-stablelm-instruct-alpha-7b) を実行する手順を紹介します。
Stability AI Japan により日本語のLLMモデル、Japanese StableLM Instruct Alpha 7B (japanese-stablelm-instruct-alpha-7b) が提供されました。
Text generation web UIでこのモデルを実行してみます。
Hugging Faceのjapanese-stablelm-instruct-alpha-7bのHub
(https://huggingface.co/stabilityai/japanese-stablelm-instruct-alpha-7b)にアクセスします。
[Files and versions]のタブをクリックします。下図のページが表示されます。ファイルの一覧が表示されますので、
すべてのファイルをダウンロードします。(fp16, int8を利用しない場合は、fp16やint8のファイルは不要です。)
なお、ログインしていない場合は、ログインしてライセンス規約に同意する必要があります。
Tokenizerをダウンロードします。今回はnerdstash-tokenizer-v1を利用します。
Hugging FaceのHubのページ(https://huggingface.co/NovelAI/nerdstash-tokenizer-v1)にアクセスします。
[Files and versions]のタブをクリックます。下図のページが表示されます。ファイル一覧が表示されます。special_tokens_map.json, tokenizer.model, tokenizer_config.json をダウンロードします。
モデルファイルとTokenizerのファイルを以下のディレクトリに配置します。
(WebUIの配置ディレクトリ)\text-generation-webui¥models\stabilityai_japanese-stablelm-instruct-alpha-7b
Hugging Faceのトークンを取得します。手順はこちらの記事を参照してください。
start_windows.bat に 次のhuggingface-cli.exe を実行するコマンドを記述し、WebUI 起動時にHugging Faceにログインした状態にします。
.\installer_files\env\Scripts\huggingface-cli.exe login --token (Hagging Faceのトークン)
huggingface-cli.exe login
コマンドは1回実行するだけでよいかもしれません。(未検証)@echo off
@rem この行を追加
.\installer_files\env\Scripts\huggingface-cli.exe login --token hf_****************************
cd /D "%~dp0"
set PATH=%PATH%;%SystemRoot%\system32
echo "%CD%"| findstr /C:" " >nul && echo This script relies on Miniconda which can not be silently installed under a path with spaces. && goto end
@rem Check for special characters in installation path
set "SPCHARMESSAGE="WARNING: Special characters were detected in the installation path!" " This can cause the installation to fail!""
echo "%CD%"| findstr /R /C:"[!#\$%&()\*+,;<=>?@\[\]\^`{|}~]" >nul && (
call :PrintBigMessage %SPCHARMESSAGE%
)
set SPCHARMESSAGE=
@rem fix failed install when installing to a separate drive
set TMP=%cd%\installer_files
set TEMP=%cd%\installer_files
@rem config
set INSTALL_DIR=%cd%\installer_files
set CONDA_ROOT_PREFIX=%cd%\installer_files\conda
set INSTALL_ENV_DIR=%cd%\installer_files\env
set MINICONDA_DOWNLOAD_URL=https://repo.anaconda.com/miniconda/Miniconda3-py310_23.3.1-0-Windows-x86_64.exe
set conda_exists=F
@rem figure out whether git and conda needs to be installed
call "%CONDA_ROOT_PREFIX%\_conda.exe" --version >nul 2>&1
if "%ERRORLEVEL%" EQU "0" set conda_exists=T
@rem (if necessary) install git and conda into a contained environment
@rem download conda
if "%conda_exists%" == "F" (
echo Downloading Miniconda from %MINICONDA_DOWNLOAD_URL% to %INSTALL_DIR%\miniconda_installer.exe
mkdir "%INSTALL_DIR%"
call curl -Lk "%MINICONDA_DOWNLOAD_URL%" > "%INSTALL_DIR%\miniconda_installer.exe" || ( echo. && echo Miniconda failed to download. && goto end )
echo Installing Miniconda to %CONDA_ROOT_PREFIX%
start /wait "" "%INSTALL_DIR%\miniconda_installer.exe" /InstallationType=JustMe /NoShortcuts=1 /AddToPath=0 /RegisterPython=0 /NoRegistry=1 /S /D=%CONDA_ROOT_PREFIX%
@rem test the conda binary
echo Miniconda version:
call "%CONDA_ROOT_PREFIX%\_conda.exe" --version || ( echo. && echo Miniconda not found. && goto end )
)
@rem create the installer env
if not exist "%INSTALL_ENV_DIR%" (
echo Packages to install: %PACKAGES_TO_INSTALL%
call "%CONDA_ROOT_PREFIX%\_conda.exe" create --no-shortcuts -y -k --prefix "%INSTALL_ENV_DIR%" python=3.10 || ( echo. && echo Conda environment creation failed. && goto end )
)
@rem check if conda environment was actually created
if not exist "%INSTALL_ENV_DIR%\python.exe" ( echo. && echo Conda environment is empty. && goto end )
@rem environment isolation
set PYTHONNOUSERSITE=1
set PYTHONPATH=
set PYTHONHOME=
set "CUDA_PATH=%INSTALL_ENV_DIR%"
set "CUDA_HOME=%CUDA_PATH%"
@rem activate installer env
call "%CONDA_ROOT_PREFIX%\condabin\conda.bat" activate "%INSTALL_ENV_DIR%" || ( echo. && echo Miniconda hook not found. && goto end )
@rem setup installer env
call python webui.py
@rem below are functions for the script next line skips these during normal execution
goto end
:PrintBigMessage
echo. && echo.
echo *******************************************************************
for %%M in (%*) do echo * %%~M
echo *******************************************************************
echo. && echo.
exit /b
:end
pause
start_windows.batを実行し、WebUIを起動します。画面上部の[Model]タブをクリックします。下図の画面が表示されます。
画面左上の[Model]のドロップダウンリストボックスをクリックします。
ドロップダウンリストから"stabilityai_japanese-stablelm-instruct-alpha-7b" の項目をクリックして選択します。
選択後、[trust-remote-code]のチェックボックスをクリックしてチェックをつけます。
チェック後[Model]ドロップダウンリストの右側の[Load]ボタンをクリックします。
モデルの読み込みが実行されます。
モデルの読み込みが成功しました。
Chat画面に切り替えて、日本語で会話をしてみます。入力に対して返答があります。
以下のエラーメッセージが表示された場合は、[trust-remote-code] にチェックがついていない場合があります。
以下のエラーが発生した場合は、Hugging Faceにログインできていないため、以下の huggingface-cli.exe コマンドを実行します。
(WebUIの配置ディレクトリ)\installer_files\env\Scripts\huggingface-cli.exe login --token (Hagging Faceのトークン)