Applying OpenAI's RAG Strategies
02 RAGで取り上げられた98%の事例で紹介された手法の整理 we expand on each method mention and show how you can implement each one for yourself.
リンク集としても有用(サーベイっぽい)
https://blog.langchain.dev/content/images/size/w1000/2023/11/image-12.png
Baseline
The base-case retrieval method used in the OpenAI study mentioned cosine similarity.
distance metricsへの参考
Query Transformations (1)
Query transformations are a set of approaches focused on modifying the user input in order to improve retrieval.
Query expansion
OpenAIによって報告されなかったメソッド
Step back prompting
Rewrite-Retrieve-Read
Routing (2)
The OpenAI presentation reported that they needed to route question between two vectorstores and single SQL database.
SQLデータベースはtool利用の話ではないかと思われる
Query Construction (3)
valid SQL needed to be generated from the user input in order to extract the necessary information.
OpenAIによって報告されなかったメソッド
Text-to-metadata filter for vectorstores
Text-to-Cypher for graph databases
Text-to-SQL+semantic for semi-structured data in Postgres with Pgvector
Building the Index (4)
OpenAI reported an notable boost in performance simply from experimenting with the chunk size during document embedding.
報告されなかったメソッドに「embedding fine-tuning」
HuggingFaceのtutorial
Post-Processing (5)
We can use post-processing to enforce diversity or recency among our retrieved documents, which can be especially important when we are pooling documents from multiple sources.
Re-rank
RAG-fusion
Classification
This marries two ideas
tagging of text
logical routing
OpenAIによって報告されなかったメソッド
MMR
クラスタリング
For RAG evaluation, LangSmith offers a great deal of support