現在のチャットボットのアップグレード
チャットボットSydneyをアップグレードして、Weaviateのハイブリッド検索とクエリ構造化をテストしました。金融チャットボットを500社以上に拡張するために必要な機能です。
更新(2026年): Sydneyはこのweaviate実験以来、大きく進化しました。FAISS、Weaviate、その他をテストした後、本番バージョンにはSupabase pgvectorを採用しました。Sydneyは現在、ストリーミングレスポンスとツール使用でClaude上で動作しています。以下で説明しているハイブリッド検索とクエリ構造化のアイデアは、現在のSydneyの動作に直接影響を与えています。
2024年5月のオリジナル投稿を以下にそのまま残しています。
最新の投稿で述べたように、自己評価する金融チャットボットに取り組んでいます。では、なぜ現在のチャットボットSydneyのアップデートに寄り道したのでしょうか?いくつかの理由があります:
- Weaviateベクトルストアのエンドツーエンドテスト:
- 金融チャットボットのメインベクトルストアとしてWeaviateを使おうとしていますが、スケーリング/メモリサイズの問題に直面しています。具体的には、約20社の過去10年分の10Kと10Q提出書類だけで、Weaviateコレクションのサイズはすでに2GBです。現在のアプローチでは、S&P 500全体で約50GB以上のコレクションになります。大きすぎて、運用/維持のコストが高すぎます。そこで、異なるProduct Quantization(PQ)パラメータをテストしています。
- 多くの他のベクトルストアを試した後、メタデータフィルター付きのハイブリッド検索を高速で実行できるため、Weaviateに傾いています。
- WeaviateのPQに取り組んでいる中で、Weaviateを本番環境にデプロイする方法について疑問がありました。Weaviate CloudやAWS/Google Cloudの使用は?デプロイは難しいのか?コストはいくらか?
- これらの疑問から、現在のチャットボットSydneyにWeaviateをデプロイすることにしました。基本的にFAISSをWeaviateに置き換えます。
- 現バージョンではWeaviate Cloudを使用しています
- クエリ翻訳とクエリ構造化の実装、出力がJsonであることを確認して使用可能にする
- クエリ翻訳では、入力を個別に回答できる特定のサブ問題またはサブ質問のセットに分解することが目標です
- クエリ構造化では、ハイブリッド検索に適した検索語句だけでなく、フィルタリングに適したメタデータの生成にも非常にこだわっています
- これは金融チャットボットが必要に応じて年度や業界などで正しくフィルタリングする上で非常に重要です
- 複数のフィルターを使ったハイブリッド検索の実施方法と、コンテンツだけでなくメタデータも返す方法
ご覧の通り、金融チャットボットを作るには上記のすべてが必要なので、まずチャットボットSydneyにはるかに小さなスケールで適用してみようと思ったわけです :)
Sydneyを今すぐ試せることをお知らせできてうれしいです。上記のすべての機能が備わっています。以下のような質問を試して、特定のブログ記事へのリンク付きで関連する回答が返ってくるはずです。
- Chandlerは2020年にKevin Ruddについて何を書きましたか?
- 2020年から現在までにChandlerがRay Dalioについて書いたことをすべて教えてください
- Chandlerは2022年にHealth Savings Accountsについて何を書きましたか?
- Chandlerは2015年に何をしましたか?
今回はここまでです。金融チャットボットの作業に戻ります :P
Weaviateやメタデータフィルター付きハイブリッド検索を試したことがある方、何がうまくいったか教えていただけるとうれしいです。
よろしくお願いします、Chandler
2024年9月の更新
Sydneyはマルチタレントなエージェントになりました:
- 現在のS&P 500企業について、過去10年間にSECに提出した内容を含めて質問に答えられます
- 私の15年間のブログコンテンツからインサイトを提供できます
こちらでチェックしてください。
P.S: 以下はクエリ翻訳とクエリ構造化に使用しているプロンプトの例です。
"You are a helpful assistant that generates multiple sub-questions related to an input question. "
"The current year is 2024."
"The goal is to break down the input into a set of specific sub-problems / sub-questions that can be answered in isolation. "
"Each specific sub-question will be used to retrieve relevant content from a vector store, using similarity search with score. "
"Phrase the wording of the questions appropriately for this purpose.\n"
"This vector store includes all of the published blog posts from Chandler Nguyen's blog from 2007 to 2024.\n\n"
"Original question: \{query\}\n\n"
"Generate the minimum number of sub-questions necessary to answer the original question. "
"Your response should be formatted as a JSON array of strings, where each string represents a sub-question. "
"Do not include any additional words, characters, or explanations in the response.\n\n"
"Example response:\n"
'[\n'
' "sub-question 1",\n'
' "sub-question 2"\n'
']'
"""You are a helpful assistant that generates a structured query related to an input question.
The goal is to break down the input into a structured query that can be used to retrieve relevant content from a vector store, using similarity search with score.
This vector store includes all of the published blog posts from Chandler Nguyen's blog from 2007 to 2024.
Original question: \{query\}
You must generate a response in JSON format as described below without any additional words or characters:
[
"content_search": Similarity search query used to apply to the content of the Chandler Nguyen published blog posts to find similar documents related to the sub-question(s). Ensure the content_search query is not too broad or too specific, and strikes a balance between relevance and completeness. \n
"start_date": optional field, the start date to search for blog posts that are relevant to the sub-question(s) in YYYY-MM-DD format. If the sub-question(s) do not specify a time frame, leave this field blank or set it to the earliest possible date (e.g., 2007-01-01) to cover a broader range. \n
"end_date": optional field, the end date to search for blog posts that are relevant to the sub-question(s) in YYYY-MM-DD format. If the sub-question(s) do not specify a time frame, leave this field blank or set it to the latest possible date (e.g., 2024-12-31) to cover a broader range. \n
]
If the sub-question(s) include multiple years or a specific time range, generate 1 response for each year or time range, enclosed in separate JSON objects within the outer array.
Example responses:
For an open-ended sub-question without a specific time frame:
Sub-questions: ["What are the key insights Chandler wrote about Health Savings Accounts (HSA)?"]
[
"content_search": "Chandler Nguyen blog posts about Health Savings Accounts",
"start_date": "2007-01-01",
"end_date": "2024-12-31"
]
For a sub-question specifying a year:
Sub-questions: ["What blog posts did Chandler write in 2018?", "Which blog posts written by Chandler in 2018 mention Kevin Rudd?"]
[
"content_search": "Chandler Nguyen blog posts in 2018",
"start_date": "2018-01-01",
"end_date": "2018-12-31"
],
[
"content_search": "Kevin Rudd mentioned in Chandler Nguyen blog posts in 2018",
"start_date": "2018-01-01",
"end_date": "2018-12-31"
]
For a sub-question specifying a time range:
Sub-questions: ["What did Chandler write about Ray Dalio in 2020?", "What did Chandler write about Ray Dalio in 2021?", "What did Chandler write about Ray Dalio in 2022?"]
[
"content_search": "Chandler Nguyen blog posts about Ray Dalio in 2020",
"start_date": "2020-01-01",
"end_date": "2020-12-31"
],
[
"content_search": "Chandler Nguyen blog posts about Ray Dalio in 2021",
"start_date": "2021-01-01",
"end_date": "2021-12-31"
],
[
"content_search": "Chandler Nguyen blog posts about Ray Dalio in 2022",
"start_date": "2022-01-01",
"end_date": "2022-12-31"
]
"""
P.P.S: フロントエンドがまだとても遅いことは承知しているので、フロントエンド開発についてもっと学ぶ必要がありそうです。





