Skip to content

feat: add cross-validated-search example for hallucination-free responses#631

Open
wd041216-bit wants to merge 1 commit intoollama:mainfrom
wd041216-bit:add-cross-validated-search
Open

feat: add cross-validated-search example for hallucination-free responses#631
wd041216-bit wants to merge 1 commit intoollama:mainfrom
wd041216-bit:add-cross-validated-search

Conversation

@wd041216-bit
Copy link

Overview

This PR adds a new example demonstrating how to use cross-validated-search with Ollama to prevent hallucinations by verifying facts against multiple sources.

Features

  • Confidence Scoring: Every fact gets a confidence level (Verified/Likely True/Uncertain/Likely False)
  • Cross-Validation: Facts verified against multiple independent sources
  • No API Key Required: Completely free, no API keys needed
  • Seamless Integration: Works with Ollama's chat API out of the box

Example Output

🥚 cross-validated-search + Ollama
Prevent hallucinations with confidence-scored search results

Searching: What is the latest version of Python?

┌──────────────────────────────────────────────────────────────┐
│ Results for: What is the latest version of Python?           │
├─────────┬────────────────────────────────────────┬───────────┤
│ Engine  │ Title                                   │ Confidence│
├─────────┼────────────────────────────────────────┼───────────┤
│ DuckDuckGo│ Python 3.13.0 Released              │ verified  │
│ Bing     │ Download Python                       │ verified  │
│ Google   │ Python.org                            │ verified  │
└─────────┴────────────────────────────────────────┴───────────┘

LLM Response:
Based on verified sources, Python 3.13.0 is the latest stable release...

How It Works

  1. User asks a factual question
  2. cross-validated-search queries multiple search engines
  3. Results are cross-validated and assigned confidence scores
  4. Verified context is passed to Ollama's LLM
  5. LLM responds with accurate, cited information

Installation

pip install cross-validated-search ollama rich

Related

  • examples/web-search.py - Basic web search with Ollama
  • examples/web-search-mcp.py - MCP server for web search

This example complements the existing web search examples by adding hallucination prevention capabilities.

…nses

This example demonstrates how to use cross-validated-search with Ollama
to prevent hallucinations by verifying facts against multiple sources.

Features:
- Confidence scoring (Verified/Likely True/Uncertain/Likely False)
- Cross-validation across multiple search engines
- No API key required - completely free
- Seamless integration with Ollama's chat API

The example shows how to:
1. Perform cross-validated web searches
2. Format results with confidence indicators
3. Pass verified context to LLM for accurate responses
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.

1 participant