Custom Evaluators | LangSmith Evaluations - Part 6

LangChain
8 Apr 202406:16

Summary

TLDRこの動画スクリプトは、シリーズの第6回目の動画であり、長評価について焦点を当てています。動画では、評価が重要である理由、Langs Smith Primitivesの基礎、データセットの構築方法、開発者によるデータセットのカスタマイズ、ユーザーログからのデータセットの構築、評価器の使用方法について説明しています。特に、カスタム評価器の作成方法について詳細に説明しており、シンプルなアサーションに基づいた機能テストを通じて、システムが正しく動作していることを確認する方法を提案しています。

Takeaways

  • 📈 シリーズの第6回目の動画で、長評価について焦点を当てています。
  • 🌟 評価の重要性を説明し、Langs Smith Primitivesの基礎を築きました。
  • 🛠️ データセットの構築方法を学び、Databricksを使用してカスタマイズしました。
  • 📝 質問と回答のデータセットを作成し、編集と追加の方法を紹介しました。
  • 🔍 ユーザーログからデータセットを構築し、フィードバックや質問をプラグインする方法を説明しました。
  • 🧠 生成されたデータセットを使用して、ビルトインのライフチャイン評価器を用いてアプリを評価しました。
  • 🤖 GDP-35を使用して質問に答え、手作業でキュレートされたデータセットと比較しました。
  • 💡 カスタマイズされた評価器を作成し、答えが生成されたかどうかを確認する単純なアサーションを設定しました。
  • 📊 評価器は、答えが存在するかどうかを判断し、単位テストのような機能を有する非常简单なアサーションです。
  • 🔧 カスタム評価器を構築する際には、出力を抽出する能力が必要です。
  • 🎯 カスタム評価器は非常に柔軟で、任意のスコアリング方法を選択できます。
  • 📖 情報フローを理解し、例と実行の出力を利用することで、カスタム評価器の構築は非常に簡単です。

Q & A

  • ビデオ_SERIESの主題は何ですか?

    -ビデオ_SERIESの主題は、言語評価に関するものです。

  • 最初のビデオは何を説明していますか?

    -最初のビデオでは、評価が重要である理由について説明しています。

  • Langs Smith Primitivesとは何ですか?

    -Langs Smith Primitivesは、データセットの構築に使用される基本的な要素です。

  • データセットの構築方法について説明するビデオは何ですか?

    -3番目のビデオがデータセットの構築方法について説明しています。

  • Databricksとは何ですか?

    -Databricksは、データ分析と機械学習のためのプラットフォームです。

  • Databricksモデルを使用した質問回答データセットの構築方法について説明するブログ記事のリンクはどこにありますか?

    -ブログ記事のリンクは、ビデオのスクリプトの途中部分に示されています。

  • ユーザーログからデータセットを構築する方法について説明するビデオは何ですか?

    -4番目のビデオがユーザーログからデータセットを構築する方法について説明しています。

  • 評価器とは何ですか?

    -評価器は、アプリケーションの性能を判断するために使用されるツールです。

  • GPT-35とは何ですか?

    -GPT-35は、OpenAIによって開発された自然言語処理のモデルです。

  • カスタム評価器を作成する場合、どのようなアサーションを使用することができますか?

    -カスタム評価器を作成する場合、答えが生成されたかどうかを確認するようなシンプルなアサーションを使用することができます。

  • カスタム評価器を構築する際の主な利点は何ですか?

    -カスタム評価器を構築する主な利点は、非常に柔軟で、任意の評価方法を適用できることです。

  • このビデオ_SERIESで説明された評価方法の適用範囲はどこまでですか?

    -このビデオ_SERIESで説明された評価方法は、オフライン評価やCIなど、様々な場面で適用可能です。

Outlines

00:00

📝 評価方法の紹介とカスタマイズ

