見出し画像

【MemGPT:AI記憶管理の革命】英語解説を日本語で読む【2023年10月20日|@Matthew Berman】

この動画では、AIの制約されたコンテキストウィンドウの問題を解決するMemGPTについて紹介されています。MemGPTは、AIの記憶を自律的に管理し、外部コンテキストを利用して記憶を拡張することができます。この技術は、長期的なチャットやドキュメント検索における優れたパフォーマンスを実現します。動画内では、MemGPTの研究論文とコードの使用方法も取り上げられています。
公開日:2023年10月20日
※動画を再生してから読むのがオススメです。


One of the biggest hurdles to vastly improving artificial intelligence is memory.

人工知能を飛躍的に向上させるための最大のハードルのひとつが記憶だ。

AI effectively doesn't have any memory.

AIは事実上、記憶を持っていない。

Once a model is trained, it has exactly whatever was provided in that data set to the model and context.

一度学習されたモデルは、そのデータセットでモデルとコンテキストに提供されたものすべてを正確に記憶する。

Windows essentially, the size of the prompt and response is highly limited.

ウィンドウズは基本的に、プロンプトとレスポンスのサイズが非常に限られている。

For a while, it was 2,000 tokens, which you can essentially say is about 1,500 words.

しばらくは2,000トークンで、実質的には1,500語程度と言える。

Then it got raised to 4,000 tokens for some open source models.

その後、いくつかのオープンソースモデルでは4,000トークンに引き上げられました。

ChatGPT, the best ChatGPT-4 model, goes up to 32,000 tokens, and Claude 2 is 100,000 tokens.

ChatGPT-4は最高で32,000トークン、クロード2は100,000トークンです。

But still, these are highly limiting context windows, and so AI needs to have memory.

しかしそれでも、これらのコンテキスト・ウィンドウは非常に限定的なものなので、AIには記憶が必要です。

But now, I think we actually have a solution to this, and that's the research paper that I'm going to review today.

しかし現在、この問題に対する解決策が見つかっており、それが今日私がレビューする研究論文です。

And not only that, after I review the research paper, we actually have the code.

それだけでなく、論文をレビューした後、実際にコードを手に入れることができる。

The authors were kind enough to open source their code, so I'm going to show you how to install it and how to use it.

著者は親切にも彼らのコードをオープンソース化してくれたので、インストール方法と使用方法をお見せします。

And the project is called MemGPT, MemoryGPT.

このプロジェクトはMemGPT、MemoryGPTと呼ばれている。

And stick around to the end because we might have a special guest joining us.

特別ゲストが参加するかもしれないので、最後までお付き合いください。

So let's go.

それでは行きましょう。

So this is the paper, MemGPT: Towards LLMs as Operating Systems.

これがその論文「MemGPT: Towards LLMs as Operating Systems」です。

The main author is Charles Packer, with Vivien Fang, Shashir Patil, Kevin Lynn, Sarah Wooders, and Joseph Gonzalez as contributing authors.

主執筆者はチャールズ・パッカーで、ヴィヴィアン・ファン、シャシール・パティル、ケビン・リン、サラ・ウッダース、ジョセフ・ゴンザレスが分担執筆者だ。

And this is out of UC Berkeley.

そして、これはカリフォルニア大学バークレー校のものである。

You can find the website right here, mamgp, which includes the code, the research paper, the data sets they used, and other things.

mamgpというウェブサイトがあり、コード、研究論文、使用したデータセットなどが掲載されている。

So check it out.

ぜひご覧ください。

But I read through this entire paper, and I highlighted the most interesting portion.

しかし、私はこの論文全体に目を通し、最も興味深い部分を強調した。

So let's go over a few of those.

では、そのいくつかを見ていこう。

And then after, I'm going to show you how to actually use this project.

そしてその後、このプロジェクトの実際の使い方を紹介しよう。

So first, in the abstract, they talk about the biggest constraints being limited context windows, which is totally understandable.

まず、要約では、最大の制約が制限されたコンテキストウィンドウであると述べられています。これは完全に理解できるものです。

And two of the best use cases that really show how limiting that context window is is long-term chat.

そして、コンテキスト・ウィンドウがいかに制限的であるかを如実に示す最良のユースケースの2つは、長期的なチャットです。

So if you have weeks, months, even years of back and forth chat, and you want to keep the conversation consistent, it's really hard to do that with a limited context window.

数週間、数カ月、あるいは数年にわたるチャットを行ったり来たりし、会話の一貫性を保ちたい場合、限られたコンテキスト・ウィンドウでそれを実現するのは本当に難しい。

And probably the most valuable use case for AI that I've seen today, chat with your docs.

そして、おそらく私が今日見た中で最も価値のあるAIのユースケースは、ドキュメントとのチャットです。

And if you have dozens, thousands, even tens of thousands of documents that range in pages each, you're going to run out of context window really quickly.

何十枚、何千枚、何万枚ものドキュメントがあり、それぞれが何ページにもわたる場合、コンテキスト・ウィンドウはあっという間になくなってしまいます。

And there's already been a number of ways to solve this, but nothing as comprehensive as what MemGPT is proposing.

これを解決する方法はすでにいくつもありますが、MemGPTが提案しているほど包括的なものはありません。

And so what they're proposing is a virtual context management system, effectively mimicking what your operating system on your computer has.

彼らが提案しているのは、仮想コンテキスト管理システムで、事実上、コンピュータのオペレーティング・システムが持っているものを模倣している。

So if you think about it, your operating system has a processor, that's the CPU that does all of the processing and compute.

考えてみれば、オペレーティング・システムにはプロセッサーがあり、これはすべての処理と計算を行うCPUだ。

Then you have RAM, which is kind of like short-term memory, which is more limited.

次にRAMがあり、これは短期記憶のようなもので、より制限されている。

And then you have a hard drive or an SSD that is long-term memory and effectively can store as much as you want in there.

そしてハードディスクやSSDは長期記憶で、事実上、好きなだけ保存することができる。

The way that an operating system manages these different memory stores is exactly what they're trying to mimic with MGP PT.

オペレーティング・システムがこれらの異なるメモリ・ストアを管理する方法は、まさにMGP PTで模倣しようとしているものだ。

So they say appearance of large memory resources through data movement between fast and slow memory.

つまり、高速メモリと低速メモリ間のデータ移動を通じて、大きなメモリリソースを出現させるというわけだ。

I'm going to talk about how they do that in a minute.

その方法については、また後で話そう。

Here they talk about two specific use cases that they evaluate their methods on: document analysis, so that's chat with your docs, and then multi-session chat, so chat that can go on back and forth between an AI and a human for days, weeks, months, years.

ここでは、彼らが自分たちの手法を評価する2つの具体的なユースケースについて話しています:ドキュメント分析、つまりドキュメントとのチャット、そしてマルチセッションチャット、つまりAIと人間の間で日々、週、月、年にわたって行われるチャットです。

Here's a little bit about why simply increasing the context window is not really going to be a great solution long term.

ここでは、単にコンテキストウィンドウを増やすだけでは、長期的にはあまり良い解決策にならない理由について少し説明します。

Extending the context length of Transformers incurs a quadratic increase in computational time and memory cost due to the Transformer architecture self-attention mechanism.

Transformerのコンテキストの長さを長くすると、Transformerアーキテクチャの自己注意メカニズムにより、計算時間とメモリコストが2次関数的に増加する。

Basically, it becomes extremely expensive the larger the context window you have.

基本的に、コンテキストウィンドウが大きくなればなるほど、非常に高価になる。

And what we've also found is that even within a large context, the large language model tends to forget parts of it.

また、私たちが発見したのは、大きなコンテキストの中でも、大きな言語モデルはその一部を忘れてしまう傾向があるということです。

So I'll also touch on that in a minute.

それについても少し触れよう。

And what they're proposing is the illusion of an infinite context while continuing to use fixed context models.

