Controlling Agents with Step-by-Step Execution (Part 5, Introduction to Agents)

LlamaIndex
15 Apr 202409:17

Summary

TLDRこの動画では、より細かい粒度でエージェントをステップバイステップで制御できる「ステップバイステップ制御レベルAPI」について解説しています。低レベルAPIにより、タスクの作成と実行が分離され、各ステップと次に来るステップを確認できます。エミュレーションの実行方法とステップバイステップ実行の違いを示し、応答の各ステップを確認する方法を説明します。また、データの読み込みやインデックス作成、クエリエンジンの設定など、高度なプロセスをステップバイステップで実行する方法も紹介しています。

Takeaways

  • 🤖 ステップバイステップで制御できるエージェントの紹介:低レベルAPIを使用して、より詳細にエージェントを制御できます。
  • 🔍 タスクの作成と実行が分離されているため、各ステップと次のステップを確認できます。
  • 📈 直接実行とステップバイステップ実行の比較で、実行の違いを実感できます。
  • 🚀 関数呼び出しエージェントとリアクションエージェントの両方でステップバイステップで制御できるエージェントを使用できます。
  • 📚 ノートブックでは関数呼び出しエージェントを使用して、ステップバイステップの実行方法を示しています。
  • 🔢 演算の例として、20 + 2 * 4 - 8 の計算を通じて、ステップバイステップの実行方法を説明しています。
  • 📊 データの分析に例として、R&D費用と収益の変化を分析する方法を説明しています。
  • 📆 3月、6月、9月のUberの文書を用いて、データの読み込みと索引の作成方法を紹介しています。
  • 🛠️ ステップバイステップで実行する際には、各ステップの出力を確認し、最終的なLLM応答を受け取ります。
  • 🔄 ステップバイステップの実行中に、人間によるフィードバックを追加することができます。
  • 🔍 ステップが漏れている場合でも、人間がフィードバックを追加して正しい方向に導くことができます。

Q & A

  • ステップバイステップ制御レベルエージェントとは何ですか?

    -ステップバイステップ制御レベルエージェントは、より細かいアプローチでエージェントをステップスルーおよび制御できる低レベルAPIです。

  • タスクの作成とタスクの実行はどのように分離されていますか?

    -ステップバイステップ制御レベルエージェントでは、タスクの作成と実行が分離され、各ステップを個別に表示し、次のステップと一緒に確認できます。

  • ステップバイステップ実行とは何ですか?

    -ステップバイステップ実行は、一度に全てを実行するのではなく、各ステップを個別に実行し、確認することで、プロセスの理解やトラブルシューティングを容易にします。

  • リアクションエージェントと関数呼び出しエージェントのどちらがこのノートブックで使用されていますか?

    -このノートブックでは、関数呼び出しエージェントを使用していますが、リアクションエージェントも使用することができます。

  • 計算ツールを使用して何を実行できますか?

    -計算ツールを使用すると、基本的な計算機能(例えば、加算、減算、乗算など)を実行できます。

  • ステップバイステップ実行の利点は何ですか?

    -ステップバイステップ実行の利点は、プロセスの各ステップを個別に確認し、問題が発生した場所を特定し、適切な修正を行うことができることです。また、システムに人間フィードバックを追加することもできます。

  • データの読み込みとインデックス作成にはどれくらいの時間がかかりますか?

    -データの読み込みとインデックス作成には、それぞれのドキュメントのページ数が多いため、時間がかかることがあります。

  • R&D費用と収益の変化を分析するために、どのようなエージェントを作成しましたか?

    -R&D費用と収益の変化を分析するために、関数呼び出しエージェントを作成し、3月のツール、6月のツール、9月のツールを使用してクエリエンジンを定義しました。

  • ステップバイステップ実行中に人間フィードバックを追加するにはどうすればいいですか??

    -ステップバイステップ実行中に人間フィードバックを追加するには、各ステップの出力を確認し、必要に応じて入力としてフィードバックを提供することで可能です。

  • ステップバイステップ制御レベルエージェントを使用する際に、最後のステップを識別する方法は何ですか?

    -最後のステップを識別するには、各ステップの出力で「last」というフラグがfalseまたはtrueを返すかどうかを確認します。

  • このビデオスクリプトの目的は何ですか?

    -このビデオスクリプトの目的是、ステップバイステップ制御レベルエージェントの使い方と、それがどのように役立つかを説明することで、視聴者の理解を深め、応用方法を提供します。

