Buckets:
| <meta charset="utf-8" /><meta name="hf:doc:metadata" content="{"title":"Thought: Internal Reasoning and the ReAct Approach","local":"thought-internal-reasoning-and-the-react-approach","sections":[{"title":"The ReAct Approach","local":"the-react-approach","sections":[],"depth":2}],"depth":1}"> | |
| <link href="/docs/agents-course/pr_545/en/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_545/en/_app/immutable/entry/start.1596c81c.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_545/en/_app/immutable/chunks/scheduler.37c15a92.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_545/en/_app/immutable/chunks/singletons.8a3d92bd.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_545/en/_app/immutable/chunks/index.18351ede.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_545/en/_app/immutable/chunks/paths.5b2602e7.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_545/en/_app/immutable/entry/app.856a784e.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_545/en/_app/immutable/chunks/index.2bf4358c.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_545/en/_app/immutable/nodes/0.1cd5790a.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_545/en/_app/immutable/chunks/each.e59479a4.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_545/en/_app/immutable/nodes/31.33bac7a0.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_545/en/_app/immutable/chunks/Tip.363c041f.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_545/en/_app/immutable/chunks/Heading.8ada512a.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_545/en/_app/immutable/chunks/getInferenceSnippets.031140c2.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{"title":"Thought: Internal Reasoning and the ReAct Approach","local":"thought-internal-reasoning-and-the-react-approach","sections":[{"title":"The ReAct Approach","local":"the-react-approach","sections":[],"depth":2}],"depth":1}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <h1 class="relative group"><a id="thought-internal-reasoning-and-the-react-approach" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#thought-internal-reasoning-and-the-react-approach"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Thought: Internal Reasoning and the ReAct Approach</span></h1> <div class="course-tip bg-gradient-to-br dark:bg-gradient-to-r before:border-green-500 dark:before:border-green-800 from-green-50 dark:from-gray-900 to-white dark:to-gray-950 border border-green-50 text-green-700 dark:text-gray-400">In this section, we dive into the inner workings of an AI agent—its ability to reason and plan. We’ll explore how the agent leverages its internal dialogue to analyze information, break down complex problems into manageable steps, and decide what action to take next. Additionally, we introduce the ReAct approach, a prompting technique that encourages the model to think “step by step” before acting.</div> <p data-svelte-h="svelte-1l9soxr">Thoughts represent the <strong>Agent’s internal reasoning and planning processes</strong> to solve the task.</p> <p data-svelte-h="svelte-1f7vu7v">This utilises the agent’s Large Language Model (LLM) capacity <strong>to analyze information when presented in its prompt</strong>.</p> <p data-svelte-h="svelte-qzqdp1">Think of it as the agent’s internal dialogue, where it considers the task at hand and strategizes its approach.</p> <p data-svelte-h="svelte-1fhik7m">The Agent’s thoughts are responsible for assessing current observations and decide what the next action(s) should be.</p> <p data-svelte-h="svelte-1ngchwc">Through this process, the agent can <strong>break down complex problems into smaller, more manageable steps</strong>, reflect on past experiences, and continuously adjust its plans based on new information.</p> <p data-svelte-h="svelte-ompwrf">Here are some examples of common thoughts:</p> <table data-svelte-h="svelte-1efoj4x"><thead><tr><th>Type of Thought</th> <th>Example</th></tr></thead> <tbody><tr><td>Planning</td> <td>“I need to break this task into three steps: 1) gather data, 2) analyze trends, 3) generate report”</td></tr> <tr><td>Analysis</td> <td>“Based on the error message, the issue appears to be with the database connection parameters”</td></tr> <tr><td>Decision Making</td> <td>“Given the user’s budget constraints, I should recommend the mid-tier option”</td></tr> <tr><td>Problem Solving</td> <td>“To optimize this code, I should first profile it to identify bottlenecks”</td></tr> <tr><td>Memory Integration</td> <td>“The user mentioned their preference for Python earlier, so I’ll provide examples in Python”</td></tr> <tr><td>Self-Reflection</td> <td>“My last approach didn’t work well, I should try a different strategy”</td></tr> <tr><td>Goal Setting</td> <td>“To complete this task, I need to first establish the acceptance criteria”</td></tr> <tr><td>Prioritization</td> <td>“The security vulnerability should be addressed before adding new features”</td></tr></tbody></table> <blockquote data-svelte-h="svelte-lbm2tt"><p><strong>Note:</strong> In the case of LLMs fine-tuned for function-calling, the thought process is optional. | |
| <em>In case you’re not familiar with function-calling, there will be more details in the Actions section.</em></p></blockquote> <h2 class="relative group"><a id="the-react-approach" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#the-react-approach"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>The ReAct Approach</span></h2> <p data-svelte-h="svelte-xbnpor">A key method is the <strong>ReAct approach</strong>, which is the concatenation of “Reasoning” (Think) with “Acting” (Act).</p> <p data-svelte-h="svelte-3stkhz">ReAct is a simple prompting technique that appends “Let’s think step by step” before letting the LLM decode the next tokens.</p> <p data-svelte-h="svelte-1f470gx">Indeed, prompting the model to think “step by step” encourages the decoding process toward next tokens <strong>that generate a plan</strong>, rather than a final solution, since the model is encouraged to <strong>decompose</strong> the problem into <em>sub-tasks</em>.</p> <p data-svelte-h="svelte-cc5rnv">This allows the model to consider sub-steps in more detail, which in general leads to less errors than trying to generate the final solution directly.</p> <figure data-svelte-h="svelte-ul277z"><img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit1/ReAct.png" alt="ReAct"> <figcaption>The (d) is an example of ReAct approach where we prompt "Let's think step by step"</figcaption></figure> <div class="course-tip bg-gradient-to-br dark:bg-gradient-to-r before:border-green-500 dark:before:border-green-800 from-green-50 dark:from-gray-900 to-white dark:to-gray-950 border border-green-50 text-green-700 dark:text-gray-400">We have recently seen a lot of interest for reasoning strategies. This is what's behind models like Deepseek R1 or OpenAI's o1, which have been fine-tuned to "think before answering". | |
| <p data-svelte-h="svelte-a1470c">These models have been trained to always include specific <em>thinking</em> sections (enclosed between <code><think></code> and <code></think></code> special tokens). This is not just a prompting technique like ReAct, but a training method where the model learns to generate these sections after analyzing thousands of examples that show what we expect it to do.</p></div> <hr> <p data-svelte-h="svelte-4r07cc">Now that we better understand the Thought process, let’s go deeper on the second part of the process: Act.</p> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/agents-course/blob/main/units/en/unit1/thoughts.mdx" target="_blank"><span data-svelte-h="svelte-1kd6by1"><</span> <span data-svelte-h="svelte-x0xyl0">></span> <span data-svelte-h="svelte-1dajgef"><span class="underline ml-1.5">Update</span> on GitHub</span></a> <p></p> | |
| <script> | |
| { | |
| __sveltekit_17hovx6 = { | |
| assets: "/docs/agents-course/pr_545/en", | |
| base: "/docs/agents-course/pr_545/en", | |
| env: {} | |
| }; | |
| const element = document.currentScript.parentElement; | |
| const data = [null,null]; | |
| Promise.all([ | |
| import("/docs/agents-course/pr_545/en/_app/immutable/entry/start.1596c81c.js"), | |
| import("/docs/agents-course/pr_545/en/_app/immutable/entry/app.856a784e.js") | |
| ]).then(([kit, app]) => { | |
| kit.start(app, element, { | |
| node_ids: [0, 31], | |
| data, | |
| form: null, | |
| error: null | |
| }); | |
| }); | |
| } | |
| </script> | |
Xet Storage Details
- Size:
- 10.8 kB
- Xet hash:
- b385102dbf37c3e4e96e80f56785d24ac13bda7495144923dc775a7a925730c2
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.