Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

semlix-search

A Google-style search engine demo powered by semlix — a single runnable app (FastAPI backend + a vanilla HTML/JS frontend) that searches the semlix documentation and shows off the whole stack:

  • Hybrid search — lexical (BM25F) + semantic (sentence-transformers), fused, with a Lexical / Hybrid / Semantic toggle in the UI.
  • Highlighted snippets under each result (like Google).
  • "Did you mean…?" spelling correction.
  • Fast — query latency shown in milliseconds.

It's also a bit of dogfooding: the corpus is the semlix docs, searched with semlix.

Screenshots

semlix-search landing page — Google-style UI with a Hybrid / Lexical / Semantic toggle

Hybrid results: highlighted snippets with per-result lexical + semantic scores and query latency.

Hybrid search results for "installation" with highlighted snippets and lexical/semantic score badges

Zero-setup

A prebuilt index of the semlix docs ships in data/, so you can run the app immediately — no indexing step needed:

pip install -r requirements.txt
python -m semlix_search.app          # http://127.0.0.1:8000

Lexical search (snippets + "did you mean") works out of the box. For hybrid/semantic search, also pip install sentence-transformers (the query embedder + model are only needed at query time; the document vectors are already in data/vectors.npz). To rebuild the index from scratch, see Quick start below.

Quick start

# 1. install (semlix comes from PyPI)
python -m venv .venv && . .venv/bin/activate
pip install -r requirements.txt
#    optional — enables semantic / hybrid search (downloads a small model on first run):
pip install sentence-transformers

# 2. build the index from the semlix docs (sibling ../semlix/docs/source by default)
python -m semlix_search.cli index            # hybrid if sentence-transformers is installed
#    or: python -m semlix_search.cli index --no-semantic   # lexical only, no model download
#    or: python -m semlix_search.cli index --docs /path/to/any/docs

# 3. run
python -m semlix_search.app                  # http://127.0.0.1:8000

Open http://127.0.0.1:8000 and search.

How it works

  • Indexer (semlix_search/indexer.py) splits a docs tree (.rst/.md) into sections and builds a semlix core FileIndex (enables highlighting + spelling). If sentence-transformers is present it also builds a NumpyVectorStore via HybridIndexWriter, so the same content is searchable lexically and semantically.
  • Backend (semlix_search/app.py) — FastAPI:
    • GET /api/search?q=…&mode=lexical|hybrid|semantic&limit=10
    • GET /api/stats
    • With a vector store present it uses semlix.semantic.HybridSearcher (mode maps to the fusion alpha); otherwise it serves lexical search with highlighted snippets and spelling correction. It always degrades gracefully.
  • Frontend — one static index.html (no build step): a Google-like page that calls the API and renders results, snippets, scores, latency and suggestions.

Which semlix engine?

This demo uses the semlix core engine as its lexical half because that's what provides highlighted snippets and spelling correction. For a much larger corpus where you want raw throughput over those features, semlix also ships the bm25s engine (semlix.bm25.BM25Index) — see the engine guide in the semlix docs.

Config (env vars)

var default
SEMLIX_SEARCH_DOCS ../semlix/docs/source
SEMLIX_SEARCH_INDEX ./data/index
SEMLIX_SEARCH_VECTORS ./data/vectors.npz
SEMLIX_SEARCH_MODEL all-MiniLM-L6-v2

About

Google-style search demo powered by semlix — hybrid lexical + semantic search over the semlix docs (FastAPI + vanilla JS)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages