見出し画像

【MemGPTとローカルモデルの活用ガイド】英語解説を日本語で読む【2023年10月27日|@Matthew Berman】

この動画では、MemGPTチームがローカルLLMサポートとAuto GPTへの統合を公開していること、およびMemGPTとオープンソースのローカルモデルの使用方法を紹介しています。Runpodとローカルマシンの実行方法は同じで、オープンソースモデルを選択し、Transformersを使ってモデルをロードします。具体的な使用例は示されていませんが、動画の中でローカルモデルの動作を示しています。
公開日:2023年10月27日
※動画を再生してから読むのがオススメです。


The team behind MemGPT have been hard at work since I published my research paper review and intro tutorial on Friday.

私が金曜日に研究論文のレビューとイントロチュートリアルを発表して以来、MemGPTのチームは懸命に働いている。

They've already released local LLM support and an integration into AutoGPT.

すでにローカルLLMのサポートとAutoGPTへの統合をリリースしている。

Today, I'm going to show you how to use an open-source local model with MemGPT.

今日は、MemGPTでオープンソースのローカルモデルを使う方法をお見せします。

And in the next video coming soon, I'm going to show you how to use autogen with MemGPT.

そして次のビデオでは、MemGPTでオートジェンを使う方法をお見せします。

So let's go.

それでは行きましょう。

So, I'm going to be doing this on run pod because I can't run inference and record video at the same time without my computer absolutely hating me.

というのも、推論を実行しながら同時にビデオを録画するのは、コンピューターに嫌われない限りできないからです。

But you can do this the same exact way on your local machine.

でも、ローカルマシンでもまったく同じようにできます。

What we're going to be using is text generation web UI to expose an API based on the open source model we're choosing.

これから使うのは、オープンソースのモデルに基づいたAPIを公開するためのテキスト生成ウェブUIだ。

But if you do want to run it on runpod, here's a few steps to do so.

しかし、もしrunpod上で実行したいのであれば、いくつかの手順を紹介しよう。

You're going to click on secure Cloud.

secure Cloudをクリックする。

You're going to scroll down.

下にスクロールします。

You're going to select a GPU.

GPUを選択します。

I'm going to use this RTX a6000.

このRTX a6000を使うことにする。

Let's click deploy.

デプロイをクリックします。

I don't need to change anything, but if we click customize deployment right here, 78 860, that's the interface, and 5000 is the port for the API.

何も変更する必要はないが、ここでデプロイのカスタマイズをクリックすると、78 860がインターフェースで、5000がAPIのポートになる。

So we'll just leave that the same.

これはそのままにしておきます。

And then we click continue and deploy.

続けてデプロイをクリックします。

And so, this first step, we're just going to be downloading the model and getting it set up and the API exposed so MemGPT can use it.

最初のステップでは、モデルをダウンロードしてセットアップし、APIを公開してMemGPTが使えるようにします。

Once we're here, we're going to wait for it to fully load.

モデルが完全にロードされるまで待ちます。

Then we click connect.

それから接続をクリックします。

And then we click connect to http service.

そしてhttpサービスに接続をクリックします。

And we're going to be using Port 7860, that's the interface, because the first thing we need to do is actually download the model.

そして、ポート7860を使用します。これはインターフェースです。なぜなら、最初にモデルをダウンロードする必要があるからです。

Now, the model we're going to be using today is Dolphin 2.0 mistol 7B.

さて、今日使用するモデルはDolphin 2.0 mistol 7Bです。

It is a smallish model, so I'm going to go ahead and click copy.

小さめのモデルなので、コピーをクリックします。

But I spoke to the authors and they said that the aerob boros prompt template tends to work best.

しかし、作者と話したところ、エアロブボロスのプロンプトテンプレートが一番うまくいく傾向があるとのことでした。

But for the purposes of just showing how to get it done, I'm going to use the smaller model.

しかし、どうすればできるかを示すという目的のために、小さい方のモデルを使うことにする。

Switch over to the model tab in text generation web UI.

テキスト生成ウェブUIのモデルタブに切り替えてください。

We're going to paste that model card info.

モデルカードの情報を貼り付けます。

And then we're going to click download.

そしてダウンロードをクリックします。

And again, all of this is the same exact thing you would do if you were installing it on your local machine.

繰り返しますが、この作業はすべて、ローカルマシンにインストールする場合とまったく同じです。

I have a video going over how to install text generation web UI on your computer.

テキスト生成ウェブUIをコンピュータにインストールする方法については、ビデオをご覧ください。

I'll drop that link in the description below.

そのリンクを以下の説明に載せます。