Outlines

00:00

📚 ステップバイステップ制御のAPIエージェント

この段落では、RaviがLama indexから来て、ビデオでステップバイステップ制御のAPIエージェントについて説明しています。これは、より細かいアプローチでエージェントを通過し、制御できる低レベルAPIです。タスクの作成とタスクの実行が分離され、各ステップと次のステップを一緒に見ることができます。このノートブックでは、関数呼び出しエージェントを使用して、ステップバイステップ制御エージェントを示します。まず、通常の実行を実行して、ステップバイステップの実行との違いを理解します。次に、タスクを作成し、各ステップを実行し、最終的な結果を得ることができます。

05:01

🔍 データ分析のためのステップバイステップ実行

この段落では、Raviがデータ分析のステップバイステップ実行について説明しています。まず、データの読み込みとインデックス作成を行い、クエリエンジンを設定します。その後、March、June、Septemberの3つのツールを作成し、R&D費用と収益の変化を分析します。ステップバイステップ実行では、各ステップを個別に実行し、最終的な結果を得ることができます。また、ステップ間に人間のフィードバックを追加して、出力を変更することもできます。この方法で、ステップバイステップ制御エージェントを使用して、システムの出力を確認し、改善することができます。

Mindmap

Keywords

💡Stepwise Control

ステップバイステップ制御は、ビデオの主題である低いレベルのAPIを使用して、エージェントをより細かい粒度で操作およびステップを通して制御する方法です。この方法により、タスクの作成と実行が分離され、各ステップとそれに続くステップを視覚的に確認できます。例えば、演算子の順序を理解するために、一度に実行される代わりに、ステップバイステップで実行し、中間の結果を確認することが可能です。

💡API

API(Application Programming Interface)は、ソフトウェア間で通信を行うための規約や手続きのセットです。このビデオでは、低レベルのAPIを使用して、エージェントを直接操作および制御する方法について説明されています。APIを通じて、プログラム間のデータのやり取りや機能の利用が可能になります。

💡Function Calling Agent

ファンクションコールイングエージェントは、特定の関数を呼び出すことでタスクを実行するタイプのソフトウェア代理人です。このビデオでは、ファンクションコールイングエージェントを使用して、ステップバイステップで制御する方法が紹介されています。

💡Task Creation

タスクの作成は、新しいプロジェクトや活動を始める際に必要な一連の手順や作業を定義するプロセスです。このビデオでは、ステップバイステップ制御を行うために、まずタスクを作成し、その後にそれを実行する必要があります。

💡Execution

実行は、プログラムやタスクを開始し、その結果を得るプロセスです。このビデオでは、ステップバイステップでの実行が強調されており、各ステップを個別に実行することで、より詳細な制御が可能になります。

💡Calculator Functions

計算機関数とは、数値計算を行うための一連の関数またはメソッドのことです。このビデオでは、基本的な計算機関数を使用して、ステップバイステップ制御の例を説明しています。

💡React Agent

リアクターエージェントは、外部の入力やイベントに対する反応を行なうソフトウェア代理人です。このビデオでは、リアクターエージェントもステップバイステップ制御の対象となっていますが、具体的な例はファンクションコールイングエージェントを使用して説明されています。

💡Indexing

インデックス作成は、データベースや検索システムにおいて、効率的な検索を可能にするために、データにインデックスを付けることを指します。このビデオでは、大量の文書に関するデータをインデックス化し、検索エンジンを作成するプロセスが説明されています。

💡Query Engine

クエリエンジンは、データベースから必要な情報を検索し、取得するためのソフトウェアです。このビデオでは、インデックス化されたデータに対する検索を可能にするために、クエリエンジンを作成するプロセスが説明されています。

💡Human Feedback

