Embedding-Based Query Routing over a Local Document Corpus

Published:

Stack: Python, LangChain, Ollama, scikit-learn, PyPDF2

Links: GitHub

  • Routes a natural-language query to the correct source document by chunking each corpus, embedding the chunks, and picking the corpus with the highest cosine similarity to the query.
  • Runs embedding inference locally through a self-hosted model rather than a hosted API, so document contents and queries never leave the machine.