Skip to content

Documentation

On this page: browser, command line, GitHub Action, what the scores mean, rules, MCP, privacy, limits.

First run in the browser

  1. Open Evaluate. An example question and source text are already filled in and Demo mode is on.
  2. Press Run evaluation. You get one PASS and two FAILs with reasons. Demo results are labelled because no AI model is called.
  3. Open a card, click a score to read what it means, and read the suggested fixes.
  4. Switch to Live, choose a provider, paste your key, list the models to compare and run again. Use a judge model from a different family than the candidate when you can.
  5. Edit the rules under Guardrails, export results, and download a trustllm.yaml to run the same check in CI.

Command line

Needs Node 20 or newer. No install step: the repository ships a bundled CLI.

git clone https://github.com/Professional50coder/trustllm && cd trustllm
node dist/cli.cjs init trustllm.yaml      # writes an example config
node dist/cli.cjs run trustllm.yaml --json report.json --md report.md
echo $?                                    # 0 pass, 1 gate failed, 2 error

# live mode: keys come from the environment, never from the file
OPENAI_API_KEY=... node dist/cli.cjs run trustllm.yaml

GitHub Action

- uses: actions/checkout@v4
- uses: Professional50coder/trustllm@main
  with:
    config: trustllm.yaml
  env:
    OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

The job fails when the gate fails and a Markdown report is written to the job summary.

Add comment: true (and permissions: pull-requests: write on the job) to post the report on the pull request.

MCP server and agents

Agents can call the gate as a tool. Start the server with node dist/cli.cjs mcp (stdio). Tools: evaluate, list_packs, list_rule_types. A summary for agents is at /llms.txt. The server speaks a minimal subset of the protocol and has been tested at the message level, not with every client.

Packs, approvals and sharing

What the scores mean

Grounding
Of the factual statements in the answer, how many are backed by the context passage you provided. Higher is better. 100% means every statement can be traced to your source text. Needs a context passage. Without one this signal is not measured.
Unsupported claims
The share of statements the context does not support or that contradict it. This is how this tool counts likely hallucinations. Lower is better. A statement can be unsupported and still true; the point is that you cannot show it from your source. Offline demo scoring compares words and numbers only; the live judge reads meaning.
Consistency
The model answers the same question again several times. If its facts change between answers, it is probably guessing (the SelfCheckGPT idea). Higher is better. Low values flag instability even when the first answer sounds fine. Only available when the tool generates the answer and draws 2 or more samples.
Toxicity
Whether the answer contains insults, hate, harassment or threats: none, mild, clear or severe. None is the goal. The offline demo uses a short word list and misses implicit or sarcastic toxicity. The live judge is better but not perfect.
Expressed confidence
How certain the wording sounds ("definitely" versus "maybe"). It describes tone, not correctness. Not a quality score. Confident wording together with unsupported claims is the risky combination. Based on hedge and booster words only.
Overall
A convenience number mixing the signals above. The PASS/FAIL decision does not use it; it comes from your guardrail rules. Use it to sort results, not to decide releases. Weights (grounding 40, unsupported 30, consistency 30, toxicity 20, renormalised for missing signals) are not calibrated against human judgement.

Guardrail rules

Exact rules give the same answer every time. Scored rules depend on the judge, so keep them as warnings (blocking: false) until you trust them on your own data. A rule that cannot run (for example grounding without a source text) is shown as skipped and never counts as a pass.

typekindmeaning
no_piiExactEmails, phone numbers, US SSNs, card numbers (Luhn checked).
no_secretsExactOpenAI-style keys, GitHub tokens, AWS keys, private key blocks, Slack tokens.
has_citationsExactA [1] marker, a link, "(Author, 2020)" or a "source:" line.
valid_jsonExactThe answer parses as JSON (code fences allowed).
max_words / min_wordsExactLength limits. value is a word count.
contains / not_containsExactRequired or banned text. value is the text; ignoreCase defaults to true.
regexExactpattern, flags, mustMatch (default true).
min_groundingScoredPercent of claims supported by the source text. Skipped without a source.
max_hallucination_riskScoredPercent of claims unsupported or contradicted. Skipped without a source.
max_toxicityScored0 none, 1 mild, 2 clear, 3 severe.
min_consistencyScoredAgreement with extra samples. Needs a model-generated answer and 2 or more samples.
guardrails:
  - { id: no-pii, type: no_pii }
  - { id: grounded, type: min_grounding, value: 80 }
  - { id: consistent, type: min_consistency, value: 70, blocking: false }

Privacy and keys

Limits