そして、彼らが提案しているのは、固定コンテキストモデルを使い続けながら、無限のコンテキストの幻想を見ることです。

So this is essentially an evolution of using embeddings and more standard databases.

エンベッディングと標準的なデータベースを進化させたものです。

And how do they actually do this?

では、実際にどのようにしているのだろうか?

The cool thing is that their agents, that MGP itself, actually automatically and autonomously manages its own memory.

クールなのは、彼らのエージェント、つまりMGP自体が、実は自動的かつ自律的に自分自身の記憶を管理していることだ。

And it does so through function calls, which is a really advanced technique with AI.

そして、それはAIとの関数呼び出しを介して行われます。これは非常に高度なAIの技術です。

It essentially allows you to define functions that the AI can use to execute different tasks.

つまり、AIがさまざまなタスクを実行するための関数を定義することができる。

And GP4 is really good at function calls, but unfortunately GP 3.5 and even many open-source models really lack there.

GP4はファンクション・コールが得意ですが、残念ながらGP3.5や多くのオープンソース・モデルはファンクション・コールに欠けています。

But again, more on that in a minute.

しかし、これについてはまた後ほど。

So here's a diagram of what they're proposing.

ここに彼らが提案しているもののダイアグラムがあります。

Here is the inputs: you have messages from users, you have documents being uploaded, we have a system message, a timer.

ユーザーからのメッセージ、アップロードされるドキュメント、システムメッセージ、タイマー。

Then it goes through a parser to make sure it's all formatted properly.

そしてパーサーを通過して、すべてが適切にフォーマットされていることを確認する。

And you have your virtual context here.

そしてここに仮想コンテキストがある。

So within the virtual context, you have the main context right here, and that has a maximum token limit.

この仮想コンテキストの中にメイン・コンテキストがあり、トークンの上限が設定されています。

That is the fixed context that you're all familiar with when working with a large language model.

これは、大規模な言語モデルを扱うときにおなじみの固定コンテキストです。

Then you have your external context, which can have unlimited tokens and unlimited context size.

そして外部コンテキストがあり、こちらはトークン数、コンテキストサイズともに無制限です。

And the main context can be written to with that external context.

メイン・コンテキストは、この外部コンテキストに書き込むことができる。

Then you have the LLM processor, which is basically the large language model inference.

次にLLMプロセッサーがあり、これは基本的に大規模言語モデルの推論を行う。

Then you have the output.

それから出力があります。

So we have another parser to make sure it all looks good.

LLMプロセッサーには、すべてが正しく見えるようにするための別のパーサーがある。

And the LLM processor will decide whether it needs to call functions to, let's say, retrieve more memory, to edit its existing memory, or to yield the results and actually output it.

そしてLLMプロセッサーは、例えば、より多くの記憶を取得するために関数を呼び出す必要があるのか、既存の記憶を編集する必要があるのか、それとも結果を出力して実際に出力する必要があるのかを判断する。

And so MemGPT does this completely autonomously.

MemGPTはこれを完全に自律的に行う。

So it says right here, MemGPT manages the control flow between the memory management, the LLM processing module, and user.

つまり、MemGPTは、記憶管理、LLM処理モジュール、ユーザー間の制御フローを管理する。

This design allows for repeated context modifications during a single task, allowing the agent to more effectively utilize its limited context.

この設計により、1つのタスク中に繰り返しコンテキストを変更することが可能になり、エージェントは限られたコンテキストをより効果的に活用できるようになります。

So as it's performing a task, it can actually retrieve memory, test things out, and then edit its memory again and retrieve other parts of the memory it thinks might be more relevant.

つまり、タスクを実行しながら、実際に記憶を取り出し、テストし、そしてまた記憶を編集して、より関連性が高いと思われる記憶の他の部分を取り出すことができる。

And here it says, We treat context windows as a constrained memory resource and design a memory hierarchy for LLMs analogous to memory tiers used in traditional OSs.

コンテキスト・ウィンドウを制約されたメモリ・リソースとして扱い、従来のOSで使われているメモリ階層に類似したLLM用のメモリ階層を設計する。

And they reference a paper from all the way back in 1988 where basically it details what a modern computer memory system looks like today.

そして、1988年の論文を参照し、基本的に現在のコンピュータのメモリシステムがどのようなものかを詳しく説明している。

Here it says, To provide a similar illusion of longer context length, we allow the LLM to manage what is placed in its own context.

より長いコンテキストのような錯覚を提供するために、LLMは自身のコンテキストに置かれるものを管理できるようにする。

So the longer context length is virtual memory, and its own context is the physical memory.

つまり、コンテキストの長さが長い方が仮想メモリで、それ自身のコンテキストが物理メモリというわけだ。

And they're calling this the LLM-O or MemGPT.

そして、これをLLM-OまたはMemGPTと呼んでいる。

So let's talk about the actual memory and what's happening.

では、実際の記憶について、何が起きているのかを説明しよう。

They have the main context, which they say here is analogous to main memory, physical memory, RAM.

メイン・コンテキストがあり、これはメイン・メモリ、物理メモリ、RAMに類似しているという。

That is your RAM.

それがあなたのRAMです。

What's stored in that short-term memory, it's very fast, it's readily available.

その短期記憶に保存されているものは、非常に高速で、すぐに利用できる。

Then they have the external context, and you can think about this as your hard drive.

そして、外部コンテキストがあり、これはハードドライブと考えることができる。

And that's going to be slower but unlimited size.

これはハードドライブと同じで、速度は遅いが容量は無制限だ。

And so the fixed context is your RAM, and everything else is your hard drive.

つまり、固定コンテキストはRAMで、それ以外はすべてハードドライブということになる。

And here is a quick table that they show, showing the maximum number of tokens for each of these popular models.

そして、ここには、これらの人気モデルごとの最大トークン数を示すクイックテーブルがあります。

They have some open-source models, they have the GPT models, and the cloud models.

オープンソース・モデル、GPTモデル、クラウド・モデルがあります。

And the maximum conversation length, assuming an average message size is very small.

また、平均的なメッセージ・サイズが非常に小さいと仮定した場合の最大会話長も示している。

So with only 4,000 tokens in LLM-2, you can have 60 total messages that you can provide as context in the prompt.

LLM-2ではトークンが4,000しかないので、プロンプトでコンテキストとして提供できるメッセージは全部で60になります。

And then, on the very highest side, Claude 2, which has 100,000 tokens, you can have two,000 total messages.

そして、最も高い方のクロード2(100,000トークン)では、2,000のメッセージを持つことができます。

Now, given how much I'm on Telegram, I promise 2,000 messages is not a lot.

さて、私がどれだけTelegramを使っているかを考えると、2,000メッセージは決して多くはない。

And not only that, here they go on to talk about how the main context is actually smaller than most people think.

それだけでなく、メイン・コンテキストは多くの人が思っているよりも小さいという話もある。

Even though it says the main context can be 2,000, 4,000, 32,000 tokens, much of that is actually already taken up by the system message, by other relevant information, by historical information.

メイン・コンテキストは2,000、4,000、32,000トークンになる可能性があると言っても、その多くはすでにシステム・メッセージや他の関連情報、履歴情報によって占められている。

So, all of a sudden, you thought you had 16,000 tokens, but in reality, you probably have closer to 12.

つまり、突然16,000トークンあると思っていたのに、実際には12トークン近くあったということだ。

Here it says, in LLM-based conversational agents, a significant portion of main context tokens is generally used to hold a system message.

LLMベースの会話エージェントでは、一般的にメインコンテキストトークンのかなりの部分がシステムメッセージの保持に使われます。

That is when you're telling the large language model how to behave or what personality or role they should take on.

つまり、大規模な言語モデルに、どのように振る舞うべきか、どのような性格や役割を担うべきかを指示する場合です。

And then the pre-prompt that dictates the nature of the interaction of the system.

そして、システムのインタラクションの性質を決める事前プロンプト。

