LlamaIndexについて、共同創設者のJerry Liuと議論しています。LlamaIndexは、大規模な言語モデルにデータを接続するためのpythonフレームワークです。 Llamaindexには150人以上の貢献者がおり、Github repos、airtable、csvなど90以上のデータ接続をサポートしています。外部データ接続、データフォーマット、インデックス作成、検索、ベクトル保存、類似性検索などについて説明します。
公開日:2023年5月15日
※動画を再生してから読むのがオススメです。
みなさん、人工知能とWeb開発について語るStarMorphをご覧いただき、ありがとうございます。
今日は、大規模な言語モデルを外部データに接続するためのツール、Llama Indexの創設者であるジェリーを皆さんに紹介できることをとても嬉しく思っています。
ジェリーさん、本日はありがとうございました。
Dollaさん、お招きいただきありがとうございます。
ここに来ることができて、とても興奮しています。
ええと、私たちがLlama Indexとは何か、そして人々がそれをどのように使用し、それを構築するために始めるかについて詳しく説明する前に、あなたがこのツールの構築にどのように関与したかについて少し背景をお話しいただけますか?
ええ、それは素晴らしいことです。
このツールを作り始めたのは、11月のことです。
もともと、AIやシステム、スタートアップなど、いろいろなことに興味がありました。
以前は、Robust IntelligenceというシリーズA、シリーズBのスタートアップで数年間、MLモニタリングチームのリーダーを務めた経験もあります。
その前は、Uber ATGでAI研究に携わりました。
また、Quoraで機械学習エンジニアとして過ごした時期もあります。
ですから、推薦システム、コンピュータビジョン、そしてMLPも少々という具合に、機械学習の経験があります。
ですから、当時はまだGPT-3の波には完全に飛び込んでいなかったんです。
OpenAIのGPT-3が発表され、人々はその上にアプリケーションを構築して遊んでいました。
しかし、私はちょうどその波に乗り始めたところでした。
最初にぶつかったのは、この素晴らしいテクノロジーに自分の個人データを渡そうとしたことでした。
前の会社での顧客との会話を入力して、プライベートなデータから洞察を得るために、このツールをどう活用するのがベストなのかを考えようとしました。
そして、私が構築している抽象化は、おそらくアプリケーションを構築するすべての人が解決する必要があることだと気づきました。
当時はGPT-Indexと呼んでいました。
その後、「Llama Index」と改名しました。
しかし、そのアイデアは、言語モデルの外部記憶のようなものをデータ構造に保存し、言語モデルが後で調べて参照できるようにすることでした。
デザインプロジェクトとしてスタートしましたが、すぐに本格的なツールキットへと発展し、人々はエンドユーザー向けのアプリケーションを構築するために使用しています。
いやあ、すごいですね!
Yコンビネーターなどで聞いた話ですが、本当の意味でのプロダクト・マーケット・フィットやソリューションを見つけるには、自分が必要としているものを作るのが一番いい方法だということがありますよね。
そして、多くの人々が、まさに今あなたが説明したようなものを求めていることがわかりました。
ボットに特定のデータを取り込み、エンベッディングやベクトルストレージで使用し、大規模な言語モデルをリンクさせることができることです。
そうですね、まさにその通りです。
少し背景を説明すると、言語モデルは推論エンジンとして扱うことができます。
自然言語を入力すると、それをもとに最適な答えを出そうとする。
その意味では、AIを搭載したCPUのようなものです。
しかし、完全なプログラムを構築するには、CPUがやりとりできるものを保存するためのRAMやハードディスクのスペースが必要です。
そこで私は、言語モデルが外部メモリやハードディスクを参照し、知識ベースにはない情報を活用できるようなデータ構造を構築することに興味を持ちました。
これが、Llama Indexのアイデアの始まりです。
デザインプロジェクトとしてスタートし、すぐにエンドユーザー向けのアプリケーションを構築するためのツールキットへと発展しました。
すごいですね。
私はこのところ、1日に少なくとも1時間は、私のデータで訓練されたボットの1つと会話することに費やしています。
そして、「今週は何を学ぼうか?
今週はどんなことを学びたいかな?
これは、学習やコンテンツの作成、そしてデータの照会において、とても強力な方法だと思います。
では、もう少し詳しくお聞かせください。
データを取り込むことについての概要がよくわかりました。
多くの人が抱く疑問のひとつに、どのようなデータを取り込む必要があるのか、ということがあります。
非構造化データと構造化データについてお話しましたね。
よく聞かれるのは、どのようなファイルタイプで、どのようなフォーマットでドキュメントを作成すればいいのか、といったような、データをこのようなシステムに取り込むにはどうすればいいのか、ということです。
素晴らしい質問ですね。正直なところ、この件に関しては1時間くらい話し続けられそうですが、ただ、このようなことをユーザーに伝えることができればと思います。
言語モデルには、とても美しいものがあります。
言語モデルは、基本的に非構造化テキストをデータ表現の中心的な媒体として取り込むことができ、非構造化テキストを非常によく理解することができます。
ええと、例をあげると、ウェブページを取ると、たとえばHTMLタグを取り除くなどの基本的な処理をするだけでも、そういうことができます。
そして、そのウェブページ全体を言語モデルの入力プロンプトに投げ込みます。
プロップの制限に従えばいいのですが、これはあくまで例です。
ええと、それはウェブページ全体、つまり、そこにあるもの全てを理解することができます、たとえそこには、散らかったフォーマットやその他の問題があったとしてもです。
だから、手作業で前処理をしたり、データをきれいにしたりする必要はないんです。
また、言語モデル以前の例を見ると、データパイプラインをどのように構築するかがわかると思います。
多くの取り込み、解析、ETLを行い、それを構造化されたフォーマットで保存する必要があります。
そして、この非構造化データに多くのタグを付けて注釈を付けます。
このタグは、データに対する洞察を得るのに役立ちます。
言語モデルの優れた点の1つは、非構造化データを与えるだけで、そのデータ全体を処理できることです。
言語モデルは非構造化データを処理し、噛み砕いた上で、基本的に答えが何であるかを突き止めることができます。
そのため、これほど強力なものがあれば、使用するセットアップについても、ある種の暗示を与えることになります。
また、扱うことのできるファイルフォーマットの種類にも影響します。
PDF、PowerPoint、Excelシートなど、テキスト表現に変換さえできれば、どんなファイルフォーマットでも取り込むことができるからです。
言語モデルが理解できる非構造化テキスト表現です。
画像や動画も含まれます。
画像であれば、その画像にテキストでキャプションを付けることができます。
また、動画があったとして、その動画の説明をテキストで記述することもできます。
そうすれば、ビデオをインデックス化して、そのビデオで質問することもできます。
ええと、それで、Llama Indexが実際にサポートしているのは、私たちがサイトを持っていることです。それで、サインをお見せするために、私たちには3つの異なるコンポーネントがあります。
ひとつは、データコネクターです。
Llama Hubと呼ばれるもので、80種類以上のデータコネクタを提供しています(現時点では、アイデア以上だと思います)。
これにより、さまざまなデータ形式、API、ワークプレイス・アプリケーション、構造化データベースをシステムに接続することができます。
このデータを取り込むだけで、次のステップ、例えばステップ2やステップ3では、基本的にインデックスを作成し、このデータを保存し、言語ファイルに送り込むだけでいいのです。
ですから、実際にはかなり強力です。
PDFファイル、PowerPointファイル、Excelファイル、画像ファイル、Webサイトなど、さまざまなファイルへの対応をサポートしています。
現在、5、6人のライブストリーマーがいますが、この多くはコミュニティ主導で行われています。
言語モデルについて人々が最初に気づいたことの一つは、それがテキストであればどんなデータでもほぼ理解しようとするという事実でした。
その結果、Hubでは多くの分類が行われるようになりました。
絶対に、それは非常に大きなことだと思います。それと同様に、あなたが先ほど細かい調整とトレーニング、そしてコンテキストの取得の違いについて言及したこともです。
文脈の埋め込みができるようになるには、MLのような正式な経験はそれほど必要ないということです。
また、データをフォーマットしたり、機械学習の方法を学んだりする必要がないため、より多くの人がこれらのツールを使えるようになります。
これが、この分野で爆発的な普及が見られる理由の大きな部分を占めていると思います。
機械学習は、エンタープライズやフロントエンド開発など、さまざまな分野の人々にとって、より身近なものになっています。
100、技術的な専門性のスペクトルをカバーしているので、興味深いことだと思います。
最近では、AIの経験が少ないユーザーでも、Llama Indexのようなツールを使えば、すぐに使いこなすことができるようになりました。
たった3行のコードで、自分のデータを使ったチャットボットを構築できるのです。
データを扱い、そのデータにインデックスを付け、そのデータにクエリをかける。
なぜそんなことができるかというと、言語モデルがデータETLスタックを根本的に簡素化したからです。
データを放り込んで、白紙の状態でインデックスを作成し、その上で質問を始めることができるのです。
しかし、重要なのは、複雑さの度合いにも幅があることです。
より洗練されたAIの専門家も、この問題を解決しようとしています。
重要なのは、ツールキットの機能性、拡張性、カスタマイズ性を確保することで、彼らが必要に応じてこれらの部品を使いこなすことができるようにすることです。
その点で、明確な質問をしたいと思います。
ええと、それは私が思うに、皆さんが持っている疑問、つまり、それは素晴らしいことですが、それが実際には3行だけだとは知らなかった、それは驚くべきことです、少し明確にしていただけますか?
データコネクター、インデクサー、そしてクエリですね。
インデクサーとは何か、また、LLMにデータを供給したり、データを渡したりするプロセスについて、もう少し詳しく教えてください。
ええ、もちろんです。
3行のコードで構成されていると、ちょっと魔法のように感じますが、これらのステップはすべて自分でカスタマイズすることができます。
しかし、基本的には、おっしゃるとおり、データコネクターで、PDFファイルや税務ファイルからデータを読み込むことができます。
パワーポイントやデータベースなど、今お話したようなものをドキュメント・オブジェクトに読み込むだけです。
これは非常に軽いドキュメント・オブジェクトです。
テキストとメタデータを保存しておくものです。
そして、このドキュメントにインデックスを付けます。
インデックスを付けるということは、基本的に、さまざまなインデックス構造を提供するということです。
最も基本的なものは、テキストを塊にして、各トランクにバッティングを追加するものです。
つまり、ある種のタックスフロー戦略を用いてテキストを切り分けます。
そして、それぞれの塊にある種のエンベッディング(基本的には数字のベクトル)を加えます。
これは、そのテキストのトランクが何についてのものかを対称的に表現するものです。
これで、基本的には、ある種のアフターストアに保存されることになります。
私たちは、Pine Cone、Promo、Novasなど、さまざまなタイプのバックリストア・プロバイダーと統合しています。
そして、実際にこのデータを手に入れたら、このデータにクエリをかけることができます。
ファクトやソートで保存されたこのデータを使用します。
クエリの仕組みは、質問したり、解決すべき課題を与えたりします。
そして、まず、このインデックスから、埋め込みデータを使って、どちらかというとデータの断片を取得します。例えば、埋め込みデータで保存されている場合は、トップKやバッティング類似度ルックアップを使います。
そして、コーパスから最も関連性の高いテキストを取得します。
そして、これらのテキストを言語モデルに送り込み、「最終回答」を合成する。
なるほど、それについて2つほどフォローアップの質問があります。
検索は本当に重要な概念になりつつあると思います。
検索とはいったい何なのか、そしてそれがこのプロセスにどう関係するのか、もう少し詳しく教えてください。
ええ、では、この「検索拡張世代」のようなシステムについてもう少しお話ししましょう。
ええと、それはかなり専門的な用語ですが、基本的には、言語モデルがあり、それからリクルートメントモデルと呼ばれる別のモデルがあり、そしてあなたのデータがあります。
目的:入力プロンプトのようなユーザーからの入力要求があった場合、まず、この検索モデルを使って、知識コーパスから関連するテキストを取得することになります。
検索モデルにはさまざまな形式がありますが、簡単に言うと、クエリを受け取り、関連する仮想テキストのセットを返します。
そして、それを合成モデルや生成モデルと組み合わせます。
検索されたテキストは、生成モデルに送られ、生成モデルが最終的な答えを合成してくれます。
つまり、世代モデルとは、基本的に言語モデルのことです。
言語モデルとは、テキストを解析して、答えを合成してくれるものです。
検索モデルは、さまざまなもののうちの1つです。
最近では、多くの人がベクターストアを使用して、データの保存とインデックス付けを行っています。
検索モデルは、マクロストアのデータに対して、埋め込みの基礎となる類似性のロックアップを行うだけです。
入力されたクエリ、クエリに対する埋め込み、そしてその埋め込みを使用して、マクロソートから最も類似した文書の上位1つを探し出すという仕組みです。
そして、それをリクルートテキストとして使用するのです。
これは面白いですね。
このように、検索にはさまざまな種類がありますね。
例えば、キーワード検索やナレッジグラフ検索では、オリーブグラフ内のエンティティ間の関係や、異なるノード間の関係を使って、検索を行うことも可能です。
つまり、現在のノードだけでなく、その2つのノード間の関係も取得することができるのです。
LAVAインデックスには、このような様々なタイプのインデックス構造があり、様々なタイプの検索を可能にしています。
もう一つ非常に興味深いのは、検索というのは新しい概念ではなく、以前からあるものだということです。
言語モデルを取り除いてリトリーバルだけを取ると、それは基本的に情報の承認と推奨システムをどのように最適に行うかについてです。
だから、ここにもいろいろなコンセプトが追加できるんです。
例えば、安全な過越祭りのフリーウルフのようなもので、まず、自然なバケツのようなアイテムに手を入れます。
そして、それを第二状態クラスでフィルタリングし、書き換えやフィルタリングを行うのです。
このように、検索そのものが非常に興味深いのです。
この分野では、10年、あるいは数十年にわたる研究が行われてきました。
しかし、検索モデルとキャリブレーションモデルの相互作用を見るのも興味深いです。
システム全体が、あなたが望むような最終的な答えを返してくれるのです。
それはとても興味深いですね。
私の2つ目の質問の一部に答えてくれたようなものですが、エンタープライズに所属する人たちが、非構造化データではなく、構造化データをすでに持っているとしたらどうでしょうか。
私の質問は、インデックスやチャンキングレベルで何かできないか、というものでした。
構造化データに基づいて関係を修正するために、情報がどのように入ってくるかを整理するところでしょうか。
しかし、検索ステップで何らかの構造を作成することもできるとおっしゃいましたが、これは私がクライアントと遭遇したことでもあります。
ある種のスペクトラムが存在することがあります。
1万ページもあるコンプライアンス文書を読んでいないため、長い文書を照会して、何が得られるか確認したい場合もあります。
そのような場合、最初の調査を行うには、クエリを実行するのが最適です。
しかし、企業にはすでに重要なインフラがあり、特定の構造を持つデータインフラがあることもあります。
そのようなデータをすでに持っていて、さらに高度なシステムを構築したい場合、どうすればよいでしょうか。
そうですね、実はまだ話していないことがあるのですが、紹介は何かをきっかけに行われるもので、その何かとはデータベースのようなものです。
構造化されていないデータベース、つまり、さまざまな種類のデータベースがありますね。
構造化されていないデータベースには、キーバリューストアのようなものと、マクロストアのようなものがあります。
これらは、構造化されていないドキュメントを取得することができます。
そして、SQLで問い合わせるような構造化されたデータベースがあります。
これらのデータベースは本来、異なる形式の検索を必要とするものです。
ですから、構造化されたテーブルの中にすでにたくさんのデータがあって、それを自然言語で照会したい場合、構造化されたデータベースに対して税金をかけることができるのです。
例えば、ユーザーから入力要求があったとします。
構造化データベースがある。
この自然言語による入力を、データベースの検索で行うことはできません。
言語モデルからSQL文を出力させることができます。
そして、そのSQL文を構造化データベースに対して実行し、必要な結果を得ることができます。
つまり、検索の方法は、データが公開するインターフェースに依存するのです。
構造化データベースであれば、おそらくSQLクエリインターフェースのようなものが公開されているはずです。
また、例えばベクトルストアのようなものであれば、トップKエンベッディングのルックアップインターフェースを公開することになるでしょう。
これは、非構造化ドキュメントを検索するためのものです。
それはとても理にかなっていますね。
なるほど、ご説明ありがとうございました。
先ほど、このウェブサイトを見たことがあるとおっしゃっていましたが、このウェブサイトを見ることは、人々にとって本当に有益だと思います。
あなたは90のデータ接続があると話していましたが、このウェブサイトは見ていてとても楽しいです。
すべてのカードが表示され、どれだけ素晴らしい機能を備えているかがわかります。
そのウェブページが何なのか、説明文に書いておいてもらえますか。
ああ、もちろんです、それはllamahub.aiと呼ばれていて、ウェブサイトは実際には貢献者によってデザインされたので、彼らに少しクレジットを与えたいと思います。
彼の名前はジェシー、でも、いい感じです。
90以上のデータコネクタが載っていて、もし興味があれば、いつでも投稿を受け付けています。
状態すごいですね。
ええ、素晴らしいです。
いいぞ、ジェシー。
ジェシーのおかげだ
それで、データ・コネクターがありますね。
また、複数のレトリバー検索メカニズムがあるとおっしゃっていました。
それは、インデックス・ドキュメントの中で、さまざまな検索方法を見つけることができるのでしょうか?
そうですね、検索拡張世代という考え方に沿って、かなり主要なアーキテクチャが詳細に記述されています。
ラマ・インデックス・ドキュメントの中に、いくつかのガイドがあります。
Llama Index Docsでググってみてください。
これが基本的に今のところ私たちのメインサイトですが、実際にはランディングページもあります。
その仕組みについては、いくつかのガイドがあります。
しかし、このアイデアは、データを読み込んだら、データベースやドキュメントのようなものを使ってインデックスを作成し、データを保存することです。
そして、データを保存したら、そのデータを検索し、検索されたデータを合成することができます。
これは、全体的なクエリーインターフェースを構築し、ユーザーが望む結果を返すためのものです。
構築したいインデックス構造に対応した、さまざまな検索メソッドを用意しています。
また、そのうちのいくつかに対応する、追加で採用可能なメソッドもあります。
例えば、簡単なランキングを作成したり、土地を利用したりするような高度なものです。
たとえば、さまざまなタイプのサブデータ構造にクエリをルーティングしたり、さまざまなインデックスを作成したりすることができます。
トップレベルのクエリーを、どのように異なるインデックスにルーティングするのか?
そういったことはすべてドキュメントに書いてありますから、ぜひチェックしてみてください。
願わくば、初心者の方にも簡単にできるように、そして、より高度な機能が必要な場合は、ドキュメントを参照していただければと思います。
というわけで、以上です。
今おっしゃったようなことだと思います。
オペレーティングシステムのモデルに戻ると、異なる取得メカニズム、異なるデータコネクタ、異なる埋め込み間で動的に切り替えることができ、ボットの性格や記憶を変えることは非常に興味深いと思います。
そして、あなたが何を知っているかというと、どのモデルを使うべきかを選べる、そして全ての異なる部分がタスクに応じて変更できる完全なシステムを見るのは本当に興味深いです。
では、もう少し基本的な話に戻りますが、どのように始めればいいのでしょうか?
Llama Indexは、現在、主にPythonのライブラリですね?
では、どのような環境が必要なのか、もう少し詳しく教えてください。
例えば、3行のコード、基本バージョン1を使って、データをLLMに接続するところから始めたい人がいるとします。
この場合、どこで、どのようにコーディングを開始するのか、教えてください。
コマンドラインから始めるのでしょうか?
ウェブブラウザーでやるのでしょうか?
環境とコーディングの面で、何を始めるのが一番いいのでしょうか?
本当にいい質問ですね。
Llama Indexは現在、Pythonのパッケージとして提供されています。
PyPIで公開されているので、PipでLlama Indexをインストールすることができます。
少なくともクイックスタートチュートリアルや多くの例では、基本的にシンプルなPythonスクリプトを書く方法を紹介しています。
Jupyterノートブックで実行すれば、各セルを実行するだけで、結果をノートブックで視覚化することができます。
その他にも、スクリプトに書いてコマンドラインで実行することもできます。
これはごく基本的なものです。
とはいえ、これをフルスタックのWebアプリケーションの一部として統合する方法についても、チュートリアルを用意しています。
チュートリアルを見ていただければ、フルスタックのWebアプリケーションを構築する方法を紹介しているものがいくつかあります。
また、Llama Index Starter Packと呼ばれる、寄稿者が作成した隣接するレポもあります。
これは、Pythonで作られたアプリケーションをDockerコンテナやフラットスタックのデータシートビッグクエリの一部として実際にパッケージ化する方法を示しています。
これはある種のクライアント・フロントエンドから行われ、そこから本格的なアプリケーションを構築するのに役立ちます。
前のスターターパックではなく、他のウェブアプリケーションガイドのように、それはFlaskでも推奨されているのでしょうか?
ええと、Flaskで推奨されていると思います。
実際に再確認してみますが、私は80%くらいすごいと思っています。
それは素晴らしいですね。
そうですね...
このデータフォーマットについて 1時間くらい話そうか
フォローアップもできるかもしれませんね。
フォローアップをすることで、もう少しコーディングができるようにする、という話もしましたよね。
でも、このような質問に答えてくれて、みんなをこの世界に引き込んでくれて、この素晴らしいツールを作ってくれて、本当にありがとうございます。
そして、GitHubへの発展もおめでとうございます。
これが人々にとって重要なトピックになりつつあるのは、素晴らしいことです。
Llama Indexは、人々がそれを始めるのに役立つ最高のツールの1つだと思います。
だから、これを作ったことを祝福します。
最後になりますが、何か他に話したいことはありますか?
また、Llama Indexを使い始めるには、どこであなたを見つけることができますか?
また、今取り組んでいること、楽しみにしていることがあれば教えてください。
いやいや、ここにいるのが楽しくて仕方ないんです。
もし連絡を取りたいのであれば、ドキュメントにTwitterやDiscordへのリンクがたくさんあります。
Discordのコミュニティは活発です。
Llama Indexで遊んでいて、何か質問があれば、気軽にいずれかのチャンネルに連絡をしてください。
そして、その中でたくさんの議論が行われています。
すごい!
素晴らしいです。
では、ありがとうございました!またすぐにお会いしましょう。
これからも連絡を取り合い、Llama Indexが成長するのを楽しみにしています。
それでは、またよろしくお願いします。
ありがとうございました、最高です!