Knowledge Base Regulation Tracker Standards & Frameworks OSS Directory AI Incident Database Research Paper Library Case Studies Society Articles News Jobs About Charter Sign inBecome a Member
Home/OSS Directory/Long-form factuality (SAFE and LongFact)

Long-form factuality (SAFE and LongFact)

Hallucination and groundedness checking

Code and data for benchmarking long-form factuality: the LongFact prompt set and the Search-Augmented Factuality Evaluator (SAFE), which splits a response into facts and checks each with search. A reference method for measuring factual precision and recall.

factualitybenchmarkdeepmind

How it Works

The Long-form Factuality project by Google DeepMind introduces two key components for evaluating factual accuracy in large language models (LLMs): the LongFact prompt set and the Search-Augmented Factuality Evaluator (SAFE). These tools address the challenge of assessing factual precision and recall in open-ended, long-form responses where traditional evaluation methods fall short.

LongFact is a dataset of 2,280 fact-seeking prompts designed to elicit detailed responses from LLMs. These prompts cover 38 diverse topics and are structured to require comprehensive, multi-fact answers rather than short or binary responses. The prompts are intended to simulate real-world scenarios where users seek in-depth information, such as explanations of complex topics or summaries of historical events.

SAFE operates as an automated evaluation framework that decomposes long-form responses into individual facts and verifies each one using a multi-step process. This process involves querying Google Search with carefully constructed queries derived from the extracted facts. The search results are then analyzed to determine whether they support the factual claims made in the response. SAFE employs an LLM to perform this reasoning, making it scalable and cost-effective compared to human annotation.

The evaluation metric used by SAFE extends the traditional F1 score to accommodate long-form responses. This adapted metric, referred to as F1@K, balances two dimensions: precision, measured as the percentage of supported facts in a response, and recall, calculated as the percentage of provided facts relative to a hyperparameter representing a user’s preferred response length. This approach ensures that evaluations account for both the accuracy of the facts presented and the completeness of the response within a reasonable length.

The project also includes an experimentation pipeline that benchmarks OpenAI and Anthropic models using the LongFact dataset and SAFE. This pipeline automates the generation of model responses, their evaluation, and the computation of factuality metrics. Researchers can replicate these experiments by integrating their API keys into the configuration files provided in the repository.

SAFE’s effectiveness is demonstrated through empirical comparisons with human annotators. In a dataset of approximately 16,000 individual facts, SAFE agreed with crowdsourced human judgments 72% of the time. Additionally, in a random subset of 100 cases where SAFE and human annotators disagreed, SAFE’s evaluations were correct 76% of the time. This performance is achieved at a fraction of the cost, with SAFE being over 20 times cheaper than human annotation, making it a practical solution for large-scale factuality assessment.

Users can clone the GitHub repository and set up a Python 3.10+ environment using conda. Dependencies are listed in requirements.txt, and the pipeline for generating LongFact prompts or running SAFE evaluations can be executed via specific commands.

Use Cases

The LongFact prompt set and SAFE are primarily designed for benchmarking and red-teaming LLMs to identify and mitigate factual inaccuracies in long-form responses. Researchers and developers can use these tools to systematically evaluate how well models maintain factual consistency across diverse topics and response lengths.

One specific use case is the comparative analysis of different LLM families, such as Gemini, GPT, Claude, and PaLM-2. The project’s benchmarking experiments demonstrate that larger models generally achieve better long-form factuality, providing insights into the scalability of factual accuracy with model size. This can guide developers in selecting or optimizing models for applications where precision is non-negotiable.

SAFE’s automated evaluation process is also useful for continuous monitoring of model performance over time. By integrating SAFE into development workflows, teams can track changes in factuality as models are updated or fine-tuned. This proactive approach helps in identifying regressions or improvements in factual grounding, ensuring that deployed models remain reliable.

The transparency provided by SAFE’s fact-verification process also offers a practical example of how automated systems can assist in critical thinking and information verification.

Key Features & Capabilities

  • LongFact Dataset: Comprising 2,280 prompts across 38 topics, LongFact is designed to elicit detailed, fact-rich responses. The prompts are generated using GPT-4 to ensure high-quality and diverse coverage of open-domain topics. This dataset serves as a standardized benchmark for evaluating long-form factuality in LLMs.
  • Search-Augmented Factuality Evaluator (SAFE): SAFE automates the evaluation of long-form responses by breaking them into individual facts and verifying each fact through Google Search queries. The multi-step reasoning process involves constructing search queries from the facts, analyzing search results, and determining factual support. This method reduces reliance on human annotators while maintaining high accuracy.
  • F1@K Metric: An extension of the traditional F1 score tailored for long-form responses, F1@K balances precision (percentage of supported facts) and recall (percentage of facts relative to a preferred response length). This metric provides a nuanced measure of factuality that accounts for both accuracy and completeness in responses.
  • Benchmarking Pipeline: The repository includes a pipeline for benchmarking OpenAI and Anthropic models using LongFact and SAFE. This pipeline automates the generation of model responses, their evaluation, and the computation of factuality metrics. Researchers can customize this pipeline to include other models or adjust evaluation parameters.
  • Cost-Effectiveness and Scalability: SAFE is demonstrated to be over 20 times cheaper than human annotation while achieving comparable accuracy.
  • Empirical Validation: The project includes empirical comparisons between SAFE and human annotators, showing 72% agreement on a dataset of 16,000 facts. In cases of disagreement, SAFE’s evaluations were correct 76% of the time, validating its reliability as an automated evaluator.
  • Open-Source and Reproducible: The entire codebase, including LongFact, SAFE, and the benchmarking pipeline, is released under the Apache 2.0 license.

Sources

Contribute

Spot an error, or know a record we should add? Members can propose additions and submit corrections.