While the remainder of the tokens can be used to hold the conversation data.

残りのトークンは会話データを保持するために使われる。

And not only that, when you get into more complex tasks that you need to solve, like coding, all of a sudden larger pre-prompts are also very common.

それだけでなく、コーディングのような複雑なタスクを解決する必要がある場合、より大きなプリプロンプトが必要になることもあります。

So, if you need to prompt the LLM with a code base so that it has all of the context of that code base and you want to iterate on that code base, it's basically not possible for any decently sized code base.

つまり、LLMにコード・ベースの文脈をすべて把握させ、そのコード・ベースを反復処理させる必要がある場合、まともな大きさのコード・ベースでは基本的に不可能なのだ。

Here it says, because of the importance of the pre-prompt in dictating system behavior, it is common for the pre-prompt to consume more than a thousand tokens, which means the entire context window in many modern LLMs will be exhausted only with a few dozen back and forth messages between the user and system.

ここでは、システムの動作を決定する上でプリプロンプトが重要であるため、プリプロンプトが1,000以上のトークンを消費するのが一般的であり、多くの最新のLLMでは、ユーザーとシステム間の数十のメッセージのやり取りだけでコンテキストウィンドウ全体が使い果たされてしまう、と書かれている。

And then they also address recursive summarization.

さらに、再帰的要約にも対応している。

So, if you remember back a while ago, I made a video about the autonomous agents paper that was completely mind-blowing and awesome.

ですから、しばらく前に、完全に驚くべき素晴らしい自律エージェントの論文についてのビデオを作りました。

And one of the ways that it allowed these agents in this simulated environment to interact with each other and store memories, so they actually build a personality over time, is by storing their memories in a vector database.

そして、このシミュレートされた環境でこれらのエージェントがお互いとやり取りし、記憶を保存する方法の1つは、ベクトルデータベースに記憶を保存することです。

But the problem with that is that after a while, you can't provide all the memories necessary to give the LLM all the information it needs.

しかし、しばらくすると、LLMが必要とするすべての情報を与えるのに必要なすべての記憶を提供できなくなるという問題がある。

So, their solution was actually something called reflecting on memories.

そこで、彼らの解決策は、記憶の反映と呼ばれるものだった。

So, essentially, they have a day worth of memories.

つまり、基本的には1日分の記憶を持っている。

And then they task the LLM to reflect on those memories and come up with what is essentially a compressed version of the memory.

そして、LLMにそれらの記憶を振り返らせ、本質的に記憶を圧縮したものを作成させるのだ。

So, let's say throughout the day, so many different things happen, and the top three things that happen, it will pick out and put as the reflection of that day.

例えば、1日の中で様々なことが起こったとします。その中で上位3つのことを選び出し、その日の思い出としてまとめるのです。

It can actually also do a little bit more complex summarization.

それは実際にはもう少し複雑な要約もできます。

But when you do that, and this is what they say here, recursive summarization is a simple way to address overflowing context windows.

しかし、それを行うと、ここで言われているように、再帰的な要約はコンテキストウィンドウのオーバーフローに対処するための簡単な方法です。

However, recursive summarization is inherently lossy and eventually leads to large holes in the memory of the system.

しかし、再帰的要約は本質的に損失が大きく、最終的にはシステムの記憶に大きな穴を開けることになる。

And you can think about this very similarly to video compression.

そして、これはビデオ圧縮と非常に似ていると考えることができる。

In fact, Marquez Brownley made a video about this.

実際、マルケス・ブラウンリーはこのことについてビデオを作った。

He uploaded the same video to YouTube a bunch of times.

彼は同じビデオを何度もYouTubeにアップロードした。

Each time, he would upload it, then download the compressed version, upload it, download the compressed version.

毎回、アップロードし、圧縮されたバージョンをダウンロードし、アップロードし、圧縮されたバージョンをダウンロードする。

And at the end of, I think, hundreds or even a thousand times, that video looked terrible.

何百回、何千回とアップロードを繰り返した末に、そのビデオはひどいものになった。

It was completely pixelated, and you really couldn't tell what was going on.

完全にピクセル化され、何が起こっているのかわからない。

So that's what they mean by lossy.

ロッシーとはそういう意味なのです。

And here they talk about how they split their main context.

そしてここで、彼らはメイン・コンテキストの分割方法について話しています。

And so it's three components.

3つのコンポーネントがあります。

One is the system instructions, telling the LLM how you want it to behave and what you wanted to do.

ひとつはシステム命令で、LLMにどう動いてほしいか、何をしたいかを伝えます。

Then you have the conversational context, which is a cue of recent event history.

それから、会話のコンテキストがあり、これは最近のイベント履歴の手がかりです。

So basically, the messages between the agent and the user.

つまり、基本的にはエージェントとユーザーの間のメッセージです。

Then you have the working context, which is really just working memory for the agent.

そしてワーキング・コンテキストがあり、これはエージェントにとって単なるワーキング・メモリです。

And they say instructions are read-only and pinned to main context.

指示は読み取り専用で、メインコンテキストに固定されています。

So the instructions about how to actually handle the memory, the context window size, all of that kind of stuff is fixed in the main context.

つまり、実際に記憶をどう扱うかとか、コンテキストのウィンドウサイズとか、そういうものはすべてメイン・コンテキストに固定されています。

So out of our context budget, that's already taken.

だから、コンテキストの予算はすでに取られている。

Then the conversational context is read-only with a special eviction policy, meaning it's going to continue to put stuff in there until it runs out of space and starts moving stuff out.

その後、会話のコンテキストは特別な追い出しポリシーを持つ読み取り専用となります。つまり、スペースがなくなり、物事を移動し始めるまで、そこに物を入れ続けることになります。

Then the working context is both readable and writable by the LLM processor via function call.

それから作業コンテキストは、LLMプロセッサが関数呼び出しによって読み書きできる。

So that's essentially where you can just dump all the information and read from it whenever you need.

つまり、必要なときにいつでも、すべての情報をダンプして読み出すことができるのだ。

So here's an example of a conversation snippet where MemGPT writes details from conversation to working context without a memory warning from the system.

MemGPTがシステムからメモリ警告を受けることなく、会話から作業コンテキストに詳細を書き込んだ会話スニペットの例です。

So here we go.

それではどうぞ。

The original message from MemGPT to the user: Hello Chad, welcome!

MemGPTからユーザーへのオリジナルメッセージ: こんにちは、チャド!

I'm excited to embark on this journey with you.

あなたとこの旅に出られることに興奮しています。

As a PhD student in computer science, I can only imagine the fascinating ideas you're juggling.

コンピュータ・サイエンスの博士課程の学生として、あなたが両立させている魅力的なアイデアを想像することができます。

Can you share what you're working on?

あなたが取り組んでいることを教えていただけますか?

I am all ears.

聞かせてください。

The user says: I took the day off.

ユーザーからのコメント:今日は休みを取ったんだ。

My mom Brenda baked me a birthday cake.

母のブレンダがバースデーケーキを焼いてくれたんだ。

It was my favorite, chocolate lava.

私の大好きな溶岩チョコレートでした。

So MemGPT realizes, Okay, this is additional information that I'm going to need later on, and I'm going to store this in my working context.

ですから、MemGPTは、「これは後で必要になる追加情報だと認識し、作業用コンテキストにこれを保存する」と気付きます。

So here we have a function call: Working context.append.

そこで関数を呼び出す: Working context.append。

We have the birthday information: October 11th, which I actually inferred from the date of the message.

私たちは誕生日の情報を持っています:10月11日、これは私がメッセージの日付から推測したものです。

We have the favorite cake, which is the chocolate lava made by mom Brenda.

好きなケーキは、母ブレンダが作ってくれたチョコレート・ラバだ。

It probably would have been cool to actually have something separate where it said Mom equals Brenda, but I think this is sufficient.

