How it works
The context is JSON with the user’squestion, the sources you retrieved
and the draft answer. The keys are yours to choose. One binary
decision, grounded, asks whether the sources establish every factual
claim in the draft. yes means every fact is stated in the sources or follows directly from them.
no means at least one fact is missing from the sources or contradicts them.
Try it
Open this recipe in the playground to run it without an account. The sources there say refunds cover the unused months only. The draft promises a full refund within 14 days, even after a year of use. To run it from your code, setSQWISH_API_KEY as in the quickstart, then send this request:
Act on the answer
Adapt it to your data
It works best on one claim at a time, which is how it was measured. The sample draft makes two claims: that you can cancel any time, and that you get a full refund. For a longer answer:- Split the draft into sentences, and split a sentence again if it makes several claims.
- Check each claim against the same sources, as the
draft, in a request of its own. - Block the answer if any claim’s probability of
yesis below your threshold.
Python
What to watch
- Drafts marked supported that contain a claim the sources never make.
- What “supported” means. It means these sources state it, not that the sources are true.
- Long drafts checked in one go. Split them into claims first.
How well it works
Measured withkettei-core on 651 examples from a public dataset, it chose the right answer 79.0% of the time. Always picking the most common answer scores 53.9%. Your own data will differ, so measure it on examples of yours before you rely on it (improve a decision).
Full results
Full results
- Dataset: AttributionBench (Apache-2.0).
- Sample: 651 rows, 651 measured decisions.
- Decisions measured:
grounded. - Wording: tuned.
Always picking the most common answer has an accuracy of 0.5392, and guessing by how common each answer is has a log loss of 0.6901.These are past results on one dataset, not a promise of accuracy on yours.
Next steps
- Grade how well each passage answers the query: choose the sources before the answer is written.
- Improve a decision: measure it on your own answers and make it more accurate.
- API reference: every field in the request and the answer.
