Coder Social home page Coder Social logo

knowhalu's Introduction

KnowHalu: Hallucination Detection via Multi-Form Knowledge Based Factual Checking ๐Ÿ•ต๏ธโ€โ™‚๏ธ๐Ÿ“š

Overview

KnowHalu introduces a pioneering approach to hallucination detection in AI-generated content, focusing on enhancing the reliability and factual accuracy of language models ๐Ÿง . Our work is structured around a comprehensive pipeline designed to identify and rectify hallucinations through a multi-stage factual checking process ๐Ÿ› ๏ธ.

The hallucination detection process begins with Non-Fabrication Hallucination Checking, a preliminary phase aimed at identifying hallucinations based on the specificity of the answers provided ๐Ÿ•ต๏ธ. This is followed by a detailed Factual Checking procedure, comprising five critical steps:

  1. Step-wise Reasoning and Query: Decomposes the initial query into smaller, manageable sub-queries, facilitating a more granular factual verification ๐Ÿ”.
  2. Knowledge Retrieval: Employs Retrieval-Augmented Generation (RAG) for unstructured knowledge and extracts structured knowledge in the form of triplets for each sub-query ๐Ÿ“–.
  3. Knowledge Optimization: Utilizes Large Language Models (LLMs) to summarize and refine the retrieved knowledge into different forms, optimizing it for further processing ๐Ÿ”„.
  4. Judgment Based on Multi-form Knowledge: Applies LLMs to critically assess the answers to sub-queries, utilizing the optimized knowledge forms ๐Ÿง.
  5. Aggregation: Enhances the final judgment by amalgamating predictions from different forms of knowledge, ensuring a thorough and nuanced evaluation ๐Ÿ“Š.

Environment Setup

To set up the environment for running KnowHalu, ensure you have Conda installed. Follow these steps to create a Conda environment with all required dependencies:

conda create --name knowhalu python=3.8
conda activate knowhalu
pip install -r requirements.txt

This setup guarantees that you have all the necessary libraries and frameworks to execute KnowHalu's pipeline effectively.

Usage

QA Task Hallucination Detection

For detecting hallucinations in QA tasks, we provide qa_relevance.py for Non-Fabrication Hallucination Checking and qa_query.py for gathering queries and related knowledge. Use the following parameters for detailed customization:

python qa_query.py --model Starling-LM-7B-alpha --form semantic --topk 2 --answer_type right --knowledge_type ground --query_selection None
  • --model: Specifies the model to be used (default: 'Starling-LM-7B-alpha').
  • --form: Determines the form of the data, either structured or unstructured (default: 'semantic').
  • --topk: Sets the number of top results to retrieve from Wikipedia (default: 2).
  • --answer_type: Defines the type of answer, either 'right' or 'hallucinated'.
  • --knowledge_type: Indicates the source of knowledge, either 'ground' (off-the-shelf) or 'wiki' (retrieved).
  • --query_selection: Specifies the index for the query formulation used; 0 for specific, 1 for general, and None for using both.

Final judgments are obtained using qa_judge.py, following the collection of queries and knowledge.

Notice, the wiki retrieval component here is implemented via WikiChat, further details available at: WikiChat GitHub.

Text Summarization Task Hallucination Detection

The process for detecting hallucinations in text summarization tasks involves summarization_query.py for initial query and knowledge collection, followed by summarization_judge.py for final judgment. The usage is similar to the QA task, adapted for summarization purposes.

This comprehensive guide should enable you to effectively utilize KnowHalu for detecting and analyzing hallucinations in AI-generated content, ensuring higher factual accuracy and reliability ๐ŸŒŸ.

knowhalu's People

Contributors

javyduck avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.