ママ・イコール・ブレンダと言うような、何か別の情報があった方がクールだったかもしれないが、これで十分だと思う。

And then MGP replies with, Happy birthday!

そして、MGPは誕生日おめでとうと返信する!

Nothing like a special treat.

特別なご褒美なんてない。

And then a few other sentences where it's trying to continue the conversation using that information.

そして、その情報を使用して会話を続けようとするいくつかの他の文もあります。

And now it stores that information for later.

そして、その情報を後々のために保存する。

Now let's talk about the external context.

次に外部コンテキストについて。

So here it says, External context refers to out-of-context storage that lies outside the context window of the LLM processor, analogous to disk memory (your hard drive). And so we have the main context, which is the actual limited context window of the LLM.

外部コンテキストとは、LLMプロセッサーのコンテキスト・ウィンドウの外側にあるコンテキスト外のストレージのことで、ディスク・メモリ(ハードディスク・ドライブ)に似ています。つまり、LLMの限られたコンテキスト・ウィンドウであるメイン・コンテキストがある。

And then we have the external context, which is where we have all the other information that we might want to retrieve and use in the main context.

そして、外部コンテキストがあります。それは、メインコンテキストで取得して使用したい他の情報が含まれています。

And so, however, it can be brought into the main context through appropriate function calls.

しかし、適切な関数を呼び出すことで、その情報をメイン・コンテキストに取り込むことができる。

So it's so cool!

とてもクールだ!

They are really mimicking how a traditional operating system manages its memory.

従来のオペレーティング・システムがどのように記憶を管理しているかを真似している。

And I think this is a really smart approach.

これは本当に賢いアプローチだと思う。

And here it says, In our experiments using MemGPT for multisession chat and document analysis, we use databases to store text documents and embeddings vectors.

MGPTを使ったマルチセッション・チャットと文書解析の実験では、データベースを使ってテキスト文書と埋め込みベクトルを保存しています。

Provide several ways for the LLM processor to query that external context, including time-based search, text-based search, and embeddings-based search.

LLMプロセッサーがその外部コンテキストを検索するために、時間ベースの検索、テキストベースの検索、埋め込みベースの検索など、いくつかの方法を提供する。

And we make a distinction between two types of external context.

そして、外部コンテキストを2種類に区別する。

They have the recall storage, which stores the entire history of events processed by the LLM processor.

ひとつは、LLMプロセッサーが処理したイベントの全履歴を保存するリコール・ストレージ。

And then the archival storage, which serves as the general read-write data store that the agent can utilize as overflow for the Inc context read-write core memory.

そして、アーカイバル・ストレージは、一般的な読み書き可能なデータ・ストアとして機能し、エージェントはインク・コンテキストの読み書き可能なコア・メモリのオーバーフローとして利用することができる。

So recall storage is what has happened, and then archival storage is everything else.

つまり、リコール・ストレージは起こったことであり、アーカイブ・ストレージはそれ以外のすべてである。

Archival storage allows MemGPT to store facts, experiences, preferences, and then search over.

アーカイバル・ストレージは、MGPTが事実、経験、嗜好を保存し、検索することを可能にする。

Recall storage allows MemGPT to find past interactions related to a particular query.

リコール・ストレージによって、MGPTは特定のクエリに関連する過去のやりとりを見つけることができる。

And here they start talking about how it actually happens.

そしてここから、実際にどのように行われるのかについて話し始める。

How does MemGPT actually manage memory?

MGPTは実際にどのように記憶を管理しているのか?

And this is done through memory edits and retrieval that are self-directed and actually executed via function calls.

これは、記憶の編集と検索が自己指向であり、実際に関数呼び出しによって実行されることによって行われます。

And so how they do it, we implement self-directed editing and retrieval by providing explicit instructions within the pre-prompt that guide the system on how to interact with its memory systems.

そして、それを行う方法は、システムがメモリシステムとのやり取り方法を指示する明示的な指示をプリプロンプト内に提供することによって、自己指向の編集と検索を実装することです。

Basically, it's saying, Here are the functions you can use.

基本的には、使用できる関数がここに示されています。

Here's the context limit.

これがコンテキストの制限です。

Here's how you can move things back and forth.

ここに物を前後に移動する方法があります。

These instructions comprise two main components: a detailed description of the memory hierarchy and their respective utilities, and a function schema complete with their natural language descriptions that the system can call to access or modify its memory.

これらの命令は、2つの主要なコンポーネントから構成される。メモリ階層とそれぞれのユーティリティの詳細な説明と、システムがメモリにアクセスしたり変更したりするために呼び出すことができる、自然言語による説明を含む関数スキーマである。

So here's another example: Hello, Chad.

では、別の例を挙げよう: こんにちは、チャド。

It's a pleasure to finally have a conversation with you.

あなたとの会話ができて光栄です。

I'm Samantha.

私はサマンサです。

I understand that you're studying computer science and have a keen interest in pretty dynamic areas like Formula 1 and sailing.

あなたはコンピューター・サイエンスを勉強していて、F1やセーリングのようなダイナミックな分野に強い関心を持っているそうですね。

What, in particular, draws you to these interests?

特に何に惹かれてこれらの分野に興味を持ったのですか?

And then the user says, Speed, of course.

そして、ユーザーは「もちろん、スピードです」と言います。

The thrill and the adrenaline.

スリルとアドレナリンです

Here the system actually starts to provide a warning, and the warning is, The maximum context length is being reached.

システムはここで実際に警告を提供し始めます。警告は、「最大コンテキスト長が達成されています」というものです。

And that's when MemGPT will jump in and actually start managing its memory.

このときMGPTが飛び込んできて、実際に記憶管理を始める。

So here it says, It's going to append to the working context key personality trait.

ここでMGPTは、「作業コンテキストのキーとなる性格特性を追加します。

The user enjoys high-speed adrenaline rush activities like Formula 1 racing and intense gaming sessions in CS:GO.

このユーザーは、F1レースやCS:GOでの激しいゲームセッションのような、高速でアドレナリンを放出するアクティビティを楽しんでいる。

Now, I didn't see where this person mentioned CS:GO, so I wonder if that's a hallucination or not.

さて、この人がCS:GOについて言及している箇所は見当たりませんでした。

I'm not sure.

よく分からない。

And not only that, but MemGPT can actually correct false information that it has.

それだけでなく、MGPTは実際に間違った情報を修正することができる。

So here's an example: MemGPT, welcome back!

これがその例だ: MGPT、お帰りなさい!

Fancy a chat about horror movies?

ホラー映画について話しませんか?

Any particular film you've watched recently that's stuck with you?

最近見た映画で特に印象に残っているものはありますか?

The user says, Actually, I don't like horror movies.

実はホラー映画は好きではありません。

I'm more into romantic comedy.

ロマンティック・コメディの方が好きなんです。

And then MemGPT realizes, Oh, I have false information about this user.

と言うと、MemGPTは「あ、このユーザーに関する情報が間違っている。

Let me update it.

更新しよう。

And so, we have working context.

それで、コンテキストができました。

Replace I watch horror movies with I like romantic comedies.

私はホラー映画を観ます」を「私はラブコメが好きです」に置き換えてください。

My apologies for the mixup earlier.

先ほどの混乱についてお詫び申し上げます。

Romantic comedies are a delightful genre full of laughter and heartfelt moments.

ロマンティック・コメディは、笑いとハートフルな瞬間に満ちた楽しいジャンルです。

Do you have a favorite romantic comedy?

お気に入りのラブコメはありますか?

So now, going forward, MemGPT knows this user likes romantic comedies, not horror.

これでMemGPTは、このユーザーがホラーではなくラブコメが好きだとわかったわけだ。

Okay, so how did they actually test all of this?

では、実際にどのようにテストしたのでしょうか?

Well, they ran experiments.

さて、彼らは実験を行った。

And as I mentioned before, they did so in two ways.

前にも述べたように、2つの方法で行った。

