AuditNLG: Auditing Generative AI for Trustworthiness
This repository profile is provided by osrepos.com, an open source repository discovery platform.

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
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
- GitHub Repository: https://github.com/salesforce/AuditNLG
- License: BSD-3-Clause
Related repositories
Similar repositories that may be relevant next.
AutoResearch: AI/ML Research Agents from Idea to Paper-Ready Evidence
September 22, 2026
AutoResearch is an open-source agent workflow designed for AI and machine learning research. It automates the entire research process, from generating ideas and planning experiments to execution, analysis, and independent evaluation. This project helps researchers produce paper-ready evidence efficiently and with traceable provenance.
HarnessRouter: Unified Interface for AI Agent Harnesses
September 22, 2026
HarnessRouter Community Edition provides a self-hosted, Apache-2.0 licensed unified interface for various AI agent harnesses like Codex, Claude Code, and Hermes. It allows users to run multiple agents through a single API, offering features such as sessions, streaming, file handling, and cancellation. The project implements the open-standard Unified Harness Protocol (UHP), ensuring users maintain control over their keys and infrastructure.

AREX-Skill: A Skill Library for Automated Machine Learning and Auto-Research
September 21, 2026
AREX-Skill is a powerful skill library designed to advance automated machine learning and auto-research. It distills over 5,000 executable skills from more than 1,000 popular GitHub repositories, making complex ML knowledge directly usable by coding agents. This project significantly enhances agent performance in various research tasks by providing structured, validated operating knowledge.

oh-my-hermes: Enhance Hermes Agent with Advanced AI Workflow and Memory
September 17, 2026
oh-my-hermes is an all-in-one plugin designed to significantly enhance the Hermes Agent. It provides advanced coding intelligence, a robust long-term memory system, and optimized workflow packages, transforming standard Hermes requests into structured, actionable tasks with clear operational layers.
Source repository
Open the original repository on GitHub.
23 counted GitHub visits