Checking factual accuracy with promptfoo factuality assertions

Use promptfoo's factuality assertion to compare LLM answers with reference answers, with grading categories you can tune and reference sets you can maintain. This page covers how to set it up and where it stops being reliable.

On this page

Checking factual accuracy with promptfoo factuality assertions starts with a reference answer

The factuality assertion in promptfoo compares each model output with a reference answer you supply, using a model grader to decide whether the output agrees with that reference. Teams use it when a feature must give correct answers and they need a repeatable check that runs before every release, rather than relying on someone reading samples by hand. The assertion does not check facts against the open web. It checks the output against the reference text you wrote, so the quality of the check depends on the quality of that reference.

Factuality fits best where the correct answer is known in advance: product specifications, pricing rules, policy questions, eligibility criteria and other facts that change only when your organization decides to change them. It is also useful for regression testing. When you change a prompt, a model or a retrieval setting, the same reference set shows whether answers that used to be right are still right. If the answer is a free-form synthesis of documents supplied at runtime, a RAG faithfulness check is usually the better fit, because the question is whether the answer is supported by the retrieved context. If the expected output is a fixed value, such as a code, a date format or a yes or no result, a deterministic assertion is cheaper, faster and easier to audit.

Before you write assertions, confirm three things with your team: who owns each reference answer, which model will act as the grader, and how often the reference set will be reviewed as the underlying facts change. The grader is a separate model call, so its cost, its rate limits and its data handling are part of your review. The promptfoo documentation for the factuality assertion describes how grading categories and scores work, and it is the right next read before you decide how strict your suite should be (promptfoo docs: Factuality).

How the five factuality grading categories score an answer

The factuality grader places every output into one of five categories, and each category maps to a score. Because the category decides pass or fail, teams need to understand what each one means before they set thresholds or tune the scoring.

A: subset and consistent

The output contains only part of the reference answer, and everything it says agrees with the reference. Illustrative example: the reference lists three refund windows and the output names one of them without contradicting the others. By default this category scores 1. Check whether a partial answer is acceptable for your use case, since the grader will still pass it.

B: superset and consistent

The output contains everything in the reference and adds extra detail that does not contradict it. Illustrative example: the reference gives a product's warranty length and the output also adds a claim about shipping times. By default this category scores 1. Extra claims are not penalized here, so pair this category with a check for unsupported additions if your application must not invent details.

C: same details

The output states the same facts as the reference, with different wording or structure. Illustrative example: the reference says a loan term is 36 months and the output says three years. By default this category scores 1. This is the category that lets correct answers phrased differently pass, so confirm that your reference answers are specific enough to match.

D: disagreement

The output conflicts with the reference on at least one fact. Illustrative example: the reference says a fee is waived for accounts over a set balance and the output says it applies to all accounts. By default this category scores 0, so it is the failure case. Review failing examples in this category first, because a wrong reference answer will show up here as well.

E: different but factually equivalent

The output differs from the reference in content or framing, but the two are factually equivalent. Illustrative example: the reference describes a process in one sentence and the output describes the same steps in a bulleted list with different ordering of the same facts. By default this category scores 1. Read these cases closely, since a grader that accepts equivalence too readily can hide real differences in your data.

Scores are configurable

The default scores are a starting point, not a policy. You can change the score for any category in the assertion configuration, for example to give partial credit to subset answers. Decide the score for each category in writing before tuning thresholds, and confirm the configuration key and syntax in the factuality documentation for your version.

Factuality docs

Factuality assertion configuration options and when each fits

This table compares the settings a team chooses when configuring a factuality assertion: the reference answer, the grader model, per-category scores and the pass threshold. Read each row as a decision point, with the usual reason to change its default. Exact configuration keys should be confirmed against the current promptfoo factuality documentation before you write them into a suite.

