Prompt Chain

Evaluate Model Factuality on HuggingFace Datasets

Promptfoo config benchmarking model truthfulness against the TruthfulQA dataset, with custom weighted factuality scoring.


78
Spark score
out of 100
Updated last month
Version code-scan-action-0.1

Add to Favorites

Why it matters

Assess the factual accuracy of language models using the TruthfulQA dataset. Ensure your AI avoids generating common misconceptions and provides truthful answers.

Outcomes

What it gets done

01

Utilize the TruthfulQA dataset from HuggingFace.

02

Test language models for factual correctness.

03

Identify and mitigate the generation of false answers.

04

Evaluate model performance on questions designed to elicit misconceptions.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/pfoo-huggingface-dataset-factuality | bash

Overview

Huggingface Dataset Factuality

This Promptfoo example benchmarks model truthfulness against the TruthfulQA dataset, auto-generating test cases from HuggingFace's EleutherAI/truthful_qa_mc validation split and scoring answers with custom weighted factuality categories. Use it as a template when benchmarking a model's truthfulness against TruthfulQA with fine-grained control over partial-answer scoring.

What it does

This Promptfoo config evaluates factual accuracy against the TruthfulQA benchmark. Tests aren't hand-written in the YAML - they're generated dynamically by a dataset_loader.ts:generate_tests script that pulls the EleutherAI/truthful_qa_mc dataset's validation split from HuggingFace and formats each question into Promptfoo test cases. The default provider is Anthropic's claude-sonnet-4-6, with commented-out alternatives for a Bedrock-hosted Llama model, OpenAI, and Google Gemini, so the config can be repointed to a different model or grading provider.

A defaultTest sets custom scoring weights for Promptfoo's factuality grading categories: an answer that's a strict subset of the correct answer scores 1.0, a superset scores 0.8, exact agreement scores 1.0, outright disagreement scores 0.0, and a factually compatible but differently worded answer scores 0.7.

When to use - and when NOT to

Use it as a template for benchmarking a model's truthfulness against the TruthfulQA dataset, with fine-grained control over how partial or differently phrased but correct answers are scored. Do not use it if you need a custom or proprietary factuality dataset instead of TruthfulQA, or if the default equal-weight factuality scoring already fits your needs.

Inputs and outputs

Input: the YAML config - prompt template, provider choice, and factuality scoring weights - plus a dataset_loader.ts script that fetches and formats the TruthfulQA validation split. Output: Promptfoo's evaluation report, scoring each generated test case against the weighted factuality categories.

Integrations

Uses Promptfoo's factuality assertion and grading system with custom category weights, its dynamic test-generation via an external TypeScript loader, and the HuggingFace-hosted EleutherAI/truthful_qa_mc dataset.

Who it's for

Teams benchmarking a model's truthfulness on a standard dataset like TruthfulQA who need fine-grained control over how partially correct or differently worded answers get scored.

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.