CoolFace
Datasetpublic

Laurie/faithfulness-qa-dataset

Faithfulness-QA: A Counterfactual Entity Substitution Dataset for Training Context-Faithful RAG Models Overview Faithfulness-QA is a large-scale dataset of 99,094 question-answer pairs designed to train and evaluate the faithfulness of Retrieval-Augmented Generation (RAG) models to retrieved context. The core idea is counterfactual entity substitution: for each QA sample, we replace the answer-bearing entity in the context with a type-consistent alternative… See the full description on the dataset page: https://huggingface.co/datasets/Laurie/faithfulness-qa-dataset.

sourceHugging Facemitupdated 2mo agoView on Hugging Face
0likes83downloads
Dataset Card

Faithfulness-QA: A Counterfactual Entity Substitution Dataset for Training Context-Faithful RAG Models

![License: MIT](https://opensource.org/licenses/MIT) ![Dataset: 99K]() ![arXiv](https://arxiv.org/abs/2604.25313) ![HuggingFace Dataset](https://huggingface.co/datasets/Laurie/faithfulness-qa-dataset)

Overview

Faithfulness-QA is a large-scale dataset of 99,094 question-answer pairs designed to train and evaluate the faithfulness of Retrieval-Augmented Generation (RAG) models to retrieved context.

The core idea is counterfactual entity substitution: for each QA sample, we replace the answer-bearing entity in the context with a type-consistent alternative, creating a controlled conflict between the context and the model's parametric knowledge. A faithful model should output the replacement entity (from context), not the original entity (from memory).

Dataset Statistics

SourceTotalTrainValidationTest
SQuAD49,09439,2754,9094,910
TriviaQA50,00040,0005,0005,000
Total99,09479,2759,9099,910

Entity Type Distribution

TypeSQuADTriviaQA
PERSON9,775 (19.9%)22,871 (45.7%)
ORG10,114 (20.6%)8,186 (16.4%)
DATE9,997 (20.4%)2,057 (4.1%)
GPE6,292 (12.8%)11,810 (23.6%)
CARDINAL6,568 (13.4%)1,348 (2.7%)
NORP4,004 (8.2%)1,247 (2.5%)
LOC1,629 (3.3%)1,952 (3.9%)
EVENT715 (1.5%)529 (1.1%)

Usage

python
from datasets import load_dataset

# Load all data (both SQuAD and TriviaQA)
dataset = load_dataset("Laurie/faithfulness-qa-dataset")

# Load only SQuAD subset
squad = load_dataset("Laurie/faithfulness-qa-dataset", "squad")

# Load only TriviaQA subset
triviaqa = load_dataset("Laurie/faithfulness-qa-dataset", "triviaqa")

# Example: access a training sample
sample = dataset["train"][0]
print(f"Question: {sample['question']}")
print(f"Modified context: {sample['modified_context'][:200]}...")
print(f"Faithful answer: {sample['faithful_answer']}")

Data Format

Each sample contains the following fields:

FieldTypeDescription
idstringOriginal sample ID from the source dataset
questionstringThe question text
original_contextstringUnmodified context from the source dataset
modified_contextstringContext after counterfactual entity substitution
original_answerstringGround-truth answer from the source dataset
faithful_answerstringCorrect answer given the modified context (= replacement entity)
original_entitystringThe named entity that was replaced
replacement_entitystringThe new entity substituted in
entity_typestringNER type: PERSON, GPE, ORG, DATE, CARDINAL, NORP, LOC, or EVENT
sourcestringSource dataset: squad or triviaqa

Intended Use Cases

  1. 1.Faithfulness-aware fine-tuning: Train with (modified_context, question) → faithful_answer to teach models to follow context over parametric memory.
  2. 2.Attention-based faithfulness loss: Supervise cross-attention weights to ensure models attend to retrieved context.
  3. 3.Faithfulness evaluation: Measure the rate at which models output the faithful answer (context-grounded) vs. the original answer (parametric).
  4. 4.Knowledge conflict research: Study LLM behavior when retrieved context contradicts parametric knowledge.

Methodology

The pipeline consists of four stages:

  1. 1.Entity Bank Construction: Extract all named entities from SQuAD contexts using SpaCy NER → 76,953 entity bank across 8 types.
  2. 2.NER & Answer Entity Match: Match the answer to a recognized entity via exact match, substring match, or positional overlap.
  3. 3.Counterfactual Substitution: Replace entity with a same-type alternative from the entity bank (with length compatibility constraints).
  4. 4.Quality Filtering: Apply 6 quality filters, then split 80/10/10.

Citation

bibtex
@misc{zhang2026faithfulnessqa,
  title={Faithfulness-QA: A Counterfactual Entity Substitution Dataset for Training Context-Faithful RAG Models},
  author={Zhang, Qi},
  year={2026},
  url={https://github.com/qzhangFDU/faithfulness-qa-dataset}
}

License

MIT License. The source datasets (SQuAD, TriviaQA) are used under their respective licenses.