OptionWhat it controlsWhen it fitsTrade-off to review
Reference answer (value)The approved answer each output is compared againstUse one vetted reference per test case, written by a subject expert and kept under version controlStale or incomplete references will grade correct answers as wrong
Grader model (provider)The model that classifies each output into categories A through EUse a judge model separate from the model under test, and pin its version so scores stay comparableGrader cost, latency and drift change results between runs
Category A score (subset, consistent)Credit for answers that include only part of the referenceKeep at 1 when partial answers are acceptable, lower it when omissions matter for the userLowering it can hide answers that drop key facts
Category B score (superset, consistent)Credit for answers that add correct detail beyond the referenceLower it when extra detail adds risk, such as dosage or pricing content, and raise it when added context is welcomeExtra detail that is correct but unverified may still be unsafe
Category C score (same details)Credit for answers that match the reference fact for factUsually keep at 1, since it is the target outcomeLittle reason to change; a lower score makes the suite harder to read
Category D score (disagreement)Credit for answers that contradict the referenceSet to 0 for strict compliance or regulated content, where any contradiction must failDefault is already 0; changing it upward weakens the check
Category E score (factually equivalent)Credit for answers that differ in wording but agree in factKeep at 1 so correct answers phrased differently are not penalizedLowering it forces teams to match exact wording and inflates failures
Pass thresholdThe minimum score the assertion needs to passSet high for compliance content and lower for exploratory evals, and review it against a labeled sampleA threshold set without a labeled sample is a guess and will need tuning

How to set up a factuality eval in promptfoo

This sequence takes you from a clean install to a working factuality eval that compares model answers against reference answers and grades each one. The result is a repeatable run you can review, tune and extend as your test set grows.

  1. Install promptfoo and confirm Node.js

    The engineer running evals installs promptfoo from npm on a machine with Node.js 22.22.0 or newer, which is the minimum version the current npm package requires. Check your Node.js version first, then install promptfoo globally or run it through npx from a project folder. The step is done when the promptfoo command prints its version number without errors.

  2. Create a project and configure the target

    Create a project folder with a promptfooconfig.yaml file and point the config at the model or application you want to test. Set the provider, the prompt template and any settings the target needs, such as the model name and API key from an environment variable. Keep keys out of the config file itself. The step is done when promptfoo can load the config and lists the provider you expect.

  3. Write test cases with reference answers

    Write each test case with the question as the input and a reference answer that states the facts a correct response must contain. Keep reference answers short and specific, and avoid wording that only one correct phrasing could match. Review the set with a subject expert who can confirm that each reference is accurate. The step is done when every test case has a reference, and the expert has signed off on the first batch.

  4. Add the factuality assertion and grader

    Attach a factuality assertion to each test or to the defaults block, and set a grader model that is separate from the target under test. Confirm the grader model is reachable from your machine by running a single call with the same credentials before the full eval. The step is done when a one-test run returns a grade without a connection or authentication error.

  5. Run the eval and read the grading categories

    Run promptfoo eval against the config and open the results view or the output file. Each output is sorted into one of five factuality categories, and the default scoring gives a point to every category except disagreement. Look at one failing output and confirm the category it received matches what you see when you compare it to the reference. The step is done when you can explain the category of the failing output in your own words.

  6. Adjust scores and tune the reference set

    If a category does not match your intent, change its score in the assertion configuration, or rewrite the reference to state the required facts more clearly. Rerun the same eval so you can compare results before and after the change. Record the grader model, target model and config version with each run so results stay comparable. The step is done when a rerun produces stable categories on the cases you reviewed.

Building reference sets that stay accurate over time

A factuality assertion is only as trustworthy as the reference answer it grades against, so the reference set needs the same care as the code under test. Write each reference to contain the facts the answer must get right and nothing more. The factuality grader sorts each output into one of five categories: a subset of the reference that is consistent, a superset that is consistent, same details, disagreement, or different but factually equivalent. By default every category scores 1 except disagreement, which scores 0. A reference padded with background detail invites outputs that are a subset and get a full score for leaving things out, while a reference stuffed with several claims makes it hard to tell which fact a failing output actually got wrong. Keep each test to one fact where you can, and split multi-part questions into separate tests so a failure points to a single claim.

Source every reference from an approved document, such as a current policy, product specification, rate sheet or regulatory text your organization has signed off on, and record the document name, section and version beside the test. Give each reference set a named owner who answers for its accuracy, approves changes and decides which source wins when two documents disagree. Store references in version control next to the eval config so that every change has an author, a date and a reason. Confirm with your own content owners how they publish updates, because a reference that was right when written can become wrong after a product change, a fee revision or a policy update.

