Skip to content

feat: add hallucination bench#838

Merged
rootfs merged 2 commits into
vllm-project:mainfrom
rootfs:hallucination-bench
Dec 16, 2025
Merged

feat: add hallucination bench#838
rootfs merged 2 commits into
vllm-project:mainfrom
rootfs:hallucination-bench

Conversation

@rootfs
Copy link
Copy Markdown
Collaborator

@rootfs rootfs commented Dec 15, 2025

Add hallucination bench to evaluate the hallucination detection feature against vLLM models.

This is the screenshot of running the bench against a locally started vLLM with Qwen2.5 14B model:

# make bench-hallucination MAX_SAMPLES=20
Evaluating: 100%|██████████| 20/20 [07:20<00:00, 22.03s/sample] Hallucinations: , 8

🚨 HALLUCINATION DETECTED [1]
   Question: Which magazine was started first Arthur's Magazine or First for Women?...
   Spans: 18
   Ground Truth: ✅ Correct
   Latency: 11261ms


🚨 HALLUCINATION DETECTED [2]
   Question: Musician and satirist Allie Goertz wrote a song about the "The Simpsons" charact...
   Spans: .; ps;  he was indeed named after Matt Groeningâs half-brother, Mark Groening. Matt named his character after Mark,;  half;  Mark Groening
   Ground Truth: ❌ False Positive
   Latency: 50684ms


🚨 HALLUCINATION DETECTED [3]
   Question: Which tennis player won more Grand Slam titles, Henri Leconte or Jonathan Stark?...
   Spans: Henri Leconte, on the other hand, has not been noted for winning any Grand Slam titles according to the available data.;  Henri Leconte who hasn't won...
   Ground Truth: ✅ Correct
   Latency: 37018ms


🚨 HALLUCINATION DETECTED [4]
   Question: Who was once considered the best kick boxer in the world, however he has been in...
   Spans: also known as Badr Moua
   Ground Truth: ❌ False Positive
   Latency: 32407ms


🚨 HALLUCINATION DETECTED [5]
   Question: Fast Cars, Danger, Fire and Knives includes guest appearances from which hip hop...
   Spans: independent hip
   Ground Truth: ❌ False Positive
   Latency: 23218ms


🚨 HALLUCINATION DETECTED [6]
   Question: In which American football game was Malcolm Smith named Most Valuable player?...
   Spans: This recognition came as a result of his significant contributions during the game on February 2, 2014,
   Ground Truth: ❌ False Positive
   Latency: 22426ms


🚨 HALLUCINATION DETECTED [7]
   Question: What U.S Highway gives access to Zilpo Road, and is also known as Midland Trail?...
   Spans: significant;  connecting various
   Ground Truth: ✅ Correct
   Latency: 17437ms


🚨 HALLUCINATION DETECTED [8]
   Question: What are the names of the current members of  American heavy metal band who wrot...
   Spans: According to the response, Metallica did not write the music for this;  James Hetfield (rhythm guitar, vocals);  Lars Ulrich (drums)
   Ground Truth: ❌ False Positive
   Latency: 49813ms


============================================================
HALLUCINATION DETECTION BENCHMARK
============================================================

📌 Configuration:
----------------------------------------
  Dataset:  halueval
  Endpoint: http://localhost:8801
  Model:    MoM

📊 Request Statistics:
----------------------------------------
  Total samples:  20
  Successful:     20
  Failed:         0

📋 Detection Results:
----------------------------------------
  Hallucinations detected: 8

🎯 Accuracy Metrics (vs ground truth):
----------------------------------------
  True Positives:  3
  False Positives: 5
  True Negatives:  6
  False Negatives: 6
  Precision: 0.3750
  Recall:    0.3333
  F1 Score:  0.3529
  Accuracy:  0.4500

⏱️ Latency:
----------------------------------------
  Average: 22030.13 ms
  P50:     19920.96 ms
  P99:     50684.18 ms

⚡ Two-Stage Pipeline Efficiency:
----------------------------------------
  Fact-check needed:     8/20 queries
  Detection skipped:     12/20 queries
  Avg context length:    371 chars
  Estimated detect time: 1048.54 ms (if all ran)
  Actual detect time:    422.28 ms
  Time saved:            626.26 ms
  Efficiency gain:       59.7%

  💡 Pre-filtering skipped 60.0% of requests,
     saving 626ms of detection compute.