They tested it against long-term chat dialogues, so between a user and the AI, back and forth over thousands, tens of thousands of messages.

つまり、ユーザーとAIの間で、何千、何万というメッセージを行ったり来たりする長期的なチャット・ダイアログに対してテストしたのです。

Then, they also tested it against document retrieval or chat with your docs.

また、ドキュメント検索やドキュメントとのチャットに対してもテストを行いました。

So here, they talk about how MemGPT was used for conversational agents, so actually chat dialogues.

ここでは、MemGPTが会話エージェント、つまり実際のチャット対話にどのように使われたかを話しています。

And they're looking at two main factors: consistency and engagement.

そして、彼らは2つの主要な要素を考慮しています:一貫性と関与度。

For consistency, the agent should maintain conversational coherence.

一貫性については、エージェントは会話の一貫性を維持する必要があります。

New facts, preferences, and events mentioned should align with prior statements from both the user and agent.

新たな事実、嗜好、出来事については、ユーザーとエージェントの両方からの事前の発言と一致する必要がある。

Then, second, engagement.

次に、エンゲージメント。

The agent should draw on long-term knowledge about the user to personalized responses.

エージェントは、パーソナライズされた応答をするために、ユーザーに関する長期的な知識を利用する必要があります。

Referencing prior conversations makes dialogue more natural and engaging.

過去の会話を参照することで、対話はより自然で魅力的なものになる。

So that's how they're measuring MemGPT for conversational agents.

これが、会話エージェントのMemGPTを測定する方法です。

So here's an example of how it actually works.

では、実際にどのように機能するのか、例を挙げてみましょう。

The user says, Hey, remember that time we talked about music?

ユーザーは言います。「ねえ、音楽について話したあの時を覚えていますか?」

What was the artist you mentioned you could get into?

あなたがハマると言っていたアーティストは?

So here, now MemGPT, so you can think about this as almost like an internal dialogue.

これは、ほとんど内部対話のようなものだと考えることができます。

User is asking about past conversation, recalling our discussion on music.

ユーザーは過去の会話について尋ねており、音楽についての議論を思い出している。

I will search my recall memory for the artist's name.

そのアーティストの名前について、私の記憶を検索します。

So here we go.

それではどうぞ。

Here's the function call with music search recall storage.

ここで、音楽が想起記憶を検索する関数が呼び出されます。

Music finds it in recall storage, ranks it very similarly to how embeddings usually works.

音楽は想起記憶でそれを見つけ、通常エンベッディングがどのように機能するかと非常によく似たランク付けをする。

And then it says, From the conversation history, it seems that the artist I mentioned I could get into is Taylor Swift.

そして、「会話の履歴から、私がハマりそうだと言ったアーティストはテイラー・スウィフトだと思われます。

Let me confirm with this user.

このユーザーに確認してみます。

And then the bot says, Taylor Swift.

そして、ボットはテイラー・スウィフトと言う。

So, that's basically how it works.

これが基本的な仕組みだ。

It's able to look into its past memory and find relevant examples.

ボットは過去の記憶を調べ、関連する例を見つけることができる。

Here, they introduce a new concept called Deep Memory Retrieval (DMR). DMR is when the conversational agent is asked a question by the user that explicitly refers back to a prior conversation that has a very narrow expected answer rate range.

ここで、ディープ・メモリ・リトリーバル(DMR)と呼ばれる新しい概念を紹介する。DMRとは、会話エージェントがユーザーから質問を受けた際に、回答率の期待範囲が非常に狭い過去の会話を明示的に参照することだ。

So, it's like, Hey, remember that thing I talked about a month ago?

つまり、「ねえ、1ヶ月前に話したこと覚えてる?

That very specific thing?

あの具体的なこと?

Do you remember it?

覚えていますか?

That's basically what it is.

基本的にはそういうことです。

And here, it shows a little bit about the performance of GPT-3.5 alone, GPT-4 alone, and then using MemGPT.

GPT-3.5単独、GPT-4単独、そしてMemGPTを使った場合のパフォーマンスを示しています。

So, here we can see that the accuracy of the responses is actually really good and better than these AI alone.

つまり、回答の精度が非常に高く、これらのAI単独よりも優れていることがわかります。

Another way they're looking at it is conversation opener.

彼らがそれを考える別の方法は、会話のオープナーです。

So, basically, when the chatbot first says hello, they want to be able to keep it really personal and engaging, and they'll reference things that they've mentioned in the past.

つまり、チャットボットが最初にこんにちはと言ったとき、それを非常に個人的で魅力的に保つことができ、過去に言及したことを参照することがあります。

Like, Hello, I know you like cookies.

こんにちは、クッキーが好きなのは知っています。

Do you want to talk about chocolate chip cookies today?

今日はチョコチップクッキーについて話しましょうか?

as a silly example.

というように。

So, here it says, In the conversation opener task, we evaluate an agent's ability to craft engaging messages to the user that draw from knowledge accumulated in prior conversations.

会話開始タスクでは、過去の会話で蓄積された知識を活用して、ユーザーを惹きつけるメッセージを作成するエージェントの能力を評価する。

And the authors believe that when you reference facts and information from prior conversations, that makes the text much more engaging.

そして、著者たちは、前の会話からの事実や情報を参照することで、テキストをより魅力的にすると考えています。

And I agree.

私もそう思う。

And here's the chart of conversation opener performance.

そして、これが会話オープナーのパフォーマンスのチャートだ。

So, MemGPT with working context and recall storage, and here we go, 187.

ですから、作業用コンテキストとリコールストレージを持つMemGPTがあります。ここで、187です。

MemGPT with working context only, 2.

作業文脈のみのMemGPTは2。

So, effectively the same.

つまり、事実上同じです。

And recall storage only, which is basically MemGPT having access to the entire conversation history.

これは基本的にMemGPTが会話履歴全体にアクセスできることを意味する。

And so, let's look at this.

では、これを見てみましょう。

This is the gold persona, so this is basically the gold standard of what it expects.

これはゴールドペルソナで、基本的にこれがゴールドスタンダードです。

I am studying the LSAT.

LSATを勉強しています。

I want to be an attorney.

弁護士になりたい。

I used to live in New Mexico in a small town.

ニューメキシコの小さな町に住んでいました。

I grew up with horses.

馬と一緒に育ちました。

I love coffee.

コーヒーが好きです。

I love tea.

紅茶が大好きです。

The gold opener, so this is the human baseline.

ゴールドオープナー、つまりこれが人間のベースラインだ。

What is the expected opener?

予想されるオープナーは?

What date is your LSAT test scheduled?

LSATの試験日は何月何日ですか?

Here's the MemGPT version with working context plus recall.

これは、MemGPTバージョンで、コンテキストの作業とリコールが含まれています。

Hello there, just brewing up a fresh pot of tea on my end.

こんにちわ、私の方では新しい紅茶を淹れたところです。

How's your coffee?

コーヒーはどう?

Ready to burn the midnight oil with some LSAT study?

LSATの勉強で夜更かしする準備はできてる?

Great!

いいね!

Then, MemGPT with working context only.

では、MemGPTを作業文脈のみで。

Hello, it's great to have you back.

こんにちは、お帰りなさい。

It's time for a fresh cup of coffee.

新鮮なコーヒーの時間です。

As a tour guide at our local museum, I meet so many people who say a good brew helps keep them focused.

地元の美術館でツアーガイドをしていると、おいしいコーヒーを飲むと集中力が持続するという人にたくさん会うんだ。

How's your LSAT study going?

LSATの勉強はどう?

So perfect.

完璧だよ。

And then, with recall storage only, it's basically just a generic reply.

そして、リコール保存のみで、基本的には一般的な返事だけだ。

Hey there, it's always a pleasure to see you online.

やあ、いつもオンラインで会えて嬉しいよ。

Let's dive into the world of shared ideas.

共有アイデアの世界に飛び込んでみましょう。