A stale reference causes two kinds of error. If the source changed and the reference did not, a correct model answer can fail, and the team may start tuning prompts to match an outdated fact. If the reference is wrong in the other direction, an incorrect answer can pass because it matches the old record. Schedule a review tied to each source change, and when a reference is updated, rerun the suite against the previous and new versions so the change in score is explained rather than surprising. Keep a short log of which references changed and why, so a drop in pass rate can be traced to a content update instead of a model regression.

Trade-offs of model-graded factual checks

A factuality assertion is only as trustworthy as the model grading it and the reference answers it compares against. The cards below cover the decisions that shape cost, stability and coverage before you adopt model-graded factual checks in a test suite.

Grader cost and latency per run

Every factuality assertion sends a request to a grader model, so each test case adds a paid call and wait time on every run. The cost grows with the number of cases, the number of prompts and models under test, and the number of runs in CI. Before adopting it, estimate the call volume from your planned suite size and confirm the grader's pricing and rate limits with your provider. Consider running factuality checks on a focused subset and keeping cheaper deterministic assertions for everything else.

Grader drift when the model changes

A grader model can change its grading behavior after an upgrade, a provider-side update or a switch to a different model. When that happens, scores move even though your application did not change, and a previous baseline stops being comparable. Pin the grader to a specific model version where your provider allows it, record the grader in every eval result, and re-run a fixed set of known answers whenever the grader changes so you can see the shift before trusting new scores.

Dependence on reference quality

Factuality grading compares the output with a reference answer, so a wrong or outdated reference produces confident but wrong verdicts. Reference sets need an owner, a source for each answer and a review date, especially for facts that change. Check a sample of references with a subject expert before scoring a release, and treat a sudden jump in disagreement results as a possible reference problem before you blame the model.

Limited coverage of open-ended questions

Factuality checks work best when a question has one defensible answer. For open-ended tasks such as summaries, recommendations or advice, there may be many correct responses, and a single reference will mark good answers as wrong or disagreement as correct. For those tasks, decide early whether factuality is the right measure at all, and use a rubric or a checklist of required facts instead, so the test measures what matters to your users.

Keeping the grader separate from the target

If the grader is the same model as the application under test, it may favor its own phrasing and miss its own errors. Choose a grader model that differs from the target, and document the choice in your eval design. Confirm that the grader is approved for the data you send it, since reference answers and outputs may contain customer or regulated content, and that the grader provider's terms cover that use.

Factuality docs

Security and data handling for factuality evals

Where does promptfoo send my reference answers and model outputs?

promptfoo runs on the machine that starts the eval and talks directly with the configured LLM, so reference answers and outputs leave that machine only as requests to the providers you configure. A factuality check is a model-graded assertion, which means the reference answer, the output under test and the grading prompt are sent to the grader provider you set, which may be a different vendor from the model under test. Confirm with each provider its data retention, training and region terms before loading internal material, and check the grader setting in your config so you know exactly which endpoint receives the data.

Are internal facts in reference sets safe to use in factuality evals?

They are safe to use only if the provider receiving them is approved for that data classification. Reference sets often contain pricing rules, policy wording, customer facts or product roadmap details, and each one is transmitted to the grader on every run. Before adding internal facts, classify the reference file, confirm the grader provider is approved for that class, and consider using a grader inside your own infrastructure where your provider approval process allows it. Keep reference files in your normal repository access controls rather than in shared spreadsheets.

Who can see factuality eval results and reference answers?

Anyone who can read the output directory, the CLI results or the CI artifacts can see the reference answers, model outputs and grader reasons stored with them. Results are written locally by default, so access depends on where your team keeps them. Set artifact retention in your pipeline, restrict who can download CI artifacts, and avoid posting full result files into public chat channels or issue trackers. Grader reasoning often quotes the internal reference text, so treat result files with the same sensitivity as the reference set itself.

How should provider API keys be stored for factuality evals in CI?

Store provider keys as masked secrets in your CI system and pass them to the job as environment variables, never as values written into the promptfoo config or committed to the repository. Use separate keys for the target model and the grader where possible, so you can rotate or revoke one without breaking the other. Limit who can edit pipeline secrets, scope keys to the project and spending limits your provider offers, and confirm that debug logging in your pipeline does not echo environment variables. Check your CI platform's documentation for how masked and protected variables behave on forks and merge requests.

