吳恩達 Agentic AI 第六講 Task decomposition
- URL: https://www.youtube.com/watch?v=yr78nQ56h-c
- Channel: 扣子說AI
- Fetched: 2026-08-12T18:31:07+00:00
- Language: English (auto-generated)
Transcript
[00:02] People and businesses do a lot of stuff.
[00:07] How do you take this useful stuff that
[00:08] we do and break it down into discrete
[00:11] steps for an agentic workflow to follow?
[00:14] Let’s take a look. Take the example of
[00:16] building a research agent. If you want a
[00:19] AI system to write an essay on the topic
[00:21] X, one thing you could do is prompt an
[00:23] LM to have it generate an output
[00:26] directly. But if you were to do this for
[00:29] topics that you want deeply researched,
[00:31] you’ll find that the LM output covers
[00:33] only the surface level points or maybe
[00:35] covers only the obvious facts, but
[00:37] doesn’t go as deep into the subject as
[00:40] you want it to. In this case, you might
[00:42] then reflect on how you as a human would
[00:45] write an essay on a certain topic. Would
[00:47] you just sit down and start writing or
[00:49] would you take multiple steps such as
[00:51] first write an essay outline and then
[00:53] search the web and then based on the
[00:55] input from the web search, write the
[00:57] essay. And as I take a task and
[00:59] decompose it into steps, one question
[01:01] I’m always asking myself is, if you look
[01:03] at these steps one, two, and three, can
[01:05] each of them be done either by an LM or
[01:09] by a short piece of code or by a
[01:12] function call by a tool? And so in this
[01:14] case, I think that an LM can maybe write
[01:16] a decent outline on many topics that I
[01:19] would want it to help me think through.
[01:22] So say probably okay on the first step.
[01:24] And then I know how to use an LM to
[01:27] generate search terms to search the web.
[01:29] So I would say the second step is also
[01:31] doable. And then based on web search, I
[01:33] think an LM could input the web search
[01:35] results and write an essay. And so this
[01:37] would be a reasonable first attempt at
[01:39] an agentic workflow for writing an essay
[01:42] that goes deeper than just direct
[01:44] generation. But if I were to then
[01:46] implement this agentic workflow and look
[01:48] the results, maybe we find that the
[01:50] results still aren’t good enough. It’s
[01:52] still not yet as deeply thoughtful.
[01:54] Maybe the essays are feel a little bit
[01:56] disjointed. This how this should happen
[01:57] to me.” Once built a research agent
[01:59] using this workflow, but when I read the
[02:01] output, it felt a bit disjointed. You
[02:03] know, the start of the article didn’t
[02:05] feel completely consistent with the
[02:06] middle, didn’t feel completely
[02:07] consistent with the end. In this case,
[02:10] what you might do is then reflect on how
[02:12] you would change the workflow if you as
[02:14] a human found that the essays were a bit
[02:16] disjointed. One thing you could do is
[02:18] take the third step and further
[02:21] decompose, write the essay into
[02:24] additional steps. So, instead of writing
[02:27] the essay all in one go, you might
[02:28] instead have it write the first draft
[02:31] and then consider what parts need
[02:32] revision and then revise the draft. And
[02:35] this is what I would do how I as a human
[02:37] might go about it to um not just write
[02:39] the final essay at my first attempt, but
[02:42] write the first draft and then read over
[02:43] it, which is another step that the um is
[02:47] pretty decent at. And then based on my
[02:49] own critique of my own essay, I’ll
[02:50] revise the draft. So, to recap, I
[02:53] started off with direct generation, just
[02:56] one step, decided that it wasn’t good
[02:58] enough, and so broke that down into
[02:59] three steps, and then maybe decided that
[03:01] still isn’t good enough and took one of
[03:03] the steps and further broken it down or
[03:05] decomposed it into three more steps,
[03:08] resulting in this more complex, richer
[03:11] process for generating an essay. And
[03:14] depending on how satisfied you are with
[03:16] the results of this process, you may
[03:18] choose to even modify this essay
[03:20] generation process further. Let’s look
[03:22] at a second example of how to decompose
[03:25] complex tasks into smaller steps. Take
[03:28] the example of responding to basic
[03:30] customer order inquiries. The first step
[03:33] that the human customer service agent
[03:34] might carry out might be to first
[03:37] extract the key information, such as who
[03:39] is this email from, what did they order,
[03:41] and what is the order number. And these
[03:44] are things that the um could do. So, I
[03:46] could just say, “Let’s have a one do
[03:47] that.” The second step would be to then
[03:49] find the relevant customer records, so
[03:52] to write and generate the relevant
[03:54] database queries to pull up the order
[03:56] what the customer had ordered and when
[03:58] it shipped and so on. I think an LLM,
[04:00] with the ability to call a function to
[04:03] query the orders database, should be
[04:06] able to do that. And lastly, having
[04:08] pulled up a customer record or the
[04:09] customer order record, I might then
[04:11] write and send a response back to the
[04:13] customer. And I think with the
[04:14] information we pulled up, this third
[04:16] step is also doable with an LLM, if I
[04:18] give it the option to call an API to
[04:21] send an email. So, this would be another
[04:23] example of taking a task of responding
[04:26] to customer email and breaking it down
[04:28] into three individual steps, where I can
[04:30] look at each of these steps and say,
[04:31] “Yep, I think an LLM, one LLM with the
[04:34] ability to call a function to query a
[04:36] database or send an email, should be
[04:38] able to do that.” Just one last example
[04:40] for the invoice processing. After a PDF
[04:43] invoice has been converted to text, the
[04:45] first step is to pull out the required
[04:47] information, the name of the biller, the
[04:49] address, the due date, the amount due
[04:51] and so on. And an LLM should be able to
[04:53] do that. And then, if I want to check
[04:56] that the information was extracted and
[04:58] save it in a new database entry, then I
[05:00] think an LLM should be able to help me
[05:02] call a function to update the database
[05:04] record. And so, to implement this, we’ll
[05:06] implement an agentic workflow to carry
[05:09] out basically these two steps. When
[05:11] building agentic workflows, I think of
[05:14] myself as having a number of building
[05:16] blocks. One important building block
[05:18] would be large language models or maybe
[05:20] large multimodal models, if I want to
[05:22] try to process images or audio as well.
[05:24] And LLMs are good at generating text,
[05:27] deciding what to call, maybe extracting
[05:29] information. For some highly specialized
[05:32] tasks, I might also use some other AI
[05:34] models, such as AI model for converting
[05:37] a PDF to text or for text-to-speech or
[05:40] for image analysis. In addition to AI
[05:42] models, I also have access to a number
[05:45] of software tools, including different
[05:48] APIs that I can call to do a web search,
[05:51] to get maybe real-time weather data, to
[05:53] send emails, check calendar, and so on.
[05:56] And I might also have tools to retrieve
[05:59] information, to pull up data from a
[06:01] database, or to implement rag or
[06:04] retrieval augmented generation, where I
[06:06] can look up a large text database and
[06:07] find the most relevant text, or I might
[06:09] also have tools to execute code. And
[06:12] this is a tool that lets an LM write
[06:15] code and then run the code on your
[06:16] computer to do a huge range of things.
[06:19] In case some of these tools seem a bit
[06:21] foreign to you, don’t worry about it.
[06:22] We’ll go through the most important
[06:24] tools in much greater detail in a later
[06:26] module. But I think of a lot of my work
[06:29] when I’m building an agent workflow as
[06:31] looking at the work that a person or
[06:33] business is doing, and then trying to
[06:34] figure out with these building blocks,
[06:36] how can I sequence these building blocks
[06:38] together in order to carry out the task
[06:41] that I want my system to carry out. And
[06:44] this is why having understanding of what
[06:46] building blocks are available, which I
[06:48] hope you have a better sense of by the
[06:51] end of this course as well, will allow
[06:52] you to better envision what agentic
[06:54] workflows you can build by combining
[06:56] these building blocks together. So, to
[06:58] summarize, one of the key skills in
[07:00] building agentic workflows is to look at
[07:02] a bunch of stuff that maybe someone
[07:04] does, and to identify the discrete steps
[07:08] that it could be implemented with.
[07:10] And when I’m looking at the individual
[07:12] discrete steps, one question I’m always
[07:14] asking myself is, can this step be
[07:16] implemented with either an LM or with
[07:20] one of the tools, such as an API or a
[07:21] function call that I have access to? And
[07:24] in case the answer is no, I’ll then
[07:26] often ask myself, how would I as a human
[07:29] do this step? And is it possible to
[07:31] decompose this further, break this down
[07:33] into even smaller steps that then maybe
[07:36] is more amenable to implementation with
[07:39] an LM or with one of the software tools
[07:42] that I have. So, I hope this gives you a
[07:44] rough sense of how to think about task
[07:46] composition in case you feel like you
[07:48] don’t fully have it yet. Don’t worry
[07:50] about it. We’ll go through many more
[07:52] examples in this course and you have a
[07:54] much better understanding of this by the
[07:56] end of this course. But, it turns out
[07:58] that as you build agentic workflows, you
[08:00] find that often you build an initial
[08:03] task composition, initial agentic
[08:05] workflow, and then you want to keep on
[08:08] iterating and improving on it quite a
[08:09] few times until it delivers the level of
[08:12] performance that you want. And to drive
[08:14] this improvement process, which is found
[08:16] important for many projects, one of the
[08:19] key skills is to know how to evaluate
[08:21] your agentic workflow.
[08:23] So, in the next video, we’ll talk about
[08:25] evaluations or evals and this will be a
[08:28] key component for you can build and then
[08:31] also keep on improving your workflows to
[08:33] get the performance that you want. Let’s
[08:35] talk about evals in the next video.