LoginSignup
0
0

japanese-stablelm-instruct-alpha-7b-v2をtext-generation-webuiで動かした備忘録

Last updated at Posted at 2023-10-14

なんかそのままだと動かなかったのでメモ

私はこの手の専門家ではないので、本当に治し方が合っているは分かりません。
あと将来的には直っているかも(執筆日:2023/10/14)

text-generation-webuiとjapanese-stablelm-instruct-alpha-7b-v2はダウンロード済みの想定です。

1.modules/models.pyの102行目辺りにtokenizerの処理を入れる

novelai-tokenizer?で初期化するようにします。
(huggingfaceに置いてあるサンプルコードと同じものです)
これがないとロード中にエラーが発生します。

def load_tokenizer(model_name, model):
    tokenizer = None
    path_to_model = Path(f"{shared.args.model_dir}/{model_name}/")
    if any(s in model_name.lower() for s in ['gpt-4chan', 'gpt4chan']) and Path(f"{shared.args.model_dir}/gpt-j-6B/").exists():
        tokenizer = AutoTokenizer.from_pretrained(Path(f"{shared.args.model_dir}/gpt-j-6B/"))
    #以下の3行
    elif model_name.find("stablelm-instruct-alpha-7b-v2") != -1:
        from transformers import LlamaTokenizer
        tokenizer = LlamaTokenizer.from_pretrained("novelai/nerdstash-tokenizer-v1", additional_special_tokens=['▁▁'])
    elif path_to_model.exists():
        if shared.args.use_fast:
            logger.info('Loading the tokenizer with use_fast=True.')

        tokenizer = AutoTokenizer.from_pretrained(
            path_to_model,
            trust_remote_code=shared.args.trust_remote_code,
            use_fast=shared.args.use_fast
        )

    return tokenizer

2.trust-remote-codeをチェックしロード

trust-remote-codeにチェックを入れ、モデルをロードします。
(私のマシンはVRAM12GBの非力マンなので、加えてload-in-8bitも指定しています。)
スクリーンショット 2023-10-14 17.48.30.png
これでモデルがロードできれば成功です

3.動作風景

「メロスはあり得ないぐらいにめっちゃ激怒した」と入れてみる。
スクリーンショット 2023-10-14 17.55.54.png
メロスがやべーやつになってますが、なんかいい感じに書いてくれてますね。

次に質問っぽいのも
スクリーンショット 2023-10-14 18.24.16.png
質問に対する回答はあっていますね。それ以外の情報は分かりませんが…
ただ毎回合っているわけではなく、的外れな回答も返ってくるようです。
スクリーンショット 2023-10-14 18.23.22.png
次に、公式のフォーマットに極力沿ってやってみます。

スクリーンショット 2023-10-14 18.20.37.png
「にゃん」は付けてくれなかったけど、いい感じで返答してくれましたね。

次にコード生成を試してみる。
スクリーンショット 2023-10-14 18.32.39.png
書いてはくれるもののでたらめですね…
うーむ。load-in-8bitの弊害なのかな?
あるいはちゃんと直せていないのか…

ともあれ、OSSでこのクオリティは将来が楽しみです

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0