Can I run a self-hosted promptfoo server for my team's factuality results?

Not for production shared use. The self-hosted promptfoo app stores data in a local SQLite database that cannot be shared across replicas, and it has no RBAC, horizontal scaling, built-in authentication or SSO. The promptfoo documentation states it is not recommended for production use. For a single engineer or a small trial, a local server can be useful, but it should not be exposed to a wider network as a shared results store without your own access control in front of it.

What do teams need if several people must access factuality results?

Teams that need shared, access-controlled results should review the promptfoo Enterprise options rather than rely on the self-hosted app. Per the promptfoo pricing page, Enterprise adds team sharing, teams-based access control and SSO, custom roles and permissions, and continuous monitoring, and the On-Premise edition runs that functionality on your own infrastructure with complete data isolation and a dedicated deployment engineer. Pricing is custom. Ask the vendor for written confirmation of the SSO, role and audit capabilities you need, and ask how the On-Premise deployment handles grader traffic.

Who should own the security review of factuality eval data handling?

Your security or privacy team should own the data classification and provider approval decisions, while the engineering team owns the config, secrets and pipeline settings that enforce them. Write down which reference sets may go to which grader, record the retention terms you confirmed with each provider, and review the decision when you change models or grader settings. If you want an outside check of how the eval setup handles credentials and access, DeployOpen can include the promptfoo setup in a security testing engagement under a written scope.

Limits to confirm before relying on factuality scores

A factuality score is only as trustworthy as the grader behind it. The checks below cover the grader model, the domain language, the scoring weights and the history of results, and each one is best confirmed with the promptfoo documentation or a pilot run on your own reference set.

Grader model availability and limits

Confirm which models you can use as the factuality grader in your environment, and whether your provider account has the request and token limits a full suite needs. A grader that is rate limited mid-run can turn a clean suite into a partial one. Ask your provider for the current limits for the grader model you plan to use, then run the full reference set once to measure how long grading takes before you set it into CI.

Factuality docs

Grader behavior on domain language

Test whether the grader reads your domain's terms the way your experts do. Drug names, policy codes, legal clauses, currency amounts and units of measure can be paraphrased in ways that look like disagreement to a grader that does not know the field. Run a pilot set of answers your subject-matter reviewers have already marked correct, and check whether the grader scores them in the categories you expect.

Default category scores and risk tolerance

The default scores decide what counts as a pass, so confirm they match your tolerance for error. Subset and superset answers score as passing by default, which may be acceptable for a summary but not for a dosage or a fee amount. Decide in writing which categories should pass, which should fail, and whether any category needs a partial score, then configure those values explicitly rather than accepting the defaults.

Retention and comparison across releases

Decide how grader outputs are stored, for how long, and where they can be compared between releases. A factuality score from one prompt version means little if the grader, its model version or the reference set changed in the meantime. Record the grader model, the configuration and the reference set version with every run, and confirm where promptfoo keeps these results in your setup before you rely on trend lines.

Reference set ownership and review

Confirm who owns the reference answers and how they are updated when facts change. A reference set that is out of date will mark correct answers as wrong, and the grader will not notice. Ask your domain owners to sign off on each reference answer, assign a review cycle, and check that the owner of the reference set is the same person who approves changes to the scoring configuration.

What teams ask before adding factuality checks

What drives the cost of a promptfoo factuality suite?

Most of the cost comes from three parts: the model calls made by the grader on every run, the time spent writing and approving reference answers, and the time spent reviewing outputs the grader places in the disagreement category. The promptfoo software itself is open source under the MIT license, so the license is not the cost driver. Grader calls recur every time the suite runs, so the size of the suite and how often it runs set the ongoing bill. Reference creation is one-time work that grows with the number of domains covered and needs subject-matter time. Ask any partner quoting the work to split the fee into setup, reference set creation, grader configuration, and recurring run support, and to state which items assume your own model accounts.

How long does a first factuality suite take to build?