人間フィードバックは、システムやプロセスに対して人間の判断力や知識を提供するものです。このビデオでは、ステップバイステップの実行中に人間がフィードバックを与え、システムの出力を変更することができることを示しています。

💡Final Response

最終応答とは、システムがすべての処理を完了した後の結果を提供することです。このビデオでは、ステップバイステップ制御を通じて、最終応答を取得する方法が説明されています。

Highlights

Introduction to stepwise control level agent, a lower level API for granular control of an agent.

Task creation and tax execution are separated, allowing for a detailed view of each step and upcoming steps.

Execution without stepwise shows a direct result, highlighting the difference when compared to stepwise execution.

Stepwise controllable agents are available with both react agent and function calling agent.

Demonstration of function calling agent in the notebook, with the option to experiment with the react agent as well.

Explanation of how to execute tasks directly and the difference in stepwise execution.

Importing required modules and setup of API key for the demonstration.

Creation of tools from calculator functions and setup for the function calling agent.

Execution of the agent directly showing the sequence of operations: multiplication, addition, subtraction, and final LLM response.

Stepwise execution demonstration, showing how to execute one step at a time and check for the last step.

Illustration of how step outputs can be checked and how the process continues to the next step.

Transition from demonstration with calculator functions to using rack tools with actual documents.

Loading and indexing of large documents, such as March, June, and September Uber documents.

Creation of query engine and definition of tools for each month's documents.

Direct execution of the agent to analyze changes in R&D expenditures and revenue.

Stepwise execution with rack tools, showing the process of calling each month's tool and getting outputs.

Inclusion of human feedback into the stepwise process to influence the direction and outcome of the agent's response.

Conclusion summarizing the use of stepwise controllable agents for experimentation and exploration.

Transcripts

play00:01

hey everyone Ravi here from Lama index

play00:04

um so in this video we'll look into uh

play00:07

stepwise control level agent so this is

play00:10

a low level lower level API um that

play00:13

allows you to step through and control

play00:15

an agent on a more uh granular approach

play00:19

so basically uh in these cases task

play00:23

creation and the tax execution are

play00:26

separated so so that you can view each

play00:30

step and uh together with the upcoming

play00:32

steps as well so we'll uh you can

play00:35

actually see the differentiation when

play00:37

you execute it directly without any uh

play00:39

stepwise execution and doing stepwise

play00:43

execution uh in this notebook so

play00:46

stepwise U controllable agents are uh

play00:50

available with both react agent and uh

play00:53

function calling agent uh in this

play00:55

notebook uh I'll show with the function

play00:57

calling agent but feel free to exper

play01:00

with the react agent as well so let's

play01:03

get started with

play01:06

it we'll import all the modules required

play01:11

uh

play01:12

setup API key uh we have all the usual

play01:18

uh calculator functions and we'll create

play01:22

the

play01:23

tools out of it and then uh we'll create

play01:27

the uh function calling agent as usual

play01:29

ual first we'll execute it directly

play01:32

without any stepwise execution so this

play01:35

will help you to understand the

play01:38

differentiation so here the result is 20

play01:41

like 20 + 2 * 4 - 8 so there is

play01:46

multiplication first and then addition

play01:48

and then

play01:49

subtraction and then a final llm

play01:52

response so um that's how it is executed

play01:55

right there are four steps uh one

play01:58

multiply then the addition then the

play02:01

subtraction and then the final llm

play02:03

response now let's see how you can do

play02:05

this stepwise rather than in one single

play02:08

go right so first step is to create this

play02:12

task this is the task and then we'll go

play02:15

with the uh executing the first step

play02:19

which is run step and then you get the

play02:23

one step

play02:25

output you can check the uh step output

play02:28

here you can see

play02:30

that this is not uh last step and what

play02:33

is the output what are the arguments

play02:36

what is output from this right all those

play02:41

things you can check the uh step output.

play02:44

e last which is false so that are steps

play02:47

ahead so run it again uh so you got the

play02:52

next step which is addition 28 you can

play02:55

check again whether it's last step or

play02:56

not this is not so run it again and then

play03:01

you can see that uh this is subtraction

play03:04

is done and then probably you check if

play03:07

this is the last step

play03:10