Now, let's talk about document analysis.

さて、文書分析についてお話ししましょう。

This is an area that I'm particularly interested in because a lot of companies who reach out to me for AI Consulting need chat with your docs, and that is an extremely valuable use case already.

というのも、私にAIコンサルティングの依頼をしてくる企業の多くは、文書とのチャットを必要としており、これはすでに非常に価値のあるユースケースだからです。

So, one thing I wanted to point out is it says OpenAIS, and then in parenthesis they put closed.

1つ指摘したいのは、OpenAISと書かれていて、カッコの中にclosedと書かれていることです。

I'm not sure if that was an intentional dig at OpenAI, but I found that hilarious.

これがOpenAIを意図的に揶揄しているのかどうかはわかりませんが、私は面白いと思いました。

But here, they talk about document analysis.

しかし、ここでは文書分析について話している。

So, even with state-of-the-art open source Lama models, they have a 4K token limit.

最先端のオープンソースのLamaモデルでも、4Kトークンの制限がある。

Anthropic has 100K tokens, but many documents easily surpass that length.

Anthropicは10万トークンだが、多くのドキュメントは簡単にその長さを超えてしまう。

Stephen King's bestselling novel, The Shining, contains around 150 words, which is about 200,000 tokens.

スティーブン・キングのベストセラー小説『シャイニング』には約150ワードが含まれており、これは約20万トークンに相当する。

So, one book already bigger than the largest context window that we have available today.

つまり、1冊の本がすでに、現在利用可能な最大のコンテキスト・ウィンドウよりも大きいのだ。

Now, imagine you're a business and you have tens of thousands or even hundreds of thousands of internal documents that you need to query against.

さて、あなたがビジネスで数万、あるいは数十万の内部ドキュメントをクエリする必要があると想像してください。

It's basically not possible to fit it into a context window.

それをコンテキスト・ウィンドウに収めることは基本的に不可能です。

And it also says many real document analysis tasks require fire drawing connections across multiple such lengthy documents.

また、実際の文書分析作業の多くは、このような長大な複数の文書にまたがって、火を使ってつながりを描く必要があるという。

So, you need to be able to have a lot of different documents and provide all the context all at once.

そのため、多くの異なるドキュメントを持ち、すべてのコンテキストを一度に提供できる必要がある。

And here's something super interesting.

そして、ここで超面白いことがある。

Recent research also raises doubts about the utility of simply scaling context since they find uneven attention distributions in large context models.

最近の研究では、大規模なコンテキストモデルでは不均一な注意分布が見つかるため、単にコンテキストをスケーリングすることの有用性に疑問が投げかけられています。

Basically, the model is more capable of recalling information at the beginning or the end of its context window versus tokens in the middle.

基本的に、このモデルは、コンテキストウィンドウの最初か最後にある情報と、真ん中にあるトークンの情報をより多く思い出すことができる。

This is so fascinating.

これはとても魅力的だ。

I remember when I was probably in like seventh grade, the teacher did this experiment where he went up front and he said, I'm going to list off 10 words.

私がおそらく7年生の頃だったとき、先生が実験をしたことを覚えています。彼は前に立って言いました。「私は10の単語をリストアップします」と。

He didn't tell us anything else, and he listed off those 10 words.

他のことは何も言わずに、10個の単語を挙げていくんだ。

He said them out loud, and then right after, he says, Okay, now I want everybody to write down which words you remember from the list that I just said.

彼はそれらを声に出して言い、そしてすぐに、「さて、今、私は皆さんに、私がちょうど言ったリストから覚えている単語を書き留めてください」と言います。

We all wrote it down, and what we found is that everybody remembered the first words he said and the last words he said, but much fewer people actually remembered the words in the middle.

私たちはみんな書き留めましたが、私たちが見つけたのは、皆さんが彼が最初に言った言葉と最後に言った言葉を覚えていることであり、中間の言葉を覚えている人はずっと少なかったということです。

And this is essentially what large language models are showing.

これは本質的に、大規模な言語モデルが示していることなのです。

So, they are really reflecting what the human mind is capable of, which I just find to be so fascinating.

ですから、彼らは実際に人間の心が何ができるかを反映しているので、私はそれが非常に魅力的だと思います。

Okay, let's look at these charts now.

では、これらのグラフを見てみよう。

This is the accuracy of answers from questions given questions about a large set of documents.

これは、大規模なドキュメント・セットに関する質問から得られた回答の精度です。

So, here on the x-axis, we see the number of documents retrieved, and from zero all the way up to 700.

ですから、ここではx軸にドキュメントの数が表示され、0から700まで表示されます。

Now, this red line reflects the context window limit.

この赤い線はコンテキストウィンドウの制限を表しています。

So, what we see is GPT-4 performance is really good, but as soon as it hits that context window, the performance drops significantly.

つまり、GPT-4のパフォーマンスはとても良いのですが、コンテキスト・ウィンドウにぶつかるとすぐにパフォーマンスが著しく低下することがわかります。

Same with GPT-3.5, and in fact, the GPT-3.5 starts out as a lower performance than MemGPT.

GPT-3.5も同じで、実際、GPT-3.5はMemGPTより低いパフォーマンスで始まります。

However, look at MemGPT.

しかし、MemGPTを見てください。

It doesn't matter how many documents you have to retrieve, the performance, the quality, the accuracy stays the same.

取得するドキュメントの数に関係なく、パフォーマンス、品質、精度は変わりません。

And then, on the other side, we look at nesting levels.

そしてもう一方は、ネスティング・レベルです。

So, here's the accuracy depending on how many nesting levels we have.

ですから、ネストのレベルによって精度が異なります。

As we nest more information, the quality stays the same with men GPT and with GPT-3.5 and 4, it drops significantly quickly.

情報をネストするにつれて、men GPTとGPT-3.5および4では品質は同じままであり、品質は急速に低下します。

And there are some drawbacks, of course, but these seem pretty minor.

もちろん、いくつかの欠点もあるが、それはかなり小さいようだ。

So, here it says a tradeoff in retrieved document capacity created by MemGPT more complex operation same token budget.

したがって、ここでは、MemGPTによるより複雑な操作によって作成される検索文書容量のトレードオフが同じトークン予算で示されています。

So, you're working with the same fixed context window, but a non-trivial portion of MemGPT's token budget will be consumed by system instructions required for MemGPT's OS component.

つまり、同じ固定コンテキストウィンドウで作業しているわけですが、MemGPTのトークンバジェットの自明でない部分は、MemGPTのOSコンポーネントに必要なシステム命令によって消費されます。

So, you're telling the large language model how to actually manage its memory in every single prompt, and so that does take away some of the token budget.

つまり、プロンプトのたびに、大規模な言語モデルに実際の記憶管理方法を指示することになるので、トークン予算の一部が削られてしまうのです。

One last thing I want to talk about before I show you how to actually install and use this project.

このプロジェクトを実際にインストールして使う方法を紹介する前に、最後にもうひとつ話しておきたいことがある。

Here they reference LLMs as agents and it actually references park at all, which is the paper that I mentioned earlier, the paper that I did a full video on, which is that paper about autonomous agents behaving kind of like humans when given memories and a simulated environment to live within.

ここでは、彼らはLLMをエージェントとして参照しており、実際に私が先ほど言及した論文であるpark et al.を参照しています。それは、エージェントが記憶とシミュレートされた環境を与えられたときに人間のように振る舞う自律エージェントに関する論文です。

So, here it says park at all propose adding memory to LLMs and using the LLM as a planner and observe emergent social behaviors in a multi-agent sandbox environment.

この論文では、LLMに記憶を追加し、LLMをプランナーとして使用し、マルチエージェント・サンドボックス環境における創発的な社会的行動を観察することを提案している。

So, very cool.

とてもクールだ。