The time depends mainly on how many reference answers you need, how fast your domain experts can approve them, and how many distinct question types your application answers. A narrow product with a short list of facts moves faster than a system covering policies, pricing and regulated guidance across several business lines. Setup of the eval configuration is usually the smaller share of the effort. Other drivers include access to source documents, the number of models being compared, and how many rounds of reviewing disagreements your team needs before the grader matches expert judgment. Ask for a written timeline tied to a defined scope, with the number of reference items and reviewers named explicitly.

What does the work need from our team?

It needs two kinds of people. Domain experts write, check and approve the reference answers, because a factuality grader can only be as accurate as the facts it compares against. An engineer sets up the promptfoo configuration, connects the application or model under test, wires the suite into your test runs, and reads the results. The experts should also agree on how strict the grading is, including which differences count as acceptable paraphrase. Plan time for these people before the build starts, since reference approval is the step most often delayed. Confirm who owns the reference set after handover, because it must be updated when source facts change.

Can our own team build factuality checks without a partner?

Yes, for a small suite. A team with one engineer who knows the application and one domain expert who can approve reference answers can write a basic factuality configuration from the promptfoo documentation and run it locally. The Community edition is free and includes all LLM evaluation features, so the tooling does not add a license cost. A partner becomes more useful when the suite must cover many domains, when results need to be reviewed by compliance or audit teams, when you need reference sets that are versioned and governed, or when your team lacks time to maintain the suite as the application changes. Decide early which parts stay in-house so the handover is written down.

How does factuality differ from RAG faithfulness?

Factuality compares an output with a reference answer that someone wrote and approved, so it asks whether the answer agrees with an agreed ground truth. RAG faithfulness asks whether the answer is supported by the context the retrieval step passed to the model, so it checks the answer against what the system retrieved. An answer can be faithful to a retrieved document that is wrong, and it can be factually correct while still going beyond the retrieved text. Many teams use both: retrieval metrics show whether the right context was found, faithfulness shows whether the answer stayed inside it, and factuality shows whether the final answer matches the reference. Your sibling evaluation guides cover the RAG side in more depth.

What should we confirm about grader models and data handling?

Confirm which model acts as the grader, where it runs, and what data it receives. The promptfoo documentation states that the software runs locally and talks directly with the LLM, so the destination of each grading request is set by your provider configuration. Check whether reference answers, prompts and outputs contain customer or regulated data, and whether your data policy allows sending them to the chosen grader. A judge model that is a different model from the one under test is commonly used, but confirm this choice with your own evaluators. Record these decisions in the suite documentation so reviewers can trace how each result was produced.

Does a factuality suite replace human review?

No. A factuality suite gives a repeatable check that flags outputs which disagree with the reference, so changes between releases can be seen quickly. It does not confirm that the reference answers are correct, and it does not cover questions nobody wrote a reference for. Humans still need to review disagreements, update references when facts change, and decide whether a flagged output is a real error. Budget for that review as a recurring activity, since it is the part of the work that keeps the suite trustworthy over time.

How DeployOpen scopes factuality eval work

A written scope agreed before work starts is the starting point for every factuality engagement. DeployOpen sets out which target models and applications are under test, where the reference answers come from, how the five grading categories map to pass and fail for your use case, and which score values apply to each category. Those decisions change what the suite can detect, so they are settled on paper before any test case is written. The scope also names the CI system the suite will run in, the people who receive the reports, and the handover items that leave with you at the end.

DeployOpen deploys promptfoo inside your own infrastructure, so the runner, the configuration files, the reference sets and the stored results stay in your cloud accounts, data center or network. Where the suite calls a hosted model, the scope records which provider account and credentials it uses, and who in your organization approves that data path. Engagements are fixed-scope, with deliverables, acceptance checks and timelines agreed in writing. Typical deliverables include the eval configuration, the reference set with its review notes, a CI job, and a short runbook. Confirm with DeployOpen which of these your team needs and which access it must provide before the work starts.

Factuality suites need upkeep after handover, because reference answers go stale and model providers change behavior between releases. DeployOpen offers retainers for ongoing suite maintenance, covering reference set updates, threshold reviews and reruns after model or prompt changes. Ask for the retainer terms in writing, including what triggers work, how reference changes are reviewed, and how results are reported back to your team. Ask also how the suite will be handed over so that your engineers can run and extend it without DeployOpen present.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.