again um this is false right so you need

play03:14

to run it

play03:16

again so and the lrm response here it

play03:19

ends so and then finally you get a

play03:22

response right so here you can see what

play03:25

are all the different steps you can run

play03:27

through it uh by checking whether it's a

play03:30

last step or not and get a final

play03:32

response so this is more of lower level

play03:36

API agent API um uh that you can see

play03:39

what are the different steps going on um

play03:42

executing one step at a

play03:45

time okay we'll observe the similar

play03:48

thing with the rack tools as well so

play03:50

we'll consider uh uh March June and

play03:53

September Uber uh

play03:56

documents and uh let's load the data

play04:00

this will take some time uh because of

play04:02

the huge uh number of pages in each of

play04:05

the document and then we'll uh create

play04:08

index and tools um

play04:11

so we have a function to Define get the

play04:14

Tool uh this will uh create index and

play04:18

then uh create query engine and then

play04:21

Define the

play04:23

tool so let's do that and then let's

play04:28

create uh

play04:30

uh tools for uh March June and September

play04:34

and get the query engine

play04:37

tools now we'll uh create the agent and

play04:42

then first let's do the direct execution

play04:44

analyze the changes in R&D expenditures

play04:47

and revenue let's see how it works so

play04:52

think still it's loading the

play04:57

data we take a minute of time probably

play05:01

uh even indexing might take more

play05:05

time so let's

play05:08

see and then once it is executed so and

play05:12

then we can see the stepwise execution

play05:14

as well uh Again by creating the task

play05:18

and running one step at a time and

play05:20

checking whether it's a last step or not

play05:23

right

play05:25

so we'll see how it works so yeah

play05:34

yeah

play05:35

so here you can see it called the March

play05:39

2022 first and

play05:43

then uh it gave some

play05:47

output then it went for uh

play05:52

June

play05:54

tool and then again

play06:01

think the final one the

play06:03

September right so this give the output

play06:08

and you'll get a final response um so

play06:11

here as well there are four steps right

play06:14

uh first calling

play06:18

the March then uh June September and

play06:22

then the final llm

play06:24

response so so that's how it is uh let's

play06:28

do the uh stepwise execution

play06:31

now and then create the

play06:34

task and you can check the first

play06:40

step so it called U March 2022 tool with

play06:45

the input R&D expenditures and revenue

play06:48

and then check if it last step which is

play06:51

false and then run the next step

play06:54

again right

play06:57

um I should ideally call the

play07:02

June yeah June 2022

play07:07

tool and then if check if the last step

play07:11

no run

play07:13

again it should call the September one

play07:21

now so yeah this is the September one

play07:27

and then yeah let's check this is the

play07:29

last step I should be know and then next

play07:34

step this is like

play07:36

the llm response

play07:40

ideally yeah so this is the last step

play07:44

and finally get the

play07:46

response that's it so we went through

play07:51

each step individually and got the final

play07:54

response and also you can actually give

play07:57

a separate input in the one of these

play07:59

steps right as a human

play08:04

feedback so let's create the agent and

play08:07

create the task let's run first step the

play08:10

first step is uh March whatever we have

play08:13

seen um yeah it call the March tool and

play08:19

then it gets the response obviously this

play08:22

is not the last step uh the next step we

play08:25

have seen is June so we'll ask uh with

play08:27

the input what about September

play08:30

so now it will it should ideally call

play08:33

September yeah so with the September

play08:36

tool and it generates a response

play08:38

accordingly so in this way you can uh

play08:41

check individual uh stepwise in outputs

play08:45

and also uh add human feedback uh into

play08:49

the system and then see uh how the

play08:52

output changes so let's say some

play08:55

sometimes the some of these steps uh uh

play08:59

maybe missed then you can add a human

play09:01

feedback and then

play09:04

uh write into get into the right

play09:06

direction so that's how you can use uh

play09:09

stepwise controllable agents um do

play09:12

experiment with it and uh explore the

play09:15

notebook see you in the next video

Rate This

5.0 / 5 (0 votes)

Related Tags
API制御エージェントステップ実行プログラムコード人工知能応答学習技術
Do you need a summary in English?