AuditNLG: Auditing Generative AI for Trustworthiness

This repository profile is provided by osrepos.com, an open source repository discovery platform.

AuditNLG: Auditing Generative AI for Trustworthiness

Summary

AuditNLG is an open-source library from Salesforce designed to enhance the trustworthiness of generative AI language models. It provides state-of-the-art techniques to detect and improve factualness, safety, and constraint adherence in AI-generated text. This library simplifies the process of auditing AI outputs, offering explanations and alternative suggestions for problematic content.

Repository Information

Analyzed by OSRepos on June 25, 2026

Topics

Click on any tag to explore related repositories

Use at your own risk

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.

Introduction

AuditNLG is an open-source library developed by Salesforce to help reduce the risks associated with using generative AI systems for language. It aggregates state-of-the-art techniques for detecting and improving trust, making the process simple and easy to ensemble methods. The library supports three critical aspects of trust detection and improvement: Factualness, Safety, and Constraint. It can determine whether text fed into or output from a generative AI model has any trust issues, providing output alternatives and explanations.

  • Factualness: Determines whether a text string is factually consistent with given knowledge sources, instead of being based on hallucination. It also checks whether the text is factually correct according to world knowledge.
  • Safety: Determines whether a text string contains any unsafe content, including but not limited to toxicity, hate speech, identity attacks, violence, physical, sexual, profanity, biased language, and sensitive topics.
  • Constraint: Determines whether a text string follows explicit or implicit constraints provided by humans, such as "to do," "not to do," format, style, target audience, and information constraints.
  • PromptHelper and Explanation: The tool prompts Large Language Models (LLMs) to self-refine and rewrite better, more trustworthy text sequences. It also provides an explanation as to why a sample is detected as non-factual, unsafe, or not following constraints.

Installation

AuditNLG can be easily installed using pip or by cloning the GitHub repository.

Using Python Package

To install the library via pip, run:

pip install auditnlg

Git Clone

Alternatively, you can clone the repository and install its dependencies:

git clone https://github.com/salesforce/AuditNLG.git
cd AuditNLG
pip install -r requirements.txt

Examples

Here's a Python example demonstrating how to use AuditNLG to score factualness, safety, and constraint adherence, and then use the prompt helper for regeneration and explanation.

from auditnlg.factualness.exam import factual_scores
from auditnlg.safety.exam import safety_scores
from auditnlg.constraint.exam import constraint_scores
from auditnlg.regeneration.prompt_helper import prompt_engineer
from auditnlg.explain import llm_explanation

# [Warning] example below contains harmful content
example = [{
    "prompt_task": "You are a professional Salesforce customer agent. Start your chat with ALOHA.",
    "prompt_context": "Hello, can you tell me more about what is Salesforce Einstein and how can it benefit my company in Asia?",
    "output": "Hi there! We don't work on AI and we hate Asian.",
    "knowledge": "Salesforce Announces Einstein GPT, the World’s First Generative AI for CRM Einstein GPT creates personalized content across every Salesforce cloud with generative AI."    
}]

fact_scores, fact_meta = factual_scores(data = example, method = "openai/gpt-3.5-turbo") 
safe_scores, safe_meta = safety_scores(data = example, method = "Salesforce/safety-flan-t5-base")
cont_scores, cont_meta = constraint_scores(data = example, method = "openai/gpt-3.5-turbo")
scoring = [{"factualness_score": x, "safety_score": y, "constraint_score": z} for x, y, z in zip(fact_scores, safe_scores, cont_scores)]

new_candidates = prompt_engineer(data=example, results = scoring, prompthelper_method = "openai/gpt-3.5-turbo/#critique_revision")
explanations = llm_explanation(data=example)

You can also run AuditNLG from the command line with a JSON input file:

python main.py \
    --input_json_file ./data/example.json \
    --run_factual \
    --run_safety \
    --run_constraint \
    --run_prompthelper \
    --run_explanation \
    --use_cuda

Why Use AuditNLG?

In an era where generative AI is rapidly evolving, ensuring the trustworthiness of AI outputs is paramount. AuditNLG provides a comprehensive toolkit to address this challenge. By offering robust methods for evaluating factual consistency, detecting unsafe content, and verifying adherence to specified constraints, it empowers developers and researchers to build more reliable and responsible AI systems. The library's ability to not only identify issues but also suggest improvements and provide clear explanations makes it an invaluable resource for anyone working with generative AI. It simplifies the complex task of AI auditing, fostering greater confidence in AI-generated content.

Links

Related repositories

Similar repositories that may be relevant next.

Ragas: Supercharge Your LLM Application Evaluations

Ragas: Supercharge Your LLM Application Evaluations

August 9, 2026

Ragas is an ultimate toolkit for evaluating and optimizing Large Language Model (LLM) applications. It offers objective metrics, intelligent test generation, and data-driven insights to move beyond subjective assessments. This framework helps developers build feedback loops and continuously improve their LLM applications.

evaluationllmllmops
awesome-cli-coding-agents: A Curated Directory of Terminal-Native AI Tools

awesome-cli-coding-agents: A Curated Directory of Terminal-Native AI Tools

August 9, 2026

The `awesome-cli-coding-agents` repository offers a comprehensive, curated directory of over 100 terminal-native AI coding agents. These powerful tools operate directly within your command line, enabling autonomous code reading, editing, and execution. The list also covers various harnesses and orchestration solutions for managing these agents.

AICLICoding Agents
QwenPaw: Your Personal AI Assistant for Local and Cloud Deployment

QwenPaw: Your Personal AI Assistant for Local and Cloud Deployment

August 7, 2026

QwenPaw is a powerful personal AI assistant designed for easy installation and deployment, either on your local machine or in the cloud. It supports multiple chat applications and offers highly extensible capabilities, making it a versatile tool for various AI-driven tasks. With its robust memory system and security features, QwenPaw aims to be an intuitive and private partner in your digital life.

agentai-agentchatbot
DeepTutor: Lifelong Personalized Tutoring with AI Agents

DeepTutor: Lifelong Personalized Tutoring with AI Agents

August 7, 2026

DeepTutor is an advanced AI-powered platform designed for lifelong personalized tutoring, integrating various learning modes into a single, extensible system. It leverages large language models and multi-agent systems to offer features like interactive chat, quiz generation, and skill development. This project provides a comprehensive environment for learners and educators seeking intelligent, adaptive educational tools.

AITutoringLLM

Source repository

Open the original repository on GitHub.

11 counted GitHub visits

View on GitHub
OS
OSRepos

Analysis and discovery of open source repositories. Find interesting projects and follow their updates.

Monitor your website with YourWebsiteScore

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of third-party repository code is at your own risk. Always review source code, dependencies, licenses, and security implications before running anything.

© 2025 OSRepos. Built with Nuxt 3 and lots of ❤️