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.

dify-official-plugins: Extending Dify with AI Models, Tools, and Agent Strategies
August 18, 2026
The `dify-official-plugins` repository hosts a collection of official plugins for Dify, an open-source platform for developing LLM-powered AI applications. These plugins, including models, tools, agent strategies, and extensions, enhance Dify's capabilities and are maintained by the official Dify team. They are designed to help developers efficiently build, deploy, and manage AI-driven solutions.

Agent Skills: A Standardized Way to Give AI Agents New Capabilities
August 18, 2026
Agent Skills provides a lightweight, open format for extending AI agent capabilities with specialized knowledge and workflows. It allows packaging procedural knowledge and context into portable, version-controlled folders that agents load on demand. This enables agents to gain domain expertise, follow repeatable workflows, and reuse skills across various compatible AI tools.

A-MEM: Self-Evolving Memory for Coding Agents
August 17, 2026
A-MEM is an innovative self-evolving memory system designed for coding agents, organizing knowledge into a dynamic Zettelkasten-style graph. It allows memories to evolve and connect over time, enhancing an agent's ability to recall and utilize information effectively. This system offers both semantic and structural search capabilities for a richer knowledge base.

Agent Sandbox: Secure Local Development for AI Coding Agents
August 17, 2026
Agent Sandbox provides a robust and secure local development environment specifically designed for collaborating with AI coding agents. It ensures minimal filesystem access, configurable network egress policies, and secure secret injection, protecting your local machine from potentially risky agent operations. This project supports various AI agents and integrates seamlessly with both CLI and popular IDE devcontainer setups.
Source repository
Open the original repository on GitHub.
17 counted GitHub visits