見出し画像

Alpaca-LoRAを使ってみた

ここ最近、Alpaca-LoRAという言葉を目にする機会が増えていたので試してみます。

Alpaca-LoRAは、Alpacaというモデルをlow-rank adaptation (LoRA)という手法で軽量化したものになります。学習はRTX4090一台で5時間以内に完了すると報告されています。Alpaca-LoRAは、低コストでAlpacaと同等の出力を得ることができる言語モデルです。また、Raspberry Piでも動かすことができます。


今回は、下記のページを参考にGoogle Colabで実行してみます。


Google Colabで動くソースコードは以下です。

!git clone https://github.com/tloen/alpaca-lora.git
%cd alpaca-lora/

!pip install -r requirements.txt

次に、generate.pyというところで、最後の行にある下記をshare=Trueに修正します。

    ).launch(server_name="0.0.0.0", share=share_gradio)

修正後のgenerate.pyは以下です。

    ).launch(server_name="0.0.0.0", share=True)

これに書き換えると、Webからもアクセスできるようになります。

そして、次に、下記を実行します。

!python generate.py \
    --load_8bit \
    --base_model 'decapoda-research/llama-7b-hf' \
    --lora_weights 'tloen/alpaca-lora-7b'


最後の行にhttpsのURLが出てくるので開いてみましょう。


日本の人口はどのくらいですか?と聞いたら、英語で回答してくれました。Google ColabのGPU標準でこのレベルを提供してもらえるのは今後の発展が期待できます。ただ、回答まで約16秒ほどかかるので、まだまだ改善は必要な状況です。


最後に、Alpaca-LoRAについて説明してもらいました。

Alpaca-LoRA is an open-source machine learning library for Python. It is designed to make it easy to build and deploy machine learning models. Alpaca-LoRA supports a variety of algorithms, including linear and logistic regression, support vector machines, random forests, and neural networks. It also provides tools for data preprocessing, model selection, and hyperparameter optimization.

Alpaca-LoRAについて説明してください。の回答

Support Vector Machineを含むアルゴリズムをサポートしていると書いてあるが本当か気になりました。

この記事が気に入ったらサポートをしてみませんか?