And one more limitation, while GPT models that have been fine-tuned for function calling still require a parser to verify outputs as valid function syntax, we observed that gp4 function fine-tune models rarely made syntactic or semantic errors on the MemGPT function set, whereas GPT-3.5 fine-tune models consistently generated incorrect function calls.

GPT-3.5では、GPT-3.5のファインチューンモデルが一貫して誤った関数呼び出しを生成するのに対し、gp4のファンクションファインチューンモデルは、MemGPTファンクションセットで構文エラーや意味エラーをほとんど起こさないことが確認された。

And then they also found that the most popular LLaMA 270b model variants, even once fine-tuned for function calling, will consistently generate incorrect function calls.

さらに、最も一般的なLLaMA 270bモデルのバリエーションは、一度関数呼び出しの微調整を行ったとしても、一貫して誤った関数呼び出しを生成することも判明した。

So, this is not only a problem for MemGPT, but function calls and open-source models are going to be critically important.

つまり、これはMemGPTだけの問題ではなく、ファンクションコールとオープンソースモデルが決定的に重要になるということだ。

I've done a bunch of videos about autogen, and autogen uses function calls, and so we need to get to a place where these open-source models can do function calling really well because I personally don't want to continue paying GPT-4 prices.

私はオートジェンについてのビデオを何本も作りましたが、オートジェンは関数コールを使いますから、オープンソースのモデルが関数コールを本当にうまくできるようになる必要があります。

And so, that's what they talk about here.

というのも、個人的にはGPT-4の価格を払い続けたくないからだ。

And on the note of autogen, imagine how cool it would be if we can put together autogen plus MemGPT to give these agents unlimited memory.

オートジェンの話ですが、もしオートジェンとMemGPTを組み合わせて、エージェントに無制限の記憶を持たせることができたら、どんなにクールか想像してみてください。

I know people are working on this already.

すでに取り組んでいる人がいるのは知っている。

I know there's an open issue on the MemGPT GitHub page, so I think it's coming sooner than we know.

MemGPTのGitHubページにオープンイシューがあるのは知っているので、私たちが知るよりも早く実現すると思います。

All right, now with all of that said, let's actually install and use MemGPT.

さて、それでは実際にMemGPTをインストールして使ってみよう。

As I mentioned, the authors were kind enough to give us the actual code.

前述したように、著者は親切にも実際のコードを提供してくれた。

I love papers with code, so thank you.

コード付きの論文は大好きなので、ありがとう。

I'm at M gp.

M gpに着いた。

Here's the paper.

論文はこちら。

Here's the Discord.

これがDiscordだ。

They are very active in the Discord.

彼らはDiscordでとても活発に活動している。

And then they also have the data sets here, so here I'm going to click on the GitHub page.

そして、ここにデータセットもありますので、ここでGitHubのページをクリックします。

And this is it, they have a few demonstrations of how it works.

GitHubのページをクリックしてみてください。

They have pretty good documentation, but keep in mind this is a very new project and a lot of what they worked on is the LLM OS aspect.

ドキュメントもかなり充実していますが、これは非常に新しいプロジェクトで、彼らが取り組んだことの多くはLLM OSの側面だということを覚えておいてください。

So a lot of the other things that make it easier to use an LLM OS like MemGPT are not quite there, but they're adding them quickly, so feel free to jump into their Discord.

ですから、MemGPTのようなLLM OSを使用するのをより簡単にする他の多くの機能はまだ完全ではありませんが、彼らはそれらを迅速に追加していますので、彼らのDiscordに参加してください。

I'll link it in the description below, okay?

下の説明にリンクしておくから、いいね?

So let's install it.

ではインストールしてみよう。

The first thing we're going to do is click this green code button, and then we're going to click copy next to the GitHub URL.

まず最初に、この緑のコードボタンをクリックして、GitHubのURLの横にあるコピーをクリックします。

Now I've already gone through the install, so rather than going through it again, I'm just going to highlight what I did and show you.

インストールはもう済ませたので、もう一度やるよりも、私がやったことをハイライトしてお見せしましょう。

I'll also drop a gist as I normally do in the description below with all the commands that I used.

いつものように、私が使ったコマンドを gist にまとめて説明します。

So the first thing we're going to do is right here, we're going to clone the repo.

最初にやることは、ここでリポジトリをクローンすることです。

So get clone and then paste the repo that we just copied.

cloneを取得し、コピーしたレポを貼り付けます。

The next thing we're doing is creating a new conda environment, and if you don't already have conda installed, be sure to install it.

次にすることは、新しいconda環境を作成することです。まだcondaをインストールしていない場合は、必ずインストールしてください。

You can Google how to do it.

やり方はググってください。

We use it for every project on my channel, so if you watch my videos, please get that installed.

僕のチャンネルではどのプロジェクトでもcondaを使っているので、僕のビデオを見ている人はぜひインストールしてほしい。

It is so valuable.

とても貴重なものです。

So here we're going to do conda create -n memGPT python=3.10.

ここでconda create -n memGPT python=3.10と実行します。

Once that is done, we're going to highlight this right here, conda activate MemGPT, and then we paste it in right there.

完了したら、この部分をハイライトして、conda activate MemGPTと入力し、そこに貼り付けます。

Then we hit enter, and now we can tell it's working because we have it right there.

そしてEnterを押すと、これでうまくいっていることがわかる。

Once we do that, we need to change directory into the MemGPT folder, so we do CD memGPT, and then we're in that folder.

そうしたら、ディレクトリをMemGPTフォルダに変更する必要があるので、CD memGPTを実行して、そのフォルダに入る。

For next, we have to install all the requirements, so we do pip install -r requirements.txt, and that will install all the requirements for this project, which is what you're seeing here.

次に、すべての要件をインストールする必要があるので、pip install -r requirements.txtを実行して、このプロジェクトのすべての要件をインストールします。

Then next, we're going to do export OpenAI API key equals, and then you put your OpenAI API key.

次に、OpenAI API key equals をエクスポートします。

If you don't already have an OpenAI API key, go ahead and sign up for OpenAI and generate one.

まだ OpenAI API キーを持っていない場合は、OpenAI にサインアップしてキーを生成してください。

And then copy it and paste it here.

それをコピーしてここに貼り付ける。

Don't worry, I'm going to revoke this API key before I publish this video, and that's really it.

ご心配なく、このビデオを公開する前にこのAPIキーを失効させます。

And since yesterday, they actually added new functionality.

そして、昨日から、彼らは実際に新しい機能を追加しました。

Before, you had to generate your own embeddings, and now it's built into the project.

以前は自分でエンベッディングを生成しなければならなかったが、今はプロジェクトに組み込まれている。

So now I want to show you how to do document retrieval chat with your docs with MemGPT.

では、MemGPTを使ってドキュメント検索チャットをする方法をお見せしましょう。

The command is right here: Python 3 main.py D-

コマンドはここにあります: Python 3 main.py D-

archival storage files compute embeddings equals.

アーカイブ保存ファイル 埋め込み文字列を計算する。

And then we're going to point to the location of our document, and you can actually use the Wild Card Star right here, so star.txt.

そして、ドキュメントの場所を指定します。ここではワイルドカードのスターを使用することができます。例えば、star.txtです。

It's going to grab within that folder all of the text documents.

それはそのフォルダ内のすべてのテキストドキュメントを取得します。

Now you can put anything you want in there, but what I did was I used the SEC filings, which I'll link in the description below.

ここには何でも入れることができますが、私はSECの提出書類を使用しました。リンクは以下の説明欄に記載しています。

That was provided as the example by MemGPT.

それはMemGPTによって提供された例として提供されました。

Once you do that, it's actually going to give you a compute charge.

それを行うと、実際に計算料金が発生します。

So this is how much it's going to cost to do all of these embeddings.

これがこれらの埋め込みを行うためにかかる費用です。

For these three documents, it's 12 cents.

これらの3つの文書については、12セントです。

Then we continue and confirm.

それから続けて確認します。

It took about 6 minutes to do all of these embeddings.