🔍 Sample Results (first 5):
------------------------------------------------------------
  🚨 GT:HAL | Which magazine was started first Arthur's Magazine...
  ✅ GT:OK | The Oberoi family is part of a hotel company that ...
  🚨 GT:OK | Musician and satirist Allie Goertz wrote a song ab...
  ✅ GT:OK |  What nationality was James Henry Miller's wife?...
  ✅ GT:HAL | Cadmium Chloride is slightly soluble in this chemi...
============================================================

📁 Results saved to bench/hallucination_bench/results/results_halueval_20251215_142431.json

BEFORE SUBMITTING, PLEASE READ THE CHECKLIST BELOW AND FILL IN THE DESCRIPTION ABOVE


  • Make sure the code changes pass the pre-commit checks.
  • Sign-off your commit by using -s when doing git commit
  • Try to classify PRs for easy understanding of the type of changes, such as [Bugfix], [Feat], and [CI].
Detailed Checklist (Click to Expand)

Thank you for your contribution to semantic-router! Before submitting the pull request, please ensure the PR meets the following criteria. This helps us maintain the code quality and improve the efficiency of the review process.

PR Title and Classification

Please try to classify PRs for easy understanding of the type of changes. The PR title is prefixed appropriately to indicate the type of change. Please use one of the following:

  • [Bugfix] for bug fixes.
  • [CI/Build] for build or continuous integration improvements.
  • [Doc] for documentation fixes and improvements.
  • [Feat] for new features in the cluster (e.g., autoscaling, disaggregated prefill, etc.).
  • [Router] for changes to the vllm_router (e.g., routing algorithm, router observability, etc.).
  • [Misc] for PRs that do not fit the above categories. Please use this sparingly.

Note: If the PR spans more than one category, please include all relevant prefixes.

Code Quality

The PR need to meet the following code quality standards:

  • Pass all linter checks. Please use pre-commit to format your code. See README.md for installation.
  • The code need to be well-documented to ensure future contributors can easily understand the code.
  • Please include sufficient tests to ensure the change is stay correct and robust. This includes both unit tests and integration tests.

DCO and Signed-off-by

When contributing changes to this project, you must agree to the DCO. Commits must include a Signed-off-by: header which certifies agreement with the terms of the DCO.

Using -s with git commit will automatically add this header.

What to Expect for the Reviews

Signed-off-by: Huamin Chen <hchen@redhat.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented Dec 15, 2025

Deploy Preview for vllm-semantic-router ready!

Name Link
🔨 Latest commit e4acfc6
🔍 Latest deploy log https://app.netlify.com/projects/vllm-semantic-router/deploys/694068be39610f0008d3721a
😎 Deploy Preview https://deploy-preview-838--vllm-semantic-router.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 15, 2025

👥 vLLM Semantic Team Notification

The following members have been identified for the changed files in this PR and have been automatically assigned:

📁 bench

Owners: @yuezhu1, @Xunzhuo
Files changed:

  • bench/hallucination/README.md
  • bench/hallucination/__init__.py
  • bench/hallucination/config-7b.yaml
  • bench/hallucination/config.yaml
  • bench/hallucination/datasets.py
  • bench/hallucination/evaluate.py

📁 tools

Owners: @yuluo-yx, @rootfs, @Xunzhuo
Files changed:

  • tools/make/build-run-test.mk

vLLM

🎉 Thanks for your contributions!

This comment was automatically generated based on the OWNER files in the repository.

Comment thread bench/hallucination/README.md Outdated
# 2. Start semantic router with hallucination config
cd /path/to/semantic-router
export LD_LIBRARY_PATH=$PWD/candle-binding/target/release
./bin/router -config=bench/hallucination_bench/config.yaml
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be bench/hallucination/config.yaml

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, it is fixed now

@Sophie8
Copy link
Copy Markdown
Contributor

Sophie8 commented Dec 15, 2025

@rootfs when tested it got ""msg":"Failed to load config: category 'general' has no model_scores defined - each category must have at least one model"

Signed-off-by: Huamin Chen <hchen@redhat.com>
@rootfs
Copy link
Copy Markdown
Collaborator Author

rootfs commented Dec 15, 2025

@Sophie8 thank you for reviewing! the config.yaml in the first commit is stale, it is fixed now.

@rootfs rootfs changed the title feat: ad hallucination bench feat: add hallucination bench Dec 16, 2025
@rootfs rootfs merged commit a6ec94d into vllm-project:main Dec 16, 2025
27 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants