HowieHwong/TrustLLM
[ICML 2024] TrustLLM: LLM trustworthiness evaluation across truthfulness, safety, fairness, robustness, privacy and ethics. Python/CLI toolkit for local models, compatible APIs and AI agent orchestration.
TrustLLM – Evaluating LLM Trustworthiness
What it is – TrustLLM is a research‑grade toolkit that lets you run the ICML 2024 TrustLLM benchmark. The benchmark measures six “trustworthiness” dimensions of any large language model (LLM): truthfulness, safety, fairness, robustness, privacy, and ethics.
How it works – The package provides a small command‑line interface (and a Python API) that:
- Downloads the benchmark data and prompt files.
- Generates model responses either via an OpenAI‑compatible API or by loading a Hugging Face checkpoint locally.
- Scores the generated answers with the original paper’s evaluation pipelines (rule‑based checks, a downloaded classifier, embeddings, or an LLM judge). Results are saved as JSON and a human‑readable HTML report.
Key features
- Works with any model that speaks the OpenAI chat format – you just set
OPENAI_API_KEYandOPENAI_BASE_URL(or point to a local server). - Optional local mode that pulls Hugging Face weights (e.g.,
Qwen/Qwen2.5-0.5B‑Instruct) and runs on CPU, CUDA, or Apple Silicon via 🤗 Accelerate. - Modular install: base package + optional
[local]and[eval]extras, keeping the core lightweight. - Built‑in resume, per‑sample checkpointing, and bounded retry logic for robust large‑scale runs.
- Generates a concise HTML report (
report.html) and a detailed score file (scores.json).
Typical workflow
# 1. Install the core toolkit
pip install "trustllm @ git+https://github.com/HowieHwong/TrustLLM.git@main#subdirectory=trustllm_pkg"
# 2. Pull the benchmark data
python -m trustllm download --output data
# 3. Run a quick test against an API model
export OPENAI_API_KEY=…
export OPENAI_BASE_URL=https://myprovider/v1
python -m trustllm generate \
--backend api --model my-model-id \
--task safety --data data/dataset \
--limit 5 --output runs/api-safety
# 4. Evaluate the generated answers
pip install "trustllm[eval] @ …"
python -m trustllm evaluate --task safety --data runs/api-safety-full
A similar flow works for local HF weights by adding the [local] extra and swapping --backend api for --backend local.
Who it’s for – Researchers and developers who need a reproducible, open‑source way to benchmark the trustworthiness of new LLMs, whether they are hosted as a service or run locally.
Where to learn more – Paper: https://arxiv.org/abs/2401.05561, docs site, dataset on Hugging Face, and a public leaderboard.
All details are taken directly from the repository’s README; no extra claims are added.
Related
- Dispatch
- Project
- Project
- Project
- Dispatch