Selecting APIs From a Large Tool Catalog: Test Retrieval First, Then Qwen3, Tool-Embed/Tool-Rank or a Picker
Tool retrieval decides which APIs the calling model ever sees. Measure recall over the full catalog, then shortlist scoring, then arguments and deferral, before choosing Qwen3, Tool-Embed and Tool-Rank, Claude tool search or TOD.
To select APIs from a large tool catalog, run a tool retrieval model over the whole catalog, rerank a shortlist, and let a tool-calling LLM or your own code fill in the arguments. Start with BM25 plus Qwen3 Embedding and Qwen3 Reranker as the open baseline, and test Tool-Embed and Tool-Rank against it on your own catalog. Claude tool search and OpenAI tool search are managed alternatives that bundle retrieval and calling. No published test compares all of these on one catalog, so the choice rests on measuring each stage separately.
Retrieval over the full catalog sets the ceiling for every later stage
A calling model can only choose an API that reaches its context. ToolRet, a benchmark presented at ACL 2025, makes this concrete. It pairs 7,600 retrieval tasks with a corpus of 43,000 tools. Its authors found that retrieval models that score well on ordinary search benchmarks perform poorly on tool retrieval. They also found that weak retrieval lowers the task pass rate of the tool-use LLMs downstream.
The same split between finding a tool and using it goes back to ToolLLM, a 2023 paper by Qin and colleagues. ToolLLM collected 16,464 REST APIs in 49 categories from RapidAPI Hub. It paired a neural API retriever, which recommends APIs for each instruction, with a separate calling model, ToolLLaMA. That split remains a sensible design for catalogs of thousands of endpoints.
Anthropic's managed system follows the same design. Its tool search documentation states that Claude's tool selection accuracy degrades once more than 30 to 50 tools are available. Anthropic therefore loads only the tools that a search returns.
A five-stage pipeline separates the jobs that fail in different ways
A clear architecture keeps each failure visible. The pipeline below shows where each model fits and where application code must remain in charge.
user request
|
[1] Catalog retrieval over all N tools
BM25, Qwen3-Embedding, Tool-Embed,
or TOD's ModernBERT-base retriever
| top k candidates, k tuned per catalog
[2] Shortlist scoring and reranking
Qwen3-Reranker, Tool-Rank, or TOD predict()
| top m options plus "no suitable tool"
[3] Final selection and deferral gate
pick if confident, otherwise defer
|
[4] Argument resolution
tool-calling LLM or application code,
validated against the JSON schema
|
[5] Authorization and execution
application code only
Stages 1 and 2 can use small open models. Stage 3 is a threshold that you set and test. Stage 4 needs a model that writes arguments, because rerankers and pickers only score options. Stage 5 always belongs to your application, because a high score is not permission to call an API.
The open baselines are Qwen3 and the tool-specific Tool-Embed and Tool-Rank
Qwen3 Embedding and Qwen3 Reranker are general-purpose retrieval models from the Qwen team. Both families come in 0.6B, 4B and 8B sizes with a 32K sequence length. The model cards list the Apache-2.0 licence. The embedding model is designed to take a one-sentence task instruction on the query side, and the reranker scores each query and document pair as the probability of a "yes" answer.
Tool-Embed and Tool-Rank are tuned versions of those models for tool retrieval. The authors of the Tool-DE paper, submitted to arXiv in October 2025 and since renamed Tool-REX, built Tool-Embed by fully fine-tuning Qwen3-Embedding-0.6B and 4B. They built Tool-Rank with LoRA on Qwen3-Reranker-4B. Their repository publishes Tool-Embed-0.6B, Tool-Embed-4B, Tool-Rank-4B and Tool-Rank-8B under Apache-2.0. The Hugging Face cards list BF16 weights but have empty READMEs, so the usage format comes from the repository code.
The paper's own figures show why the tuned models are worth testing. On ToolRet, average NDCG@10 was 36.41 for BM25, 43.13 for Qwen3-Embedding-0.6B and 45.54 for Qwen3-Embedding-4B. Tool-Embed-4B, trained on the original documents, reached 49.21. On the paper's own benchmark, Tool-Rank-4B added 4.21 points of NDCG@10 over Tool-Embed-4B alone. Those are the authors' results on research catalogs, not a ranking for any private catalog.
The baselines need careful records to be reproducible. The table lists what each one needs pinned.
| System | Models to pin | Licence | Settings to record |
|---|---|---|---|
| BM25 plus Qwen3 | Qwen3-Embedding and Qwen3-Reranker, 0.6B or 4B | Apache-2.0 | Query instruction, transformers 4.51.0 or later |
| Tool-Embed plus Tool-Rank | Tool-Embed-0.6B or 4B, Tool-Rank-4B or 8B | Apache-2.0 | BF16, rerank depth, repository commit |
| TOD v1 | LoRA adapters on gemma-4-12B-it, ModernBERT-base retriever | Adapters Apache-2.0, base under Gemma 4 terms | Eager attention, no int8 |
| Claude tool search | tool_search_tool_bm25_20251119 or regex variant |
Commercial API | Model ID, search limit |
For every self-hosted run, record the GPU, precision, batch size and both candidate limits. The Tool-DE authors reranked the top 100 candidates per query. Treat that depth, and common defaults such as 50 retrieved and 5 to 10 shortlisted, as starting points to vary rather than tested optimums.
Claude tool search and OpenAI tool search are managed systems with their own behaviour
Claude tool search is a different kind of system from the standalone models. You send every tool definition with defer_loading: true, up to 10,000 deferred tools per request. Claude then writes either a regex pattern or a natural-language BM25 query. The API returns up to five matching tools by default and expands their full definitions into context. Claude then chooses among them and writes the call.
The search covers tool names, descriptions, argument names and argument descriptions. A search that matches nothing returns an empty list rather than an error. You can also replace the built-in search with your own, such as an embedding index, by returning tool_reference blocks from a custom tool. That hook lets Qwen3 or Tool-Embed retrieval sit behind Claude's calling step.
OpenAI's tool search works on gpt-5.4 and later models in the Responses API. Deferred functions still show their name and description to the model, and mainly the parameter schema is deferred. OpenAI recommends grouping functions into namespaces of fewer than 10 functions each. It offers hosted search and a client-executed mode, in which your application performs the lookup.
Results from a managed system cannot be read as results for a retrieval model. Anthropic reported that tool search raised Opus 4.5 from 79.5% to 88.1% on its internal MCP evaluations. That figure measures search and calling together, on Anthropic's tools, with Anthropic's model.
Expanded API documentation helps keyword search most, and it must not invent capabilities
The Tool-DE paper's central claim is that tools are under-documented. Its authors used Qwen3-32B to add structured fields to each tool's description: function description, tags, when to use, limitations and example usage. A LLaMA-3.1-70B judge and a GPT-4o refinement step checked the results.
The gains were uneven across retrievers. On the ToolRet tasks, swapping the original documents for the expanded ones lifted BM25 from 36.41 to 39.35 NDCG@10. It moved Qwen3-Embedding-0.6B only from 43.13 to 43.30, and recall fell slightly for the 4B and 8B embedders. The authors also report that longer documents dilute similarity scores and can be truncated. About 23.5% of sampled documents were still judged incomplete after expansion.
A practical document schema follows from this. Each endpoint record should contain these five fields:
- A purpose sentence that states what the endpoint does and when to use it instead of its near neighbours.
- The inputs, with types, units and required fields taken from the real schema.
- The outputs, described in terms that match how users phrase requests.
- The constraints, such as rate limits, regions, permissions and side effects.
- One or two verified usage examples that have been executed against the real API.
Generated text needs two guards. First, write expansions from the API specification only, and check every stated capability against the schema or a live call. Second, write examples before the test queries are drawn, and never from them. Otherwise the documents can contain the answers to the test set. Run every retriever on both raw and expanded documents, because the paper shows that the effect differs by model.
A held-out test set must include the cases that break pickers
The test set determines whether the comparison means anything. A useful held-out set covers these cases:
- Requests that target near-duplicate endpoints, such as two versions of the same API, test whether the scorer separates close options.
- Requests that name an endpoint by its exact name test whether dense retrieval loses identifiers that BM25 keeps.
- Requests that need several tools test whether retrieval returns all of them, not just one.
- Requests for which the right API has been removed from the catalog test whether the system defers instead of guessing.
- Requests run after tools are added or retired test whether the index stays current.
The scoring rule matters as much as the queries. A September 2026 paper on annotation expansion found that 67.9% of sub-queries in the 7,360-query Tool-DE benchmark had functionally equivalent tool alternatives. Its authors estimate that 30% to 47% of the reported fine-tuning gain on that benchmark is an evaluation artifact. Accept every valid tool combination as correct, or the test will penalize good retrievers.
Each stage needs its own metric before any benefit is claimed
The metrics must follow the pipeline, so that a failure can be traced to one stage:
- Complete recall at k counts the requests for which every required tool appears in the top k. Measure it before judging any picker.
- Shortlist selection accuracy counts correct picks among requests whose correct tool reached the shortlist.
- The valid-argument rate counts calls that pass schema validation and use correct values.
- End-to-end success counts tasks that finish correctly after execution.
- Coverage and selective accuracy show how many requests the gate accepts and how accurate those accepted picks are.
- Latency at p50 and p95 and total cost per 1,000 requests cover the full pipeline, not only the picker.
Vary k and the shortlist size together, for example 20, 50 and 100 retrieved against 3, 5 and 10 shortlisted. Report results on a ToolRet-style public set and, where permitted, on a sample of real requests to your own catalog. Report uncertainty with each figure, because a few hundred test requests leave wide intervals.
A head-to-head result on these metrics for BM25 plus Qwen3, Tool-Embed plus Tool-Rank, TOD and Claude tool search has not been measured. Calibrated deferral has not been reported for any of these tool retrievers on ToolRet.
A shortlist becomes a state, a question and a set of options
A picker works on a fixed shortlist, so the shortlist must include an explicit way out. The example below retrieves with Qwen3-Embedding-0.6B and passes the shortlist to any scorer with the call shape that TOD's repository documents, predict(state, options, question, images). A wrapper around Qwen3-Reranker or Tool-Rank can fill the same role.
import numpy as np
from jsonschema import validate
from sentence_transformers import SentenceTransformer
NONE = "none_of_these: no listed API fits the request"
embedder = SentenceTransformer("Qwen/Qwen3-Embedding-0.6B")
def retrieve(request, tools, k=50):
texts = [t["doc"] for t in tools]
d = embedder.encode(texts, normalize_embeddings=True)
q = embedder.encode([request], prompt_name="query",
normalize_embeddings=True)
scores = (d @ q.T).ravel()
return [tools[i] for i in np.argsort(-scores)[:k]]
def pick(request, shortlist, predict, threshold=0.6):
options = [t["name"] + ": " + t["purpose"] for t in shortlist]
options.append(NONE)
probs = predict(state=request, options=options,
question="Which API should handle this request?",
images=[])
best = int(np.argmax(probs))
if options[best] == NONE or probs[best] < threshold:
return None
return shortlist[best]
def execute(request, tool, user, write_args, registry):
args = write_args(request, tool)
validate(args, tool["input_schema"])
if not registry.allowed(user, tool["name"]):
raise PermissionError(tool["name"])
return registry.call(tool["name"], args)
A None from pick is a deferral. The application can then pass the turn to a larger LLM with a wider shortlist, ask the user a clarifying question, or report that no API fits. The threshold of 0.6 is an assumption to tune against the coverage curve. In production, the document embeddings would be computed once and stored rather than recomputed per request.
The permission check is separate from the score on purpose. A confident pick on the wrong account or a destructive endpoint must still be refused by code that checks the user's rights.
TOD is a picker for stages 2 and 3, and it does not write arguments
Parsec's TOD is one option for the shortlist and gating stages. According to Parsec's TOD page, it ranks the next action from a list of allowed actions, generates no free text and invents no actions. A confidence gate lets it handle a turn when it is confident and pass the turn unchanged to the parent LLM otherwise. The page lists a price of $0.30 per 1,000 decisions, separate from parent-model costs. The release on Hugging Face is LoRA adapters on Google's gemma-4-12B-it plus a ModernBERT-base retriever, and users must accept the Gemma 4 licence. Parsec's repository says that predict was measured with up to 300 options and that TOD is not state of the art on JevBench. It also warns against bitsandbytes int8, which it says changes picks. Parsec has published no ToolRet or Tool-DE result for TOD, so its retrieval quality against Tool-Embed is unknown. Its compact retriever and its Gemma-based scorer should be reported as separate rows in any test.
A worked cost example shows that the calling model sets most of the bill
List prices allow a rough comparison for 1 million requests a month. The example assumes 500 tokens of request and instructions, a five-tool shortlist at 300 tokens per schema, and 150 output tokens for the search step and the call. It also adds the tool-use system prompt of 286 tokens that Anthropic lists for Haiku 5.5 and Sonnet 5.5. That gives 2,286 input tokens per request.
- On Claude Sonnet 5.5 with tool search, at $2 input and $10 output per million tokens, the month costs $4,572 for input and $1,500 for output, or $6,072.
- On Claude Haiku 5.5 with tool search, at $0.10 and $0.50, the same traffic costs $228.60 plus $75, or $303.60.
- A self-hosted Qwen3 retriever feeding Haiku 5.5 has the same token bill of $303.60, plus GPU time that depends on your hardware.
- A TOD pick followed by Haiku 5.5 writing the arguments for only the chosen tool uses 1,086 input and 100 output tokens per request. That is $158.60 in tokens plus $300 in TOD fees, or $458.60, before any retriever hosting.
Anthropic's documentation states that tool search is not metered as a separate server tool and that loaded definitions count as input tokens. On these assumptions, the choice of calling model moves the bill by a factor of 20, while the retrieval method moves it far less. Accuracy at each stage has not been measured for these configurations, so the cheapest line is not yet the best one.
Fine-tuning is worth it only where the measurements show a specific gap
Error analysis shows which fix to buy. If complete recall at k is low and BM25 beats the dense models, the documents are probably thin, and expansion is the first fix to test. If recall is high but shortlist accuracy is low on near-duplicates, a reranker such as Tool-Rank or a dedicated picker is the next test. If both are high but end-to-end success is low, the failures are in arguments or execution, and a better calling model or stricter schemas will help more than any retriever.
Fine-tune only when an untuned model fails a measured stage on your own catalog and the failure persists after better documentation. The September 2026 annotation study is a reason for caution: part of the published gain from tuned retrievers came from how benchmarks were labelled, not from better retrieval.
Sources
- ToolRet, Retrieval Models Aren't Tool-Savvy (arXiv): https://arxiv.org/abs/2503.01763
- ToolRet project page: https://mangopy.github.io/tool-retrieval-benchmark/
- Tools are under-documented: Simple Document Expansion Boosts Tool Retrieval (arXiv): https://arxiv.org/abs/2510.22670
- Tool-DE paper, HTML version: https://arxiv.org/html/2510.22670v1
- EIT-NLP Tool-DE (Tool-REX) repository: https://github.com/EIT-NLP/Tool-DE
- Tool-Embed-4B model card: https://huggingface.co/Lux1997/Tool-Embed-4B
- Tool-Rank-4B model card: https://huggingface.co/Lux1997/Tool-Rank-4B
- Tool Retrievers Are Underestimated: Annotation Expansion Reveals True Capability (arXiv): https://arxiv.org/abs/2609.08327
- QwenLM, Qwen3-Embedding repository: https://github.com/QwenLM/Qwen3-Embedding
- Qwen3-Embedding-0.6B model card: https://huggingface.co/Qwen/Qwen3-Embedding-0.6B
- Qwen3-Reranker-0.6B model card: https://huggingface.co/Qwen/Qwen3-Reranker-0.6B
- ToolLLM: Facilitating Large Language Models to Master 16000+ Real-world APIs (arXiv): https://arxiv.org/abs/2307.16789
- Anthropic, Tool search tool: https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-search-tool
- Anthropic, Introducing advanced tool use: https://www.anthropic.com/engineering/advanced-tool-use
- Anthropic, Pricing: https://platform.claude.com/docs/en/about-claude/pricing
- OpenAI, Tool search: https://developers.openai.com/api/docs/guides/tools-tool-search
- Parsec, TOD: https://parseclab.ai/tod/
- Parsec, TOD model card: https://huggingface.co/parsecai/tod
- Parsec, TOD repository: https://github.com/daseinlabs/tod