この段落では、シリーズの第六回目の動画として、評価方法について説明しています。最初の動画で重要性を述べ、二つ目の動画ではLangs Smithの基本原則を紹介しました。次に、データセットの構築方法について学び、Databricksモデルを使用して質問と回答のペアを編集し、追加する方法を示しました。さらに、ユーザーログからデータセットを構築する方法も紹介しました。そして、ビルトインのライフEvaluatorを使用して、シンプルなアプリを評価する方法を学びました。このアプリは与えられた文脈についての質問に答えることができます。GPD-35を使用して応答し、手動でキュレートされたデータセットと比較しています。

05:02

🔍 カスタマイズされた評価器の構築と活用

この段落では、独自の評価器を構築し、アプリの応答をテストする方法について説明しています。カスタマイズされた評価器は、答えが生成されたかどうかを確認するシンプルなアサーションです。これは、エミュレーションされたデータセットから質問と回答のペアを削除し、ハードコードされた判断基準(回答があるかどうか)を使用します。この方法は、単純な機能テストとして考えることができます。この場合、評価は使用されず、代わりにシンプルなアサーションが使われます。この関数は非常に簡単で、例として示しています。

Mindmap

Keywords

💡Langs Smith Primitives

Langs Smith Primitives は、ビデオのシリーズで取り上げられる基本的な概念や要素です。これには、データセットの構築や評価器の使用などが含まれます。ビデオでは、これらのプリミティブを用いて、質問と回答のデータセットを作成し、評価する方法について説明しています。

💡データセット

データセットは、ビデオの主題を理解するための重要な概念です。これは、機械学習や自然言語処理の分野で使用される一連のデータのことであり、この場合は質問と回答のペアを含んでいます。データセットは、モデルの訓練や評価に不可欠なものであり、このビデオではデータセットの構築方法や使用法について詳細に説明されています。

💡評価器 (Evaluator)

評価器は、ビデオの主なテーマの一つであり、モデルのパフォーマンスを測定するツールです。このビデオでは、既存の評価器(例えば built-in life with evaluator)だけでなく、カスタム評価器の構築方法についても説明されています。評価器は、モデルが生成した答えの品質や正確さを判断するために使用されます。

💡GPD-35

GPD-35 は、ビデオで取り上げられた技術的な用語であり、特定の世代のモデルや応答を指しています。このビデオでは、GPD-35 世代の答えをデータセットと比較して、モデルのパフォーマンスを評価する方法について説明されています。

💡カスタム評価器

カスタム評価器は、ビデオの後半で重点的に取り上げられた概念であり、既存の評価器とは異なり、開発者が特定の基準に従って作成する評価器のことです。この場合、評価基準は答えが生成されたかどうかという単純なアサーションに基づいており、これはユニットテストのようなものとして考えることができます。

💡アサーション

アサーションは、プログラムが特定の条件を満たすと期待していることを表すステートメントです。このビデオでは、アサーション用于カスタム評価器の例として取り上げられ、答えが生成されたかどうかを確認する単純な機能を示しています。

💡ユニットテスト

ユニットテストは、ソフトウェア開発において、個々のコンポーネントが正しく機能することを確認するために行われるテストの一種です。このビデオでは、カスタム評価器をユニットテストとして使用し、システムが正しく動作していることを確認する手法として紹介されています。

💡情報流 (Information Flow)

情報流は、データや情報がシステム内においてどのように移動するかを示す概念です。このビデオでは、評価器がどのように動作するかを理解するために、情報流の概念が重要です。例えば、アプリからの出力を評価器に渡し、答えが生成されたかどうかを確認する処理の流れが説明されています。

💡スコア付け (Scoring)

スコア付けは、評価器がモデルの出力を評価し、その品質や正確さを数値で表すプロセスです。このビデオでは、カスタム評価器を使用して、答えが生成されたかどうかに基づいてスコアを割り当てる方法について説明されています。

💡flexibility

柔軟性は、システムやプロセスの適応性や変化への対応能力を指す概念です。このビデオでは、カスタム評価器の構築において、柔軟性が重要であり、開発者は様々な方法で答えの品質を評価することができます。

💡メタデータ (Metadata)

メタデータは、データに関する情報であり、この場合は、評価結果に関するデータです。ビデオでは、新しいカスタム評価器を作成する際にメタデータの作成について言及されており、これは評価結果を理解しやすくするための重要な要素です。

