Backtesting | LangSmith Evaluations - Part 19
Summary
TLDRランチェインのLanceが、バックテストに焦点を当てた評価シリーズを紹介しています。プロダクションアプリのログを活用し、新しいアプリのバリアントをテストする方法を説明しています。例えば、ベクターストアを使用する「gbd4 Turbo」アプリを例に、コンテキスト詰め込みを試して比較する方法を紹介しています。ユーザーからの実際の質問をもとに、データセットを作成し、異なるアプリバリアントを評価し、比較評価を行う方法を解説しています。このプロセスは、プロダクションアプリを改善し、新しい機能をテストするのに非常に便利なワークフローです。
Takeaways
- 🔧 これは「Lang chain」というツールを使用して、アプリのバックテストに関する評価シリーズを紹介するビデオスクリプトです。
- 🛠️ スクリプトでは、既存のプロダクションログを利用して、新しいアプリのバリアントをテストする方法を説明しています。
- 📈 「gbd4 Turbo」という特定のRAGアプリについて話しており、これはベクターストアを使用してプロダクションで動作しています。
- 🔄 「コンテキスト詰め込み」という新しいアプリバリアントをテストする際に、プロダクションログを再利用することができると強調しています。
- 📝 テストのために、プロダクションからのユーザーデータを直接使用し、データセットとして利用することができると説明されています。
- 🔧 スクリプトでは、新しいプロジェクト「バックテスト」を作成し、ユーザーからの質問を通してアプリをテストするプロセスを紹介しています。
- 📑 「バックテスト V2」という新しいデータセットを作成し、ユーザーログをもとにした評価を実行する方法が説明されています。
- 🔄 新しいアプリバリアント「predict Rag」と「ser gbd4 turbo」を使用して、既存のプロダクションアプリと比較する評価を実行しています。
- 📊 ペアワイズエバリュエーターを使用して、新しいアプリバリアントとプロダクションアプリの出力を比較評価する方法が紹介されています。
- 📝 スクリプトでは、コードの質問に対する回答の品質を評価するための基準を設定し、評価プロンプトを作成する方法も説明されています。
- 🔎 最後に、新しいアプリバリアントとプロダクションアプリの比較評価を行い、どちらが優れているかを詳細に分析しています。
Q & A
ランチェインのバックテストとはどのようなプロセスですか?
-ランチェインのバックテストとは、既存のアプリのバージョンが収集したユーザーデータを使用して、新しいアプリのバリアントを実行し、その出力を比較するプロセスです。これは、異なるバリアントを試してアプリを改善するのに非常に便利な方法です。
なぜバックテストはアプリ開発において重要な役割を果たしますか?
-バックテストは、既存のアプリのパフォーマンスを評価し、新しいバージョンが改善点を提供しているかどうかを判断するのに役立ちます。これにより、開発者はより良いユーザーエクスペリエンスを提供するためにアプリを最適化できます。
ランチェインのフレームワークにおけるデータセットとは何を意味しますか?
-ランチェインのフレームワークにおけるデータセットとは、実際のユーザーデータから収集されたログを指します。これらは、新しいアプリのバリアントをテストする際に使用されるデータセットとして活用されます。
新しいアプリバリアントをテストする際に、どのようにしてユーザーデータをデータセットに変換するのですか?
-ユーザーデータは、ランチェインのフレームワークで提供される特定のコードを使用して、新しいデータセットに変換されます。これにより、ユーザーの入力がデータセットの入力として使用され、新しいアプリバリアントをテストすることができます。
バックテストで使用する新しいアプリバリアントの例として、コンテキストスティッキングとは何ですか?
-コンテキストスティッキングは、ベクターストアを使用する代わりに、すべてのドキュメントをLLMに渡す方法です。これにより、正しいドキュメントチャンクのリトリーブに関する問題が回避され、すべての情報が一度に提供されます。
バックテストの結果を比較するために使用される対比評価とは何ですか?
-対比評価は、2つの異なるアプリバリアントの出力を比較し、どちらが基準に基づいて優れているかを判断するプロセスです。これは、新しいバリアントが現在のプロダクションバージョンよりも優れているかどうかを判断するのに役立ちます。
ランチェインフレームワークで新しいプロジェクトを作成する際に、どのようにしてプロジェクトを識別するのですか?
-新しいプロジェクトは、名前とバージョン番号を使用して識別されます。例えば、「バックテスト V2」のように、プロジェクト名とバージョン番号を組み合わせて一意のプロジェクトを作成します。
バックテスト中にランチェインフレームワークで実行された評価とはどのようなものですか?
-バックテスト中に実行された評価は、新しいアプリバリアントのパフォーマンスを測定し、特定の基準に基づいてそのパフォーマンスを評価します。これは、新しいバリアントが期待通りに機能しているかを確認するのに役立ちます。
バックテストのプロセスで、どのようにして生産性向上に貢献するのですか?
-バックテストは、既存のユーザーデータを再利用することで、新しいアプリバリアントを迅速にテストし、改善することができます。これにより、開発者は時間を節約し、より迅速にアプリを最適化してユーザーに提供できます。
バックテストを使用して、どのようにしてアプリの品質を向上させるのですか?
-バックテストを使用して、新しいアプリバリアントを実際のユーザーデータでテストし、そのパフォーマンスを比較評価します。これにより、アプリの品質向上に必要な具体的な改善点を見つけ出し、実装することができます。
バックテストの結果を分析する際に、どのような基準を使用するのですか?
-バックテストの結果を分析する際には、コードの答えが問題のクリアオーバービューを含んでいるか、コードのインポートや解決策が含まれているかなどの基準を使用します。これにより、どのバリアントがより優れた結果を提供しているかを判断できます。
Outlines
🔍 バックテストのプロセスと目的
ランスは、Lang chainの評価シリーズを続け、バックテストに焦点を当てています。彼らのプロダクションアプリ、gbd4 Turboを使用してベクターストアを利用していますが、新しいバリアントを試すために、既存のプロダクションログを利用してテストすることができます。これにより、新しいアプリバリアントを既存のユーザーデータでテストし、出力を比較することができます。このプロセスにより、新しいアプリバリアントを効率的に評価することができます。
📈 バックテストによるアプリバリアントの比較
ランスは、プロダクションログから新しいデータセットを作成し、それを使用して新しいアプリバリアントをテストしました。彼は、gbd4 Turboという新しいバリアントを使用して、コンテキストの詰め込みを行っており、ベクターストアを使用する基本バージョンとは異なるアプローチをとっています。その後、新しいペアワイズ評価プロンプトを作成し、生産バージョンと新しいバリアントの出力を比較しました。評価結果は、新しいバリアントの方が優れていると示しました。
🙌 バックテストの利点とプロセスの概要
ランスは、プロダクションで動作しているアプリのログを取得し、それらをデータセットに変換することで、バックテストを行うことができます。これにより、異なるバリアントをテストし、プロダクションに投入する前に比較的簡単に比較評価を行うことができます。このプロセスは、プロダクションで動作しているアプリケーションに対して新しいバリアントをテストする際に非常に便利です。
Mindmap
Keywords
💡Lang chain
💡バックテスト
💡プロダクションログ
💡データセット
💡アプリケーション変種
💡コンテキスト詰め込み
💡ペアワイズエバリュエーター
💡コード質問応答
💡エクスペリメント
💡比較評価
Highlights
Lance from Lang chain discusses back testing different app variants using production logs.
Motivation for back testing involves trying a new variant like context stuffing instead of using a vector store.
Production logs can be utilized to create a dataset for testing without needing a curated dataset.
Back testing allows for the comparison of new app variants against the current production version.
Lance creates a new project called 'back testing' to evaluate the new app variant.
User interactions with the app are simulated and used to generate a dataset for testing.
Traces from the app are taken and turned into a new dataset for evaluating the app variant.
A new experiment is initiated using a different app variant without a vector store.
The new experiment is named 'predict Rag and ser gbd4 turbo' which uses context stuffing.
The initial experiment serves as the production baseline for comparison.
A pairwise evaluator is used to compare the outputs of the baseline and the new variant.
Criteria for evaluation include clarity, code import, and code solution.
The pairwise evaluation provides a detailed comparison and preference between the two app versions.
The workflow allows for easy back testing of production apps with different variants.
Back testing can be highly convenient for testing different chains before putting them into production.
The process concludes with a comparative assessment using the pairwise evaluator.
Transcripts
hi this is Lance from Lang chain we're
continuing our Langs Smith evaluation
series focused on back testing today so
to to motivate this let's say we had an
app in production uh say for example
it's one of our rag apps that we kind of
talked about in some prior videos um and
the particular rag app uh in our case is
gbd4 Turbo using a vector store so
that's in production we're collecting
production traffic from users based
using this app version now what happens
if we want to try different variant like
let's say I want to try context stuffing
rather than using my Vector store um one
really convenient and nice thing to be
able to do there is take a bunch of
production logs we've already collected
and just run my new app variant on them
and see how the output Compares right
that's a really common thing you might
want to do so if you look at our
framework here we're talking about the
data set actually can come from existing
production logs that's really convenient
we don't have to build some like curated
data set from it we can just take user
data that actually has been you know
contributed to our existing app and turn
that into a data set so that's step one
and we can test then a different app
variant on those same inputs so that's
really useful and we can use like a
pairwise evaluator compare our new
variant of the app to our old or
production version that's running
currently so that's like a common
workflow now let's walk through this so
I'm going to create a new project I'll
call it back testing I'll create a a new
one here back testing let's say
V2 um and here's my app so let's say
this is running a production here here's
a few user questions related to L chain
expression language so if you call this
particular app um is actually ingesting
information about Lang and expression
language and um so these are all running
cool so we can just kick a few of these
off um
great so I've run five different uh user
questions uh through my app now assume
this is you know obviously we're doing
the notebook but assume this is a
production app it's it's just out there
these are users interacting with your
app right so that's what we're
simulating here now I've created this
project back testing V2 we can go over
to limith um I can look at my projects
page and it's here and so great so
here's all my traces they're all logged
here so that's
fantastic um now what I can do is this
code right here will take these traces
so I can specify my like my my run
filters in terms of like start and end
time um and I can choose the project
that I want to grab from so in this case
it's this project we just logged to and
basically what we can do here is I can
create a new data set so I'm taking
these user logs effectively right here
and what I'm do is I'm turning them into
a new data set so now we'll see if you
go over to our data sets page we have
this new data set called backing V2 and
it has like the exact time and so forth
and what you'll see here is pretty nice
um those user inputs are now just simply
inputs in my data set so I've kind of
sucked them into a data set that's all
I've done now what I can do here is I
can run an evaluation on the states that
we just created using a different Vari
into my app so I'll call this this
predict Rag and ser gbd4 turbo is a
different app variant this particular
variant doesn't use a vector store it
does context stuffing um which we can
talk about a little bit later but let's
say kick off that evaluation so I run
that right now so if I can I can go back
to my data set here we can see a new
experiment has been kicked off and
what's pretty cool about this when I
create this data set my initial
experiment is the prod Baseline so
that's basically my production app that
we've been using that we logged from um
and that is actually what we collected
our our inputs and our outputs initially
from so this is kind of like our
Baseline right this is our inputs these
are outputs from that Baseline version
we looked at initially now I've just run
a new experiment using our variant right
so this a gp4 turbo so it's what I just
kicked off and this is running now you
can see it's still
running um you can see kind of the name
here my experiment prefix gp4 turbo and
that is what uh you can see here so gb4
turbo that's great so that's all
running and we can check and see the
state of that experiment looks like it's
still
going um cool so there's one more to
go and it looks like it's done so that's
great so now we are finished so here's
where things get kind of interesting so
I've run so maybe just back up what do
we do here so if I go all the way back
first I had a project that I was logging
to so this is simulating um for example
like a a production app and these are
user user interactions that are being
logged to some particular project what
I've done is I've taken these these
these input and output Pairs and I've
pulled them into a new data set and you
can see that right here I suck those in
and by default when I do that that
Baseline is grabbed as my prod Baseline
so this is what my production app inputs
and outputs now what's cool is I was
able to just run a new experiment with
my new app version on those same user
inputs but now I have my new output so
these are the outputs for my new chain
so that's great now this all comes
together in kind of a cool way because I
can use a pairwise evaluator to compare
them so I just created a new pairwise
evaluation prompt for this particular
task and I I think I already have it
open here great so this particular task
if you recall is code question answering
based on the Lang expression language
documentation so I set up my pawise
prompt and I just say you know previous
act as a judge to evaluate the quality
of of code responses from two assistants
um related to Lang Str language I give
my criteria here begin your evaluation
comparing the responses based upon do
they contain a clear overview of the
problem do they contain code import they
contain code solution right um so you
don't allow length to affect the results
and so forth so anyway that's my
evaluation prompt now I've I can Define
this pairwise Valor we just already
talked about this in the last video so
you've already seen a good example of
that I'm creating a pawise evaluator
right here and what's pretty cool is I
can run that pawise evaluator on my two
experiment so this is my this is the
name of my most recent experiment it's
gp4 turbo boom and my initial experiment
I can go back and get that name so it's
this prod Baseline so I can just plug
those
in
okay so I'm running a comparative
evaluation between my prod Baseline and
my new app variant that I ran back
testing on I kick that off so now this
is running and of course it's going to
be logged to the same overall uh data
set here so if I go back to my data set
recall we had two experiments my prod
Baseline my back testing which is
running those same prod inputs with my
new chain gp4 Turbo with context
stuffing um and now I've kicked off an
experiment that's comparing the two so
it's comparing my prod Baseline versus
my new variant gbd4 Turbo with context
stuffing versus the the Baseline if you
recall is actually using retrieval from
a vector store um the varant is actually
using gbd4 uh Turbo with context
stuffing the entire lell docs into the
um into the llm which has some benefits
over retrieval because uh you don't have
issues related to retrieval of the
correct document chunks uh you're just
passing in everything and so there's
some benefits there that we could talk
about at length uh different time so
this is running and it looks like it
might be finished this is done and this
is pretty cool so I can go I can go here
I can look at here's all the inputs here
was my prod Baseline here is my variant
this is what I ran back testing on and
what's pretty neat about the pair wise
value we can really see the preference
and so in this particular case it
prefers the output from our variant over
the Baseline and again just as we saw in
the previous video we can actually click
into here and investigate why so you can
go to the evaluator and it actually
gives you an explanation as to why so
anyway you can really dig into this but
this is a pretty nice workflow so if we
Zoom all the way back out what did we
really do here uh well we had an
example of an app running in production
this is kind of simulation of that we
collected five user inputs we turned
those into a data set that's what we did
here we then ran what we call back
testing on that data set with a new app
variant so like I want to test the new
app version in this case my Baseline
used retrieval from a vector store my
new app variant used context stuffing so
I ran that uh
evaluation and then I so then that that
resulted in a
generation um so that's right here for
every input I produced a new generation
or output from my variant that's great
and then I ran this comparative eval
saying hey which one's better here's my
prompt and I kicked that off I just
added the names of the two experiments
and as we saw before you get this pretty
nice comparative assessment with
detailed evaluation so pretty useful
thing to do if you have any app running
in production you can pretty easily grab
those production logs turn them into a
data set do back testing on them with
like different variants different chains
you want to test and you can even do
things like pairwise evaluation to say
hey which one's better or worse based on
some criteria that I can Define so
really nice workflow highly convenient
um for um kind of testing at testing
different variants of of chains that you
want to do you want to put in production
thanks
浏览更多相关视频
Regression Testing | LangSmith Evaluations - Part 15
Evaluations in the prompt playground | LangSmith Evaluations - Part 8
RAG Evaluation (Document Relevance) | LangSmith Evaluations - Part 14
Dataset Splits | LangSmith Evaluation - Part 22
RAG Evaluation (Answer Hallucinations) | LangSmith Evaluations - Part 13
Eval Comparisons | LangSmith Evaluations - Part 7
5.0 / 5 (0 votes)