Choosing the Right AI Model, Automatically
Updated
Picture a team that picks an AI model in March. They read a leaderboard, try it on a few questions and ship it. By June there are three newer models, one of them cheaper and about as good.
Nobody has time to test them, so the March choice stays. Nobody decides to overpay either. The decision never comes up again.
A model choice is a decision with a shelf life. New models appear every few weeks, and the best one for your data may not be the one that tops a public benchmark. This is how Ask Jentic chooses the model that answers questions about a repo, and how you can do the same for your own workload.
Test on your own data
A leaderboard measures a general workload. Yours is specific. For Ask Jentic, the workload is answering questions from one repo's documentation, so that is what we test.
For each repo we build a test set from its indexed docs. It mixes four kinds of question: simple lookups, questions that cross modules, questions about integrations, and questions about decisions. Each comes with a reference answer. We run the same retrieval that production uses, send the same prompt, and collect every candidate model's answer.
Score what you care about
We score each answer on three things: faithfulness to the docs, relevance to the question, and factual correctness against the reference answer. A judge model does the scoring, using RAGAS, an open-source evaluation library.
Faithfulness counts double. An answer that sounds right and goes beyond the docs is worse for us than a plainer one that stays inside them. Decide which failure costs you most and weight it.
Put guardrails on the choice
Picking the highest score is not enough. A model has to clear some rules first.
- A faithfulness floor. Below 0.80 a model is out, whatever else it scores.
- A cost cap. A candidate can cost at most 1.5 times the current default per question.
- Ties go to the cheaper model. Among models within 0.02 of the best quality score, the cheapest wins.
- A reluctance to switch. A repo keeps its model unless the winner is clearly better, or about as good and at least 10% cheaper. Small differences are noise, and without this rule the choice flips back and forth.
Decide when to test again
Testing costs real money, so it runs on these triggers:
- On a repo's first analysis, so it gets a suitable model from the start. This run is lighter: the default, the cheapest candidate and the newest one.
- Every quarter, with the full set of candidates.
- When the docs change a lot. If the number of indexed chunks moves by 30% or more, we test again, with a minimum gap of 14 days between runs.
Let new models in, through a gate
Each run asks the provider which models currently exist, so a new model gets tried without anyone editing a list. Three rules keep that safe.
- Only main-line text models with standard names qualify. Audio, image, search and dated snapshot models are filtered out, and so are codename models, so an unfamiliar model never gets in without a decision.
- A candidate must have a price on file. The cost cap needs it. A new model without a price is not tested. It is reported so someone adds the price.
- Only models at least as new as the default count as new. Older models are not tried as new candidates.
Cap what testing costs
Judging is most of the bill. We skip judging any model whose measured cost already exceeds the cap, since it cannot win. Each repo also has a monthly testing budget, and a repo that has spent it does not start another run.
What it found for us
On our workload, gpt-4.1 matched gpt-4o on answer quality at a lower cost, and gpt-4o-mini was clearly less faithful to the docs. That made gpt-4.1 our default. A repo can still end up with a different model if its own docs favor one.
These results are specific to answering questions from documentation. They may not carry over to your task.
The limits
A test set of a dozen questions is a small sample, so close results can swing. The judge is a model too, and it has its own biases. The test measures one workload. We handle this with the tie rule and the reluctance to switch, but they reduce the problem and do not remove it.
Copy-paste model selection policy
WORKLOAD: <what the model does, on whose data> TEST SET - Questions per run: <number> - Kinds: <e.g. lookup / multi-step / edge case> - Each has a reference answer: yes / no SCORES (weights) - <the failure that costs most>: x2 - <relevance to the question>: x1 - <correctness vs reference>: x1 RULES - Floor: <score> on <the key metric>, or the model is out - Cost cap: <n>x the current default, per request - Tie band: <score>; cheapest inside the band wins - Switch only if: clearly better, or about as good and >= 10% cheaper WHEN TO RE-TEST - First use of a new dataset - Every <n> days - When the data changes by >= <percent>, at least <n> days apart NEW MODELS - Qualify if: standard name, priced, at least as new as the default - Unknown names wait for a person BUDGET - Max testing spend per <dataset> per month: <amount> - Skip judging models over the cost cap
Frequently asked questions
How many test questions do I need?
We use 12 per run. More gives steadier results and costs more to score. Start small, and treat close results as ties.
Why not always use the newest model?
Newer is often better, but not always for your data, and it can cost more. Testing tells you which.
Can I use a public leaderboard instead?
It can shortlist candidates. It cannot tell you how a model does on your documents, so test the shortlist yourself.
Does this only work with one provider?
The approach works with any provider. Our implementation currently finds new models from OpenAI's model list.
Skip the manual work
Ask Jentic runs this for each repo: it tests candidate models on the repo's own docs and uses the one that answers best within the cost cap.