Project · 2025 · completed · Personal · Featured
VIKA vision knowledge assistant
A PDF question-answering system with hybrid retrieval, reranking, citations, and automatic LLM routing.
Problem
Long PDF collections are hard to search accurately, especially when documents mix born-digital pages, scanned content, multiple languages, tables, and repeated terminology. A useful assistant must retrieve the right passages, preserve page provenance, cite its evidence, and choose an appropriate language model without sending irrelevant context.
Approach
VIKA ingests and deduplicates PDFs, extracts page-aware text with OCR fallback, classifies pages, chunks content, and builds both dense and sparse indexes. Queries use hybrid FAISS and BM25 retrieval, followed by cross-encoder reranking. A prompt builder packages the best passages with citation labels, while an automatic router sends simple and complex requests to different configured models and falls back when a provider is unavailable.
Technical implementation
Uploads are validated by PDF header and parser checks, stored under SHA-256 content hashes, and accompanied by text, page JSONL, and metadata sidecars. Sentence Transformers create embeddings for a FAISS CPU index; rank_bm25 supplies lexical recall, and a cross encoder reorders the top candidates. RouteLLM or a deterministic heuristic estimates prompt complexity across Gemini, Mistral, Groq, and OpenRouter options. A Gradio interface exposes document intake, model selection, citations, source context, and evaluation feedback. Pytest coverage targets chunking, classification, indexing, retrieval, routing, and prompt construction.
candidates = hybrid_retrieve(query, dense_index, bm25, top_k=20)
context = reranker.rank(query, candidates)[:5]
prompt = build_prompt(query, context)
decision = select_model_for_prompt(prompt, routing_mode="Automatic")
return stream_answer(decision.model_name, prompt)