Highlights

视频系列的第六部分专注于长度评估。

第一个视频解释了长度评估的重要性。

第二个视频介绍了核心Langs Smith Primitives。

第三部分讨论了如何构建数据集,特别是开发者策划的数据集。

展示了如何为Databricks构建一个问答数据集。

介绍了如何编辑和追加示例到数据集中。

展示了如何从用户日志构建数据集。

讨论了如何使用评估器,特别是在构建的问答应用中的内置Life with Evaluator。

使用GPD-35生成的回答与手动策划的数据集进行比较。

提出了构建自定义评估器的想法,例如简单的断言来检查答案是否生成。

介绍了自定义评估器的构建方法,强调了其灵活性和简便性。

自定义评估器是基于标准的评分,例如答案的存在与否。

讨论了自定义评估器可以用于离线评估,类似于持续集成中的测试。

通过一个简单的函数示例,说明了如何实现自定义评估器。

强调了自定义评估器的强大和通用性,以及它在实践中的便利性。

Transcripts

play00:00

hi this is lash BL chain this is a sixth

play00:02

video in our series um focus on langth

play00:05

evaluations so in the first video we

play00:08

just kind of laid out why are important

play00:10

the second video we laid out the core

play00:11

Langs Smith Primitives we then talked

play00:13

about how to build data sets um first

play00:16

developer curated we built one for the

play00:18

datab bricks um The datab Brick model

play00:21

which is discussed in this blog post so

play00:22

we built a question answer data set um

play00:26

and we showed how to edit that we showed

play00:27

how to append um example to it we then

play00:31

also showed how to build data sets from

play00:33

user logs so if you like an app in

play00:34

production you're you know getting

play00:36

feedback questions from user you can

play00:39

basically Plum those into a data

play00:41

set um we then just talked through how

play00:44

to use an evaluator uh in our particular

play00:47

case uh built-in life with evaluator to

play00:50

judge our app which we built here so we

play00:54

a very simple app that answers questions

play00:55

about a given context and Es case be

play00:57

plunged in the blog post and we're using

play00:59

G GPD 35 to answer questions we're

play01:01

comparing those GPD 35 uh Generations or

play01:05

or answers to our data set which was

play01:08

manually curated so that's really it we

play01:11

used uh a built-in L with evaluator

play01:14

called coot QA which is very convenient

play01:16

for question answering so that's kind of

play01:18

where we are that's what we did now

play01:20

let's build on this a little bit and

play01:22

this kind of gives you a summary of what

play01:23

we just

play01:25

did now let's say I want to do something

play01:27

different I want to find my own custom

play01:29

evaluator

play01:31

so let's say I want like a simple

play01:33

assertion that act an answer actually

play01:35

was generated or not like was there some

play01:37

kind of like um you know failure in in

play01:40

in generation of the answer so that you

play01:42

know to turn some an empty string or or

play01:44

you know uh there can be other reasons

play01:46

why and L1 Sals to produce a generation

play01:49

right so in this case I'm changing it up

play01:51

a little bit I stole my data set a

play01:54

question answer pairs dered from that

play01:55

data post but in this case I want my

play01:58

graders to be it's like I you're the

play02:00

hardcoded decision it's just like is

play02:02

there an answer or not right it's

play02:04

reference free there isn't like a ground

play02:05

truth there it's just like is there an

play02:07

answer or not right so it's more like

play02:08

criteria based uh grading in this case

play02:11

you can this is where it's a little bit

play02:12

squishy because you think of this more

play02:14

as a unit test it's a very simple

play02:16

assertion for functionality um as

play02:18

opposed to it being an evaluation which

play02:20

is using like an LM as a judge or human

play02:22

as judge this is just like a quick test

play02:25

is there an answer present or not and of

play02:27

course this can be used you know in

play02:28

offline evaluation potentially like Ci

play02:30

right so it's like a nice test or sity

play02:32

check that my system's actually working

play02:34

so how would I do that so it's actually

play02:36

really

play02:37

simple this little function is actually

play02:39

all you need but let me actually explain

play02:43

