Skip to main content

Extractive QA pipeline — no LLM, no training. BM25 + FAISS + Wikidata + cross-encoder re-ranking + roberta-base-squad2.

Project description

watson-lite

A Watson-inspired extractive QA system that runs on a laptop.
No LLM. No trained weights of your own. No paid APIs.

Python Ruff

Install

pip install watson-lite
python -m spacy download en_core_web_sm

Usage

CLI

# Single question
watson-lite "Who designed the Eiffel Tower?"
watson-lite "Who was the 44th president of the United States?"

# Interactive mode
watson-lite

Python

from watson_lite import WatsonLite

watson = WatsonLite()
answer = watson.answer("Who designed the Eiffel Tower?")

print(answer.answer)        # "Gustave Eiffel"
print(answer.confidence)    # 0.847
print(answer.source)        # "Eiffel Tower"

Example output

$ watson-lite "Who was the 44th president of the United States?"

  ANSWER:     Barack Hussein Obama
  CONFIDENCE: 43.6%
  SOURCE:     Barack Obama
  URL:        https://en.wikipedia.org/wiki/Barack Obama

  Confidence breakdown:
    extraction_model: 0.592
    span_agreement: 0.2
    graph_corroboration: 0.0
    passage_rank_signal: 1.0

  Time: 44.60s

API

  • WatsonLite — Main orchestrator. answer(question) runs the full 6-stage pipeline.
  • NLPProcessor — spaCy-based question classification, NER, decomposition.
  • BM25Retriever — BM25 retrieval over Wikipedia REST API.
  • VectorRetriever — Dense vector retrieval (sentence-transformers + FAISS).
  • WikidataGraph — Structured fact enrichment from Wikidata.
  • Ranker — RRF fusion + cross-encoder re-ranking.
  • ExtractiveReader — Span extraction via roberta-base-squad2.
  • ConfidenceScorer — Multi-signal confidence scoring.
  • Cache — SQLite3 cache for Wikipedia and Wikidata responses.

Development

git clone https://github.com/daedalus/watson-lite.git
cd watson_lite
pip install -e ".[test]"

# run tests
pytest

# format
ruff format src/ tests/

# lint + type check
prospector --with-tool ruff --with-tool mypy src/

# find unused code
vulture --min-confidence 90 src/

Architecture

User Question → NLP (spaCy) → Decomposition → Entity Extraction
  → Parallel Retrieval (BM25 + FAISS) → Graph (Wikidata)
  → RRF Fusion → Cross-Encoder Rerank → Span Extraction → Confidence Score

Models Used (all pretrained, inference only)

Model Purpose Size
en_core_web_sm spaCy NLP ~12MB
all-MiniLM-L6-v2 Passage embeddings ~90MB
ms-marco-MiniLM-L-6-v2 Cross-encoder reranking ~90MB
deepset/roberta-base-squad2 Extractive span QA ~480MB

Total: ~670MB — runs CPU-only.

Data Sources

  • Wikipedia REST API — Live article retrieval
  • Wikidata REST API — Structured entity facts (no SPARQL)

Extending

  • Add a domain corpus: Replace fetch_wikipedia_passages() with your own document loader.
  • Add more graph sources: Wikidata REST API pattern is reusable.
  • Offline mode: Download Wikipedia dumps and index locally with BM25 + FAISS.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

watson_lite-0.1.0.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

watson_lite-0.1.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file watson_lite-0.1.0.tar.gz.

File metadata

  • Download URL: watson_lite-0.1.0.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for watson_lite-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c0fe5e8768dd5e02782b52130e7c0309fb055269921e4a4a32effce78133f9c8
MD5 8c61ec135ba242dfe7fc4748702ef470
BLAKE2b-256 3bf223d2d42122acf178f409e6b76c45e7ebb27dec565223b9ae8ba0f4e7b568

See more details on using hashes here.

Provenance

The following attestation bundles were made for watson_lite-0.1.0.tar.gz:

Publisher: pypi-publish.yml on daedalus/watson_lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file watson_lite-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: watson_lite-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for watson_lite-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 81c2b2f9701c91cc94499e8059c5381bf64cb1e58baea1f3ad4bd5e80c2fbbfd
MD5 6eff68967f504d064e42db288dbb5125
BLAKE2b-256 fc74e2bbab6767e699b9f5cc3eac658b27b9a0decb74f3948feb0b7f2574c1fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for watson_lite-0.1.0-py3-none-any.whl:

Publisher: pypi-publish.yml on daedalus/watson_lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page