RAG Evaluation (Document Relevance) | LangSmith Evaluations - Part 14
Summary
TLDRランチェインのLanceが14回目のビデオで、ランチェイン・スミスの評価について解説しました。以前のビデオでは、RAG(Retrieval-Augmented Generation)生成の答えと参照答えの比較、RAG生成の答えと関連文書の比較を行い、本稿では、問い合わせと検索された文書を比較するという新しいテストについて語ります。これは検索品質や正確性に対する非常に良いテストです。ビデオでは、ランチェインを使用する必要がないという共通の疑問に触れ、その答えは「いいえ」であると説明しました。重要なのは、任意の関数呼び出しをランチェイン・スミスに接続できるという点です。評価セットは、以前に説明したように入力出力をペアにして定義されています。以前に参照答えの評価と、答えの幻覚評価について話しましたが、今回は問い合わせと文書を比較する評価についてです。これは、RAGで非常に一般的です。評価のプロンプトは非常にシンプルで、入力の問い合わせと予測の文書を比較するだけで、基準を満たすかどうかを評価します。評価の結果は、評価スコアとして表示され、各問い合わせと検索された文書の関連性を示します。この方法は、参照がない場合に入力問い合わせと検索文書を比較する際に非常に適しています。
Takeaways
- 🔍 ランチェインのドキュメンテーションをインデックス化し、検索品質や正確性をテストすることが重要です。
- 🛠️ ランチェインを使用しなくても、ランスミスを使用することができます。任意の関数呼び出しをランスミスに記録することができます。
- 📚 評価セットは、インデックスドキュメントに基づく質問と回答のペアです。
- 📈 参照回答と比較した評価、および回答の幻覚評価が以前に説明されました。
- 🟢 緑色のバーでは、質問と検索されたドキュメントを比較し、検索品質をテストします。
- 📝 評価プロンプトはシンプルで、入力質問と予測(取得されたドキュメント)を比較する基準を提供します。
- 🔑 ランチェインの文字列バリデーターを使用して、質問と取得ドキュメントを比較します。
- 📊 スコア文字列バリデーターを使用して、ドキュメントが入力質問に関連しているかどうかを評価します。
- 🌟 正規化基準として、0が関連性なし、5が一部関連、10が全て関連していることを意味します。
- 📈 評価結果は、入力質問と取得ドキュメントの関連性スコアを示します。
- 🔎 個別の評価結果を確認し、スコアリングの理由を理解することができます。
- 📚 この方法は、ランチェインを使用して検索評価を実施する方法を示しています。
Q & A
ランチェインのドキュメンテーションをインデックス化するために必要なものは何ですか?
-ランチェインのドキュメンテーションをインデックス化するためには、ランチェインを使用する必要はありません。重要なのは、関数の定義と、その関数をLangSmithに登録することです。
ランチェインを使用しない場合でも、ランスミスを使用できますか?
-はい、ランスミスを使用することができます。ランスミスは、任意の関数呼び出しや特定のモデルAPIに接続することができます。
評価セットの入力と出力ペアはどのようにして得られますか?
-評価セットの入力と出力ペアは、インデックス化されたドキュメントに基づいて得られます。これらのペアは、質問とそれに対応する回答から成るものです。
参照回答とは何ですか?
-参照回答とは、生成された回答と比較するために使用される正確な回答です。これは、回答の質を評価するために使用されます。
回答のハロウセン評価とは何ですか?
-回答のハロウセン評価とは、生成された回答が参照文書から離れている場合に、そのような現象をテストするプロセスです。
ドキュメントの検索品質をテストするために使用される緑色のバーとは何ですか?
-緑色のバーは、検索されたドキュメントを質問と比較するプロセスを表しています。これは、検索品質や正確性をテストするのに非常に役立ちます。
ランチェインの文字列バリデータとは何ですか?
-ランチェインの文字列バリデータとは、質問と検索されたドキュメントを比較するために使用されるツールです。これは、入力と予測の関係を評価するのに使われます。
評価プロンプトには何が必要ですか?
-評価プロンプトには、入力質問と予測(検索されたドキュメントや任意の回答)が必要です。また、評価基準として、ドキュメントが入力に関連しているかどうかをスコア付けします。
スコアリングバリデータの役割は何ですか?
-スコアリングバリデータは、入力質問と検索されたドキュメントの関連性を評価し、その結果をスコアで示します。これにより、検索品質を客観的に評価することができます。
評価結果を表示する際に使用されるメトリックは何ですか?
-評価結果を表示する際には、入力質問と検索されたドキュメントの関連性のスコアを使用します。これは、ドキュメントが質問にどれだけ関連しているかを示します。
評価結果を確認する際に、どのような情報を得られますか?
-評価結果を確認する際には、各ドキュメントが質問に関連しているかどうかのスコアと、そのスコアの詳細な説明が得られます。これにより、検索結果の質を理解し、改善の余地を特定することができます。
ランスミスを使用して検索評価を行う際の利点は何ですか?
-ランスミスを使用して検索評価を行うことで、検索されたドキュメントが質問にどれほど関連しているかを客観的に評価することができます。また、検索品質の向上や、検索アルゴリズムの最適化に役立ちます。
Outlines
📈 ランチェインの評価方法: ドキュメントの関連性の評価
ランチェインを使用して、Smithの評価方法について解説しています。このビデオでは、以前のビデオで触れたRAG(Retrieval-Augmented Generation)の評価方法に加えて、検索されたドキュメントと質問の関連性評価について説明しています。ランチェイン自体は使用していませんが、ランスミスに接続するためにtraceable decoratorを使用しています。評価の際には、ランチェインの文字列バリデータを使用し、質問と検索されたドキュメントを比較します。評価のプロンプトはシンプルで、入力質問と予測(検索されたドキュメント)を比較するためだけの基準を提供しています。
📊 RAG評価の結果: ドキュメントの関連性のスコア
この段落では、RAG評価の結果を紹介しています。新しい実験の結果を表示し、メトリックの表示を選択できます。入力質問と検索されたドキュメントの関連性スコアを比較し、精度を評価しています。各評価の詳細を表示し、スコアリングの根拠を確認することができます。この評価方法は、参考回答がない場合のドキュメントの関連性評価に役立ちます。
Mindmap
Keywords
💡Lang chain
💡Rag eval
💡Traceable decorator
💡Retrieval quality
💡Answer hallucination eval
💡Score string evaluator
💡Vector store
💡Normalization criteria
💡Instrument of retrieval evaluation
💡Document relevance
💡Evaluation prompt
Highlights
This is the 14th video focused on LangChain's Smith valuations
The last two videos discussed RagEval and comparing Rag-generated answers to reference answers and relevant documents
The video will focus on comparing retrieved documents to the question, a test for retrieval quality or accuracy
LangChain is indexed with a set of documentation, but is not used for this evaluation
LangSmith can be used with any arbitrary function call or model API, not just LangChain
The traceable decorator is used to log function calls to LangSmith
A dataset of input-output question-answer pairs is defined based on the indexed documents
Answer hallucination evaluation is discussed, comparing retrieved documents to the answer
LangChain's string evaluator is used to compare the question (input) to retrieved documents (prediction)
There is no ground truth or reference answer for this evaluation, only the question and retrieved documents are compared
The evaluation prompt is simple, providing the input question and a placeholder for the prediction (retrieved documents)
The information flow involves extracting the question from examples, performing retrieval, and mapping the question to retrieved documents as the prediction
LangChain's score string evaluator is used, with criteria based on document relevance to the question
The evaluator is defined with the eval set, and the evaluation is kicked off
The experiment can be viewed, with metrics like accuracy scores for question-document comparison displayed
The prompt itself can be assessed to understand the grading, with the assistant's answer incorporating retrieved documents
The assistant's response is evaluated based on relevance to the user's question, with a scoring system from 0-10
Different responses may receive variable scores based on the relevance and reasoning provided
This demonstrates how to instrument retrieval evaluation in LangSmith using the score string evaluator
The focus is on document relevance in this third type of Rag evaluation
Transcripts
hi this is Lance from Lang chain this is
our 14th video focused on Langs Smith
valuations so our last two video talked
about rag eval and we talked through
first comparing our rag generated answer
to a reference answer we talked about
comparing our rag generated answer to
relevant documents this thing here in
the red to test for things like
hallucinations and now we're going to
talk about this green bar so comparing
our retriev documents to the question
and this is a really nice test for
retrieval quality or
accuracy so one thing just Refresh on WE
index a set of Lang chain
documentation and our rag chain is
defined right here and one thing you'll
notice that we're not actually using
Lang chain for any of this and this is a
big common question that comes up is do
I need to use Lang chain to use Langs
Smith and of course the answer is no
you'll see right here all I'm doing is
I'm basically defining my function that
performs all the he heavy lifting this
is really where my answer is generated
here I'm calling basically open a API
using this wrap thing um but the key
point is this with this traceable
decorator this function call is
basically just log to Langs Smith um so
that's a way we can connect any
arbitrary function call that you know
hits any particular model API we want
doesn't have to use Lang Lang chain at
all with this traceable decer I can then
register that function to Langs Smith
and so uh the results of this function
are going to be logged and we'll see
that
shortly
um so we defined a data set we already
went through this but I'll just refresh
very quickly input output pairs question
answer pairs based upon our again index
doc doents which are here um so that's
our eval set now we previously talked
about again that reference answer to
answer evaluation so that's what we
talked about here um we talked about
answer hallucination eval so that's
comparing as you see in our flow here
comparing the retrieve documents to our
answer okay now we're going to talk
about again comparing documents to our
question so that's kind of the third
type of evales that are very common in
Rag and you know again you'll see that
we're just going to use a line chain
string of valuator just like before um
and that makes sense because we're
comparing a question which is a string
to retrieve documents which are
strings um and you'll see previously we
used again up here the label score
string evaluator uh for comparing our um
answer to our uh context or this is you
know again the hallucination test here
comparing our context to the question
we'll just use a score string evaluator
and this and that's just simply because
we don't actually have kind of a ground
truth or reference for this particular
case uh we have a question and we have
retriev documents and so those are
really the only two entities that we
care about evaluating here um and you
can actually look at the prompt we use
for evaluation I already have it open
here basically it's pretty simple we
Supply some criteria there's your input
question and then there is a prediction
and this prediction is a placeholder it
can be retrieve documents it can be any
kind of answer that we want right um so
again it's just basically a two-part
evaluation comparing our input to a
prediction given some criteria so that's
nicely suited for this problem because
in this case we only have an input
question and retrieve
documents um so that's really all we
need to cover here and you can kind of
see in the information flow kind of it
follows what we showed previously where
we have our examples in blue here so
from the examples we simply just fish
out the question that's the input and
then we pass in the question to our rag
chain we get we perform retrieval so we
get these documents out so then those
documents are just a prediction so again
we're mapping from our question is our
input the context are then are is our
prediction um and again you recall that
every line chain string of valer just
simply has a few different common Keys
input prediction and reference if
applicable in this case we don't have a
reference um and so here we're actually
just going to Define our evaluator this
follows a lot of what we did previously
so we're using the score string
evaluator but in this case because we
don't have a reference our criteria is
just simply something like this this is
an answer a set of um documents
retrieved from a vector store the input
is a question used for retrieval score
whether documents are relevant to the
input and then we give some normal
ization criteria um you know zero means
that none of none of them are relevant
five means some are relevant 10 means
they're all relevant so that's all we
need to do here we can Define our
evaluator now again we're use the same
eval set we did before so it's rag test
LC um we can kick that off so we've just
kicked off for
evaluation and we'll let that run for a
little bit so we can kind of go over and
we can look at our eell set so again you
can see here is our examples these are
the input output pairs here's all the
experiments we've run uh so this is the
newest experiment that we just and we
can see that open up our
experiment and if you go to this display
you can choose what metrics you actually
want to show so in this case we can
choose to toggle on or off the eval
scores in this case we're going to show
our eval scores these are our accuracy
scores from that comparing our input to
the uh the input question to the re
documents and here we can just open this
up we can actually look at the prompt
itself to assess the grading so here was
the grer chain um and you can see it
follows the prompt that we showed here
you know basically the question ins
start of the assistant's answer in this
case you can see the assistant's answer
has the retriev documents plummed in
there um and you can see the question is
here and you can see you know gives a
very nice kind of detail explanation as
to its scoring in this case it scores it
as a 10 the assistant response is
relevant to the user's question um we
can look at some of the other ones we
can see you know the scoring is is a bit
more variable so in this case it only
scores as a.3 we can go we can kind of
sity check we can look at uh some of the
the reasoning for the scoring so anyway
this shows you very simply how to
instrument of retrieval evaluation using
in using ideas we talked already uh
about um except that we simply use the
scoring evaluator because we don't
actually have in this particular case
uh what you might call reference we're
only comparing two things in this case
we're comparing our our input question
to the retrieve documents as the
prediction so this shows you a third way
to run rag evaluations in this
particular case uh for document
relevance thanks
Browse More Related Video
![](https://i.ytimg.com/vi/IlNglM9bKLw/hq720.jpg)
RAG Evaluation (Answer Hallucinations) | LangSmith Evaluations - Part 13
![](https://i.ytimg.com/vi/yx3JMAaNggQ/hq720.jpg)
RAG (evaluate intermediate steps) | LangSmith Evaluations - Part 16
![](https://i.ytimg.com/vi/lTfhw_9cJqc/hq720.jpg)
RAG Evaluation (Answer Correctness) | LangSmith Evaluations - Part 12
![](https://i.ytimg.com/vi/O0x6AcImDpM/hq720.jpg)
Online Evaluation (RAG) | LangSmith Evaluations - Part 20
![](https://i.ytimg.com/vi/AVPflFmRkd4/hq720.jpg)
Single Step | LangSmith Evaluation - Part 25
![](https://i.ytimg.com/vi/zMgrHzs_cAg/hq720.jpg)
Summary Evaluators | LangSmith Evaluations - Part 11
5.0 / 5 (0 votes)