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.1.tar.gz (15.5 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.1-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: watson_lite-0.1.1.tar.gz
  • Upload date:
  • Size: 15.5 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.1.tar.gz
Algorithm Hash digest
SHA256 c067cd5597af37c6e4963c35090be3546346f4a9074916e5118709833a4fc4ff
MD5 8970a444128d63816323a1cdb9a1b633
BLAKE2b-256 8ab8e241dfc8c0419478380673a8252fa0081bff2ba035ee10e164dc7b6d7d13

See more details on using hashes here.

Provenance

The following attestation bundles were made for watson_lite-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: watson_lite-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 20.5 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2fc5a36adf0d54ddbe72f311ed3934f8dc1d05c5f18700adb31d88abf9b627e3
MD5 b38825e70804f0639a6cbb46c156a7ba
BLAKE2b-256 ad9113e0ec703d32ea3c5e04620e0b3db38b9d6aaf34a1e4ef99d1ad465f3d3e

See more details on using hashes here.

Provenance

The following attestation bundles were made for watson_lite-0.1.1-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