Course contentsShow
← AI Engineering
Lesson 546 of 1,88614. Function Calling and Tool UseFree lesson

Writing Function Descriptions for LLMs

Crafting clear, actionable descriptions that help the model decide when and how to use each function.

Writing Function Descriptions for LLMs

What you'll learn: How to write clear function descriptions that guide the LLM to correctly decide when and how to invoke your functions.

Why Descriptions Matter

When you provide functions to an LLM through the Function Calling API, the model doesn't execute your code—it only sees the function's description. Think of it like giving someone a restaurant menu: if the descriptions are vague or misleading, they'll order the wrong dish. Your function descriptions are the menu the LLM uses to decide which "tool" to pick.

Core Principles for Effective Descriptions

Be Specific About Purpose

Don't write: "Gets weather data"
Do write: "Retrieves current weather conditions for a specific city, including temperature, humidity, and conditions"

The LLM needs to know exactly when this function is the right choice versus other available functions.

Describe Parameters Clearly

For each parameter, explain:

  • What it represents (not just the name)
  • Format expected (e.g., "city name in English", "ISO country code")
  • Required vs optional

Include Behavioral Hints

If your function has limitations or special behavior, mention it: "Returns data only for US cities" or "Temperature always in Celsius". This prevents the model from choosing your function when it can't fulfill the request.

The LLM's Decision Process

The model reads all available function descriptions and compares them against the user's request. Clear, distinctive descriptions help it make accurate choices. Ambiguous descriptions lead to wrong function calls or missed opportunities to use the right tool.

Key Takeaway: Function descriptions are your primary interface for teaching the LLM when and how to use your tools—invest time making them precise, specific, and behavior-aware to ensure reliable function selection.