In many generative applications of ai, a large language model (LLM) such as amazon Nova is used to respond to a user consultation based on knowledge or context of the model provided. However, as the use cases have matured, the ability of a model of having access to tools or structures that would be inherently outside the model reference frame has become essential. This could be API, code functions or schemes and structures required by its final application. This capacity has become what is known as Use of the tool either Functions called.
To add a fine grain control to how the tools are used, we have launched a function for the choice of tools for amazon Nova models. Instead of trusting fast engineering, the choice of the tool forces the model to adhere to the configuration in place.
In this publication, we discussed the use of tools and the new function of choice of tools, with cases of example use.
Use of the tool with amazon Nova
To illustrate the concept of use of tools, we can imagine a situation in which we provide amazon Nova access to some different tools, such as a calculator or a meteorological API. According to the user's consultation, amazon Nova will select the appropriate tool and tell you how to use it. For example, if a user asks “What is the weather in Seattle?” amazon Nova will use the weather tool.
The following diagram illustrates an example workflow between a amazon Nova model, its available tools and related external resources.
The use of the tool in the nucleus is the selection of the tool and its parameters. The responsibility of executing external functionality is left to the application or the developer. After the application executes the tool, you can return the results to the model for the generation of the final response.
Let's explore some examples in more detail. The following diagram illustrates the workflow of a amazon Nova model using a function call to access a weather API and return the response to the user.
The following diagram illustrates the workflow of a amazon Nova model using a function call to access a calculator tool.
Choice of tools with amazon Nova
He toolChoice
The API parameter allows you to control when a tool is called. There are three compatible options for this parameter:
- Any – With the choice of tools
Any
The model will select at least one of the tools available each time: - Tool – With the choice of tools
Tool
The model will always use the requested tool: - Car – Choice of tools
Auto
It is the predetermined behavior and will leave the selection of the tool completely to the model:
A popular tactics to improve the reasoning capabilities of a model is to use the chain of thought. When using the choice of the tool auto
amazon Nova will use the chain of thought and the model response will include both the reasoning and the tool that was selected.
This behavior will differ according to the case of use. When tool
either any
They are selected as the choice of the tool, amazon Nova will generate only the tools and not the exit thinking chain.
Use cases
In this section, we explore different cases of use for the choice of tools.
Structured output/JSON mode
In certain scenarios, you may want amazon Nova to use a specific tool to answer the user's question, even if amazon Nova believes you can provide an answer without the use of a tool. A common use case for this approach is to enforce the structured output/JSON mode. It is often essential to have the structured output of LLMS return, because this allows the cases of downstream use to consume and process the generated outputs more effectively. In these cases, the tools used do not necessarily need to be functions on the client's side: they can be used when the model is required to return the JSON output that adheres to a predefined scheme, which forces amazon Nova to use the specified tool.
By using tools to enforce the structured output, it provides a unique tool with a descriptive JSON inputSchema
. Specify the tool with {"tool" : {"name" : "Your tool name"}}
. The model will pass the entrance to the tool, so the name of the tool and its description must be from the perspective of the model.
For example, consider a food website. When a description of the dish is provided, the website can extract the details of the recipe, such as cooking time, ingredients, the name of the dish and the level of difficulty, to facilitate the search and filtering capabilities of users. See the following example code:
We can provide a detailed description of a dish as a text input:
We can force amazon Nova to use the tool extract_recipe
which will generate a structured JSON output that adheres to the predefined scheme provided as the tool input scheme:
API generation
Another common scenario is to demand that amazon Nova select a tool of the available options regardless of the user consultation context. An example of this is with the API final point selection. In this situation, we do not know the specific tool to use, and we allow the model to choose among those available.
With the choice of the tool any
You can make sure the model always uses at least one of the available tools. Because of this, we provide a tool that can be used for when an API is not relevant. Another example would be to provide a tool that allows explanatory questions.
In this example, we provide the two different APIs and a non -compatible API tool that will select based on the user consultation:
A user entry of “Can you get all available products?” I would issue the following:
While “Can you get my most recent orders?” I would issue the following:
Chat
The final option for choosing the tool is auto
. This is the predetermined behavior, so it is consistent with not providing any tool option at all.
The use of this tool option will allow the option to use the tool or simply text output. If the model selects a tool, there will be a block of tools and a block of text. If the model responds without tool, only a block of text is returned. In the following example, we want to allow the model to respond to the user or call a tool if necessary:
A user entry of “What is the weather in San Francisco?” would result in a tool call:
While the model gives a direct question like “How many months are there in a year?” I would answer with a text response to the user:
Considerations
There are some best practices that are required for tools calls with Nova models. The first is to use greedy decoding parameters With the amazon Nova models, that requires establishing a temperature, Top P and Top K of 1. can consult the previous code examples on how to establish them. The use of greedy decoding parameters forces the models to produce deterministic responses and improve the success rate of the tool call.
The second consideration is the JSON scheme that is using for the consideration of the tool. At the time of writing this article, amazon Nova Models supports a limited subset of JSON schemes, so it is possible that the model does not collect them as expected. The common fields would be $def
and $ref
fields. Make sure your scheme has the following set of upper level fields: type
(It must be object
), properties
and required
.
Finally, for the greatest impact on the success of tool calls, you must optimize the configurations of your tool. Descriptions and names must be very clear. If there are nuances when one should be called to the other, be sure to include it concisely in the tool descriptions.
Conclusion
The use of the choice of tools in the workflows of tool calls is a scalable way of controlling how a model invokes tools. Instead of trusting fast engineering, the choice of the tool forces the model to adhere to the configuration in place. However, there are complexities for tool calls; For more information, see the use of the tool (functions calls) with amazon Nova, call tool calling systems.
Explore how amazon Nova models can improve their generative cases of use of today.
About the authors
Jean farmer It is a generative architect of Ama's General Intelligence (AGI) teams of amazon, specialized in agent applications. Based in Seattle, Washington, works at the intersection of self -employed systems and practical commercial solutions, helping to shape the AGI's future in amazon.
Sharon Li He is an IA/ML specialized solution architect at amazon Web Services (AWS) based in Boston, Massachusetts. With a passion for taking advantage of avant -garde technology, Sharon is at the forefront of developing and implementing innovative generative solutions on the Aws Cloud platform.
Lulu Wong He is an ai UX designer in the amazon artificial general intelligence team (AGI). With experience in computer science, learning design and experience of the user, unites the technical domains and user experience by shaping how IA systems interact with humans, refining the entry-salary behaviors of the model and the creation of resources to make the products of ai be more accessible to users.