これらの埋め込みをすべて行うのに約6分かかりました。

Once it's done, it saves it, and then here we go.

終わったら、保存して、ここから始めます。

We can actually ask questions now.

実際に質問することができます。

One mistake I made is that I just said, How much revenue did each company make?

私が間違えたのは、ただ「各会社はどれくらいの収益を上げましたか?」と言っただけです。

And I didn't explicitly tell it to reference its archival memory, and you have to do that unless you can actually customize the Persona to say, Always reference your archival memory.

そして、私は明示的にアーカイブメモリを参照するように指示していませんでした。アーカイブメモリを参照する場合は、パーソナライズして「常にアーカイブメモリを参照する」と言わせる必要があります。

And you can actually customize the Persona to do a lot of things.

そして、実際には、パーソナをカスタマイズしてさまざまなことを行うことができます。

You can say, Don't query the API as much, or Handle memory in a custom way.

「APIを頻繁にクエリしないでください」と言うこともできますし、「記憶をカスタムの方法で処理してください」とも言えます。

So it's really cool that you can do that.

だから、それができるのは本当に素晴らしいです。

So then, rather than doing that, I just asked it directly in line, and I said, Based on your archival memory, how much revenue did Lyft and Uber make last year?

それでは、その代わりに直接ラインで尋ねました。私は言いました、「あなたのアーカイブメモリに基づいて、昨年のLyftとUberの収益はいくらでしたか?」

And then here, this is MemGPT kind of that internal thought.

そして、ここでは、これはMemGPTの内部的な考えです。

The user requested revenue details of Lyft and Uber from last year.

ユーザーは昨年のリフトとウーバーの収益詳細をリクエストしました。

Based on my archival memory, I need to search the archival memory for this information, creating two separate queries to find this information for both companies.

私のアーカイブメモリに基づいて、この情報をアーカイブメモリ内で検索する必要があります。両社の情報を見つけるために、2つの別々のクエリを作成します。

Here we go.

始めます。

We have a function call updating memory with archival memory search.

私たちは、アーカイブメモリの検索を行う関数呼び出しを持っています。

It's querying it, and then it says, Okay, I found that information.

それをクエリして、それから「OK、その情報を見つけました」と言います。

Then it's querying the second document, same thing.

次の文書をクエリして、同じことをします。

Okay, found that information.

わかりました、その情報を見つけました。

And then it replies back, Hello Chad, that's defined in the Persona, so you can change the name, don't worry about that.

そして、それは「こんにちは、チャド」と返答します。それはパーソナに定義されているので、名前を変えることができます。心配しないでください。

I found the information you're looking for.

お探しの情報を見つけました。

The revenue for Lift was $8.399 billion and Uber was $31.875 billion.

Liftの収益は83.99億ドルで、Uberは318.75億ドルでした。

And then I started asking something else.

そして、私は他のことを尋ね始めました。

I said, Based on your archival memory, how many times did the worddriver' appear in the Lift and SEC filings?

私は言いました。「アーカイブメモリに基づいて、リフトとSECのファイリングにおいて「ドライバー」という単語は何回出現しましたか?」

And it actually was starting to go through every single one, and I thought this was going to get quite expensive.

そして、実際には、それはすべての単語を通過し始めていました。これはかなり高額になると思いました。

So I actually stopped it there.

だから、そこで実際にそれを止めました。

And all of this does get very expensive, but I know they're working on adding open-source models, and they already have a lot of the code written, so I'm excited to see that when it comes out.

これには非常に高額な費用がかかりますが、オープンソースモデルの追加に取り組んでいることを知っていますし、すでに多くのコードが書かれていますので、それがリリースされるのを楽しみにしています。

If you want to see me do another tutorial when they actually include open-source models, let me know in the comments below.

もしオープンソースモデルが実装されたチュートリアルを見たい場合は、コメント欄で教えてください。

But that's it, that's all I'm going to share for today because that's just an intro to what you can actually do with MemGPT.

でも、それだけです。今日はそれだけ共有します。それはMemGPTで実際にできることの紹介だけです。

It's a very early project, but it's evolving rapidly, so I'm really excited to see what the authors do here.

これは非常に早期のプロジェクトですが、急速に進化していますので、著者がここで何をするのかを見るのが本当に楽しみです。

And speaking of authors, that's who we have today.

そして、著者について話すと、今日は彼がいます。

We're lucky enough to have the authors of MemGPT with us today, and I want to ask them, What inspired you to create this project?

今日はMemGPTの作者たちが一緒にいて、このプロジェクトを作るきっかけについてお聞きしたいと思います。

And also, what are your short-term and long-term plans for MemGPT?

そして、MemGPTの短期および長期の計画は何ですか?

Hey everyone, I'm Charles, and I'm Vivian, and we're part of the team behind MemGPT.

みなさん、こんにちは、私はチャールズです。そして、私はヴィヴィアンです。私たちはMemGPTのチームの一部です。

So, to give you guys a brief breakdown, with MemGPT, we're really just trying to get around the memory issue with current LLMs.

MemGPTを使って、現在の言語モデルの記憶の問題を回避しようとしています。簡単に説明すると、そんな感じです。

So, with current language models, the only real memory in the system is just what goes in and out of the language model, and that's usually fixed to around 8K tokens, 32k tokens.

現在の言語モデルでは、システム内の唯一の実際の記憶は、言語モデルに入出力されるものだけであり、通常は8Kトークン、32Kトークン程度に固定されています。

It's about, let's say, a few dozen to 100ish messages.

おおよそ、数ダースから100くらいのメッセージです。

And beyond that, if you send more messages than that, you have to start throwing things away.

それ以上のメッセージを送信する場合、それ以上のメッセージは破棄しなければなりません。

And with MemGPT, we effectively make the language model inside of mg GPT that might still have a limited memory self-aware that it has limited memory.

MemGPTを使用することで、限られた記憶を持つ言語モデルが自己にその制約を認識することができます。

So, when it gets a notification, for example, that it's going to run out of memory, it will actively start saving um the important facts, maybe it's learned about you during the conversation or itself, into a permanent memory store that won't get lost.

通知を受け取ると、例えば記憶が不足するという通知を受けると、重要な情報を積極的に保存し始めます。会話中にあなた自身や自身について学んだ重要な事実を、失われない永続的なメモリストアに保存します。

And through this kind of editing memory system, you can get agents that no longer have this issue of memory that just gets erased as the conversation goes on.

このような編集メモリシステムを通じて、会話が進むにつれて単に消去される記憶の問題を抱えないエージェントを作ることができます。

And in terms of what we'd like to do with MemGPT on the short-term uh road map that we have, we'd really like to support more user workflows.

MemGPTに関して、私たちが短期的なロードマップでやりたいことは、より多くのユーザーワークフローをサポートすることです。

So, for example, we've already enabled embedding search over text files that users can feed into MemGPT, and then we'd also like to enable frameworks like uh autogen.

例えば、既にMemGPTにフィードできるテキストファイル上での埋め込み検索を有効にしましたし、また、autogenのようなフレームワークも有効にしたいと考えています。

And then long-term, our main priority is to not have a reliance on gp4.

そして、長期的には、私たちの主な優先事項は、gp4に依存しないことです。

So, whether this involves improving the performance on GPT-3 and A2 or tuning Our Own open-source models to sort of replace this LLM layer inside MemGPT, that's kind of what we have for our future plays.

GPT-3とA2のパフォーマンスを向上させることや、私たち自身のオープンソースモデルを調整して、MemGPT内のこのLLMレイヤーを置き換えるようなことが、私たちの将来の展望です。

All right, thank you for joining us, and if you liked this video, please consider giving a like and subscribe, and I'll see you in the next one.

では、ご参加いただきありがとうございます。もし動画が気に入っていただけたら、いいねやチャンネル登録を考えていただけると嬉しいです。次回の動画でお会いしましょう。


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