a bit about what's going on here

play02:45

remember our flow diagram let's actually

play02:47

go back up so there's this run and

play02:50

there's an example so the run is my app

play02:54

basically my app as some output right so

play02:57

the Run has this do output which is

play03:00

basically the the dict or the object

play03:02

that comes out of my app and then

play03:04

likewise my example which I pass an

play03:07

evaluator also has this dot outputs

play03:09

which is basically everything that's

play03:11

available to the example in my

play03:13

particular case what I'm going to care

play03:14

about is you know in typical evaluations

play03:16

I often care about just the answer but

play03:18

the point is uh when I'm doing

play03:21

evaluation there's this example object

play03:23

and if this run object and these two

play03:25

things are being compared in some way so

play03:28

that's really it so remember I have an

play03:29

example and a run now if I build my

play03:31

custom

play03:32

evaluator I plum in that example and run

play03:35

just like we just talked about and I

play03:37

could just easily fish out from the run

play03:40

which is my llm app I want to get the

play03:42

answer now let's actually go all the way

play03:44

back up and make sure we understand what

play03:46

we just said so I'm going to go back to

play03:48

my app here's my little app answer data

play03:51

ver question open AI it returns a dict

play03:54

with this answer key that's where me get

play03:56

that answer thing from so that key

play03:58

depends on my app in this case my app

play04:00

returns you can see it's it's a dict

play04:03

with answer in it that's it so that's

play04:05

why in my custom evaluator when I go

play04:07

down here I just go to my outputs from

play04:10

the run again it runs my app the outputs

play04:12

contains everything output by the app in

play04:14

that case that output is a dict but has

play04:16

a key answer so I'm fishing it out like

play04:18

that and I do something really easy if

play04:20

there's nothing there then it's not

play04:22

answered otherwise it is as simple as it

play04:25

gets remember I have this data set dbrx

play04:28

I'm going to run on this so again here's

play04:31

my app basically we already talked about

play04:33

this here's the data set we already

play04:34

showed how to build that this is my new

play04:36

little evaluator is answered um I'm

play04:39

going to create a new prefix for it uh

play04:41

it's some new metadata kick that off

play04:43

that should run pretty quick and I can

play04:46

go over to my data set it's already done

play04:48

so okay this is kind of interesting so

play04:50

now you see two evaluations the first

play04:52

one we show previously using the

play04:53

built-in uh light chain evaluator now I

play04:57

had this new one you can see it has this

play04:58

new prefix and let's open it up and see

play05:01

so in this case those scores are all one

play05:04

because there is an answer every time

play05:06

that's it that's a custom evaluator it

play05:08

shows up here in Langs Smith this

play05:11

scoring is arbitrary we can choose

play05:12

different means of scoring but in this

play05:14

particular case I just chose one or zero

play05:16

shows up here that's it pretty simple um

play05:20

and this is extremely flexible I mean

play05:22

this is just a function it can be

play05:23

anything you want again all you need is

play05:25

the ability to fish out your

play05:27

output you could do string matching

play05:29

could do arbitrary different kinds of

play05:31

evaluations and you can also include for

play05:33

example llms in this to do arbitrary

play05:37

reasoning over your answers and produce

play05:38

scores so I've used this a whole lot

play05:41

it's extremely convenient very flexible

play05:44

and building customer values is

play05:45

extremely simple particularly once you

play05:47

understand that kind of that information

play05:50

flow we showed here all that's happening

play05:52

is I have an example I have a run each

play05:55

of those has this outputs thing which

play05:57

gives you access to in the case of my

play05:59

run

play06:00

that output object in my case it was

play06:01

just a dict with answer and this do

play06:03

outputs actually gives you access to

play06:05

everything in this example that's really

play06:07

it that's all I need to know um and

play06:10

that's really all all I want to say

play06:12

about building custom valuers it's very

play06:13

powerful and very general thanks

Rate This

5.0 / 5 (0 votes)

Related Tags
LangChain評価方法カスタムエバリュエイターデータセットQuestAnswerプログラムアサーション機能テスト柔軟性情報フロー
Do you need a summary in English?