And I also want to say a quick thank you to Charles and Vivien, two of the authors from MemGPT, for helping me figure out a few remaining bugs.

MemGPTの作者であるCharlesとVivienには、残っていたバグを解決するのを手伝ってもらった。

This stuff is Cutting Edge.

これはカッティング・エッジだ。

This is all completely new, very raw.

これはすべて完全に新しく、非常に生のものだ。

There's going to be lots of bugs.

バグはたくさんあるだろう。

But if you're watching this video and you're following along and getting this working, you are on the absolute Cutting Edge of artificial intelligence.

しかし、もしこのビデオを見ていて、ついてきて、これが動くようになったなら、あなたは人工知能の絶対的な最先端にいることになる。

But with it comes a little Fric.

でも、それにはちょっとしたフリックが必要なんだ。

Okay, it's done.

よし、できた。

Says done right there.

そこに「完了」と表示されています。

Now what we're going to do is we're going to use the model loader Transformerscause this is an unquantized model.

今度は、モデルローダーTransformersを使用します。これは量子化されていないモデルです。

We're going to click this little refresh button, which will load up the model that we just downloaded.

この小さな更新ボタンをクリックすると、ダウンロードしたばかりのモデルがロードされます。

Now, it still has that bug where it selects the model, but if I click on it, it still selects none.

さて、モデルを選択するバグがまだ残っていますが、クリックしても「なし」が選択されます。

So you have to click none.

ですから、noneをクリックする必要があります。

And then switch back to the new model.

そして新しいモデルに切り替える。

Once we do that, we're going to click this load button and it's going to load the model into memory.

そうしたら、このロードボタンをクリックして、モデルをメモリにロードします。

Okay, successfully loaded.

OK、正常にロードされました。

So, one quick thing I want to show you is click over to the session tab.

では、一つ早いことをお見せしたいのですが、セッションタブに移動してください。

And last time when we were using runpod to power autogen with a local model, I enabled this OpenAI flag right here.

前回、runpodを使ってローカルモデルでオートジェンを動かすときに、このOpenAIフラグを有効にしました。

And then I applied extensions.

そして拡張機能を適用しました。

We are not going to be doing that this time.

今回はそれを行いません。

We're going to be using the default API provided by text generation web UI.

テキスト生成ウェブUIが提供するデフォルトのAPIを使うことにする。

And so we're pretty much done.

そして、ほぼ終わりです。

Next, we're going to come up here to the URL and we're going to copy the URL.

次に、URLに移動してURLをコピーします。

Next, we're going to follow the same steps to get MemGPT installed as we did on Friday.

次に、金曜日と同じ手順でMemGPTをインストールするためのステップを踏みます。

So, get clone and then the GitHub URL.

clone を取得し、GitHub の URL を取得します。

Hit enter.

エンターキーを押してください。

And by the way, the authors already put together a MemGPT module, so you don't technically need to clone the repository.

ちなみに、作者はすでにMemGPTモジュールを作っているので、技術的にはリポジトリをcloneする必要はありません。

But I like doing that.

でも僕はそうするのが好きなんだ。

I feel like I have a little bit more control.

もう少しコントロールできるような気がする。

But if I were to use MemGPT in a production level project, I wouldn't do that.

でも、本番レベルのプロジェクトでMemGPTを使うとしたら、そんなことはしない。

I would just use the module and install it.

モジュールを使ってインストールするだけだ。

Now we're going to change directory into MemGPT.

では、ディレクトリをMemGPTに変更します。

CD MemGPT.

CD MemGPT。

Hit enter.

エンターキーを押してください。

Next, we're going to run the command export open aore aior base all capitals equals.

次に、export open aore aior base all capitals equalsというコマンドを実行します。

And then, we're going to put the URL of the runp Pod instance.

そしてrunp PodインスタンスのURLを入力する。

And we're going to change one thing.

そして、1つだけ変更します。

Rather than 7860 as the port, we're going to write 5,000.

ポートは7860ではなく、5000とします。

And that's going to be the API.

これがAPIになります。

And I'm going to remove that trailing slash.

そして末尾のスラッシュを削除する。

And that's it.

これで完了だ。

Hit enter.

エンターキーを押す。

And that's going to tell MemGPT to use this URL as the API endpoint instead of OpenAI.

これでMemGPTがOpenAIの代わりにこのURLをAPIのエンドポイントとして使うようになる。

Next, we're going to set backend type to web UI.

次に、バックエンドのタイプをWeb UIに設定します。

Just like that.

こんな感じだ。

Export backend type web UI.

Export backend type web UI.

Enter.

入力する。

Actually, I forgot to do one thing.

実は、一つ忘れていました。

We actually have to install the requirements.

