Tool use
Overview
Mohit Iyyer connects two ways to extend language-model reasoning: DeepSeek R1-style explicit thinking tokens and looped transformers that spend more compute by reusing layers. He then explains tool use as a model-harness loop, covering tool schemas, prompting, supervised fine-tuning, reinforcement learning, and how flexible search tools generalize beyond fixed retrieval-augmented generation pipelines.
Key takeaways
- Looped transformers increase effective network depth by repeatedly applying the same layer weights, allowing more test-time computation without generating extra reasoning tokens.
- Explicit chain-of-thought is easier to inspect than latent reasoning in hidden states, but neither visible traces nor model internals provide a guaranteed faithful account of how an answer was reached.
- A tool-using model does not execute actions by itself: a harness parses its calls, runs the APIs, returns outputs as context, and resumes generation.
- Tool-use training can combine rewards for correctly formatted calls with rewards for solving the task, so models learn both API syntax and when a tool improves an answer.
- RAG is a constrained form of tool use: retrieval runs once before generation, whereas search-as-a-tool can happen repeatedly and dynamically during reasoning.
Chapters
- DeepSeek R1-style training rewards whether the final math answer is correct, without prescribing the contents of the model's thinking tokens.
- Generating more reasoning tokens increases test-time compute and can improve performance on math problems.
- Intermediate variables written in a reasoning trace can be reused in later computations.
- A looped transformer sends a representation through a contiguous block of layers repeatedly instead of proceeding directly through a deeper stack.
- For example, looping layers 3 and 4 thirty times adds repeated computation before the model reaches layer 5.
- The representation changes on each pass, allowing the model to refine hidden states without generating additional tokens.
- Looped transformers reuse the same layer weights, increasing effective depth and compute without adding parameters for every loop.
- Unlike chain-of-thought, intermediate results remain in hidden states rather than appearing as readable text.
- A standard model cannot simply have layers looped at inference time; it generally must be trained to handle different loop counts.
- The loop count L can be set at test time, with more loops providing additional computation for difficult problems.
- Models can be trained to encounter different loop counts, either by sampling counts or by learning a separate method to select them.
- Reinforcement learning can impose a reasoning-token budget by rewarding correct answers while penalizing traces that are too long or too short.
- Looping can reduce generated-token costs because the model may produce an answer without a long explicit reasoning trace.
- Chain-of-thought is more inspectable, while looping keeps intermediate computations implicit and difficult to read.
- Looped models may be harder to adapt than chain-of-thought models because looping usually requires changes to pretraining.
- Hidden-state reasoning makes it difficult to monitor a looped model's intermediate computations, even when researchers can inspect its internals.
- Visible chain-of-thought can support monitoring for concerning behavior, although a written trace is not guaranteed to faithfully reflect the model's actual reasoning.
- Controlled comparisons are difficult because matching a looped model's effective depth with a conventional model can be computationally expensive.
- Tool use extends models beyond single-shot token generation by connecting them to APIs and external services.
- Tools such as web search, calculators, restaurant booking, and code interpreters enable capabilities that are difficult or unavailable from model parameters alone.
- Tool-using systems can verify results and iterate, and multiple model instances can coordinate around shared goals.
- Exact arithmetic, such as calculating an 80-dollar jacket price after a 15% discount, is more reliably handled by a calculator than by language-model generation alone.
- Web search provides information after a model's training cutoff and can retrieve exact facts that are difficult to recall from parameters.
- A code interpreter or email API lets a model run code or send messages, but the model needs an external system to execute those actions.
- A tool is a callable function with a name, expected arguments, and a defined output, such as a calculator that accepts an expression and returns a number.
- A harness detects generated tool calls, executes them, returns their results to the model, and resumes decoding.
- Supervised fine-tuning and reinforcement learning can teach models to format calls correctly and solve tasks using tools.
- Tool outputs, including web-search documents, are inserted into the model's context so it can continue generating from the returned information.
- A model can search, reason over documents, issue another query, or pass one tool's output into another tool.
- The harness can parse structured tool-call text, pause generation, execute the call, append results, and restart generation.
- Tool definitions in a system prompt describe available tools, their arguments, and output formats, making it possible to add or remove tools without retraining.
- For the 80-dollar jacket problem, the model can call a calculator with 80 × 0.85 and receive 68.0 from the harness.
- The model may continue reasoning, call more tools, or produce a final answer, subject to reasoning and tool-call budgets.
- Few-shot prompting can describe tools and demonstrate calls; ReAct, published in 2022, used this approach without additional training.
- Toolformer, released by Meta in 2023, generated candidate tool-use examples and retained examples where tool calls reduced loss on held-out data.
- Reinforcement learning can reward task success and correct tool formatting, increasing the probability of useful tool calls.
- Retrieval-augmented generation, introduced in 2020, retrieves relevant documents before the language model generates an answer.
- A typical RAG pipeline searches for the top k documents, then supplies those documents and the query to the model.
- Unlike dynamic search-as-a-tool, fixed RAG does not let the model decide when to search, what to search for, or whether to retrieve again.
Transcript excerpt
0:06 Okay, let's get started everyone. >> Hope everyone had a good break. Uh, today we are going to be finishing up the reasoning lecture that we um had started right before the break and then we're going to start talking about uh tool use and agents. So how we can um kind of move past the singleshot decoding that we've been talking about and um link our models up to external APIs and tools um to get to something like what we see with modern um AI systems where you know if you go to chat GBT or claude right now you are likely going to um with whatever query you you
0:56 send interact with many tools like a web search, a restaurant booking, a calculator, a code interpreter. Um it's clear that you know the capabilities of today's uh AI go far beyond just generating tokens. And so uh we're going to see how um kind of simple it is to get uh these kinds of capabilities out of the models that we've pre and postrained. Okay. Um so to start with uh from last time we were discussing reasoning models and as a recap we uh covered kind of the deepseek R10
1:44 approach where we um kind of gave the model a reward if it correctly solved a math problem. uh but we also allowed it to think using these special thinking tokens and importantly our reward has no bearing over the content of those thinking tokens. So the model can produce whatever tokens it wants as long as at the end of the day the final answer is correct. Um and we kind of talked about how um more thinking tokens um results in more test time compute
2:34 being used uh because the model is producing you know potentially thousands
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Mohit Iyyer.