Question Answering

Predict canonical answers from a prompt corpus. Question-shaped input, predicted-answer output, calibrated confidence to decide auto-vs-route-to-human.

Question Answering: screenshot from the Grocery demo
๐Ÿ› Grocery_predict_queryCross-vertical
In shortPredict canonical answers from a prompt corpus โ€” question-shaped input, predicted-answer output, calibrated confidence to decide auto-vs-route-to-human.

The problem

Customer support and internal-help systems have spent years moving from "search for the answer" to "ask the question, get the answer." The current generation routes questions to LLMs; the answer quality is variable, the confidence is uncalibrated, and the cost per query is non-trivial.

The most-asked questions have answers that the team has already written, tagged, or recorded. Help articles, FAQ pages, internal docs, previous ticket resolutions โ€” the corpus is large. The job at decision time is: given the user's question, which canonical answer from the corpus is the right one? With what confidence?

How it works

_predict on a prompts-and-answers table returns the most likely canonical answer for a given user question. The system learns from historical question-answer pairs: which questions phrased which way map to which canonical answers, and how confidently. New questions get a predicted answer with calibrated probability.

Above the auto-answer threshold, the application returns the predicted answer directly. Between thresholds, the application returns it as "likely answer, please confirm." Below the threshold, the question routes to a human responder โ€” and the human's response becomes the new ground truth. The corpus expands by usage.

{
  "from": "prompts",
  "where": {
    "prompt": "Which payment methods do you provide?"
  },
  "predict": "answer",
  "select": ["$p", "$why", "answer"],
  "limit": 3
}

For the full architecture, see the technology overview. For the broader narrative across multiple use cases, read The Predictive Application.

See it live

This use case runs in the ๐Ÿ› Grocery demo today. Click through to the live application and inspect the queries that produce the result.

Open the live demo โ†’

Build it with Claude Code

Paste this prompt into Claude Code, or another coding agent, in your own codebase. It runs Aito locally from the Docker image, reads the API docs written for agents, and follows a working reference implementation.

Question answering: a prompt for Claude Code
Add question answering to this codebase using Aito, a predictive database. The feature: answer incoming customer questions by finding the best-matching resolved answer, with a confidence.

1. Run Aito locally: `docker pull ghcr.io/aitohq/aito`, then follow https://aito.ai/docker/ to start it with your own API keys (keep them in the environment, never in code).
2. Read https://aito.ai/docs/api/llms.txt for the v2 query shapes before writing any query.
3. Read the use-case guide: https://aito.ai/use-cases/question-answering/
4. Use this reference implementation as the pattern (schema, data load and queries): https://github.com/AitoDotAI/aito-agent-demo/blob/main/src/aito_client.py and https://github.com/AitoDotAI/aito-agent-demo/blob/main/scripts/support_fixture/schema.json
5. Find the matching tables in this codebase, design the Aito schema for them (links between tables where we have foreign keys), and load a sample.
6. Measure before wiring the UI: hold out recent rows and report how often the item actually chosen is in the top 3, against the order we show today.
7. In the UI, show the ranking as suggestions, with the reasons where the query gives them. Nothing is applied without the user.

Ask me before changing anything outside the new feature.

Frequently asked

How does this compare to GPT-style question answering?

GPT generates answers from its training data plus the prompt. _predict returns answers from YOUR corpus, ranked by conditional probability that this canonical answer matches this question. The two are complementary: GPT for open-ended questions outside your domain; _predict for the questions your team has already answered before.

How accurate is this on questions that have never been asked before?

Genuinely novel questions return low confidence; the system says it doesn't know and routes to human. Variations on previously-asked questions get high confidence โ€” the system reads the variation as a known-question with new wording. The conditional-probability machinery handles paraphrasing through the column distribution.

Can the same answer apply to many different question phrasings?

Yes. The conditional probability is over (question โ†’ answer). Many question phrasings can map to the same answer with high confidence. The corpus learns the mapping from observation.

Does this need a separate knowledge base, or does it work on existing docs?

Existing docs work if they have a question-and-answer structure. Help-center articles with FAQ sections; support-ticket history with resolved-question and resolution pairs; internal wikis with structured topic pages. The corpus shape is "prompt + canonical answer" โ€” whatever format your team has used.

How quickly does the system learn new canonical answers?

Three observations of a new question-answer pair reaches stable prediction. The system can answer the new question with reasonable confidence by the third occurrence. By ten occurrences, the answer is fully calibrated and safe for auto-answer.