要件をインストールしなければならない。

So let's go ahead and spin up a conda environment.

それではconda環境を立ち上げてみましょう。

And we don't need to change anything else.

あとは何も変更する必要はない。

Everything else should work.

あとは全部うまくいくはずだ。

The ordering didn't matter so far.

順序は今のところ関係ない。

So I'm going to say conda create -n autom MemGPT python=3.1 1.3.

conda create -n autom MemGPT python=3.1 1.3とします。

Hit enter.

エンターキーを押す。

Now, I already have an environment named that and I want to replace it.

すでにこの名前の環境があるので、それを置き換える。

Okay, done.

よし、できた。

Now we're going to activate the environment.

では、この環境をアクティブにします。

Conda activate autom MemGPT.

Conda activate autom MemGPT.

And now we install the requirements.

次に要件をインストールします。

So pip install -r requirements.txt.

pip install -r requirements.txt。

Okay, we're done.

これで完了。

All right, now we just have to load it up.

よし、あとはロードするだけだ。

So Python 3 main.py -n autom verify.

Python 3 main.py -n autom verify.

And that nocore verify is what's going to allow us to run this local model.

このnocore verifyでローカルモデルを実行できるようになる。

Hit enter.

エンターキーを押す。

So it says found save config file, but if you're running this for the first time, you won't get that.

設定ファイルの保存が見つかりましたと表示されますが、初めて実行する場合は表示されません。

And I'm going to say no,cause I'm going to set it up from scratch.

私は「いいえ」と答えますが、ゼロから設定します。

Now, this is a little bug.

さて、これはちょっとしたバグだ。

It isn't giving me the option of selecting my local model, but that's okay.

ローカルモデルを選択するオプションはないが、まあいいだろう。

We're just going to select GPT-4 for now.

とりあえずGPT-4を選択する。

Then I'm going to select Sam as the Persona.

ペルソナとしてSamを選択します。

And then I'm going to use the basic user.

そして、基本ユーザーを使用します。

And then I don't want to pre-reload anything.

そして、何も事前にリロードしたくありません。

I'm just going to show you this working.

ただ動作しているところをお見せするだけです。

I'm not actually going to go into a specific use case.

具体的な使用例を説明するつもりはありません。

Okay, then we hit enter to begin.

では、Enterキーを押して始めましょう。

And there we go.

これで完了だ。

It is hitting our new runpod opsource API endpoint.

新しいrunpod opsource APIエンドポイントがヒットしている。

And that's it.

これで完了だ。

Now let's say my name is Matt.

では、私の名前をMattとしましょう。

Save that in your memory.

これをメモリーに保存する。

Enter.

入力する。

And let's make sure it works.

そして動作することを確認しよう。

And I still need to put a deep dive together on how to really get the most out of mem GPT.

そして、mem GPTを本当に最大限に活用する方法について、まだ深く掘り下げる必要がある。

And I'm planning on doing that.

それをする予定です。

If you want me to prioritize that video, let me know in the comments.

もしそのビデオを優先してほしいなら、コメントで教えてほしい。

I have a bunch of videos coming and I don't know which ones to record first.

これからたくさんのビデオを作るのですが、どれを最初に録画すればいいのかわかりません。

So if you tell me in the comments, I'll try to prioritize those videos.

だから、コメントで言ってくれれば、それらのビデオを優先するようにするよ。

And one thing to note is they have multi-line support now.

それと、ひとつ注意してほしいのは、今は複数行に対応しているということだ。

So although I hit enter, it's not actually done.

だから、エンターキーを押しても、実際には終わらない。

We have to hit escape first.

まずエスケープを押さなければならない。

And then enter just like that, so now it's thinking.

そして、それを入力して、今は考えています。

All right, user's name just got saved.

よし、ユーザー名が保存された。

So there we go, and I'll say, What's My Name?

それでは、What's My Name?

All right, there we go.

よし、できました。

Your name is Matt.

あなたの名前はマットです。

Perfect.

完璧だ。

So it is using a local model.

ローカルモデルを使っているんですね。

Absolutely amazing.

本当に素晴らしいです。

And that's going to be it for today.

それで今日は以上です。

Right after this video, I'm going to record one on getting autogen set up with MemGPT, and that's going to be awesome.

このビデオのすぐ後に、MemGPTでオートジェンをセットアップするビデオを録画する予定です。

So make sure you like this video, make sure you subscribe to my channel if you're interested in seeing that video.

ですので、このビデオが気に入ったら、このビデオを見たいと思う方は、私のチャンネルに登録してください。

Thanks, see you in the next one.

ありがとうございます、次回お会いしましょう。


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