Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,11 @@ jobs:
components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2
- run: cargo fmt --all -- --check
- run: cargo clippy -- -D warnings
- run: cargo clippy --all-targets -- -D warnings
- run: cargo clippy --all-targets --no-default-features -- -D warnings
- run: cargo test
- name: Smoke test the offline detector on a bundled sample
run: |
cargo run -q -- --logprobs-file examples/logprobs/cuyp.json --threshold 0.6 --format json | tee report.json
grep -q '"text": " Dordrecht"' report.json
cargo run -q --example detect
57 changes: 57 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Release
on:
push:
tags: [ "v*" ]
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
BIN: llm-token-visualizer
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest, target: x86_64-unknown-linux-gnu }
- { os: macos-latest, target: aarch64-apple-darwin }
- { os: macos-latest, target: x86_64-apple-darwin }
- { os: windows-latest, target: x86_64-pc-windows-msvc }
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- run: cargo build --release --locked --target ${{ matrix.target }}
- name: Package
shell: bash
run: |
name="$BIN-${GITHUB_REF_NAME}-${{ matrix.target }}"
mkdir -p "dist/$name"
if [ "${{ runner.os }}" = "Windows" ]; then exe="$BIN.exe"; else exe="$BIN"; fi
cp "target/${{ matrix.target }}/release/$exe" README.md LICENSE "dist/$name/"
cp -r examples/logprobs "dist/$name/samples"
cd dist
if [ "${{ runner.os }}" = "Windows" ]; then 7z a "$name.zip" "$name" >/dev/null; else tar czf "$name.tar.gz" "$name"; fi
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: dist/*.*z*
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Checksums
run: cd dist && sha256sum * > SHA256SUMS.txt
- uses: softprops/action-gh-release@v2
with:
files: dist/*
generate_release_notes: true
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Changelog

## 0.2.0 (2026-09-25)

- New: hallucination-risk detection from token logprobs. `--logprobs-file` reads a Chat Completions response (or its `logprobs` block, or a bare token array) and flags words below `--threshold` (default 0.5), with the alternatives the model considered.
- New: `--live "<prompt>"` calls any OpenAI-compatible API (`OPENAI_API_KEY`, optional `OPENAI_BASE_URL`, `--model`, `--save`). Behind the default `live` feature.
- New: `--format json` report and `--fail-on-flag` (exit status 2) for scripts and CI.
- New: four real Llama 3.1 8B sample responses in `examples/logprobs/` and `cargo run --example detect`.
- Fix: `TerminalRenderer::render` no longer prints to stdout itself, so library callers of `visualize_tokens(.., "terminal", ..)` control output. The CLI prints the returned string.
- Release workflow builds Linux, macOS and Windows binaries on tag push.
- Repo: build output (`target/`) is no longer tracked; sketch directories renamed.

## 0.1.0

- Token confidence visualizer: terminal, HTML and Markdown renderers.
42 changes: 27 additions & 15 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
# Contributing to LLM-Hallucination-Detection-Script
# Contributing

Thanks for your interest. Contributions that improve detection accuracy, add new methods, extend provider integrations, or add test coverage are all welcome.
Thanks for helping. Small, focused PRs are easiest to review.

## What we want
## Setup

- **New detection methods** -- additional heuristics or ML-based approaches
- **Provider integrations** -- examples using Mistral, Gemini, local models
- **Rust MVP improvements** -- better streaming detection, new dashboard features
- **Bug fixes** -- correctness issues, edge cases, false positive reduction
- **Tests** -- more labeled examples, accuracy benchmarks
You need a stable Rust toolchain.

## How to contribute
```bash
git clone https://github.com/Mattbusel/LLM-Hallucination-Detection-Script
cd LLM-Hallucination-Detection-Script
cargo test
cargo run -- --logprobs-file examples/logprobs/cuyp.json --threshold 0.6
```

1. Fork and clone
2. Python: `python -m pytest tests/` must pass
3. Rust: `cargo test --all` must pass
4. Open a PR with a description of the change and why
## Before you open a PR

## Questions
CI runs these; run them locally first:

Open a [Discussion](https://github.com/Mattbusel/LLM-Hallucination-Detection-Script/discussions) for design questions or ideas before building.
```bash
cargo fmt --all -- --check
cargo clippy --all-targets -- -D warnings
cargo clippy --all-targets --no-default-features -- -D warnings
cargo test
cargo run --example detect
```

## Good places to start

- Detection logic lives in `src/detect.rs`, with unit tests at the bottom of the file. New heuristics should come with a test and, ideally, a real sample response in `examples/logprobs/`.
- Sample responses must be real API output (say which model and provider in the PR). Do not hand-edit logprobs.
- `rust_mvps/` is design sketches that are not built. Turning one into a working crate is welcome, but open an issue first.

Issues labelled `good first issue` are sized for a first PR.
Loading
Loading