The problem
A generic language model can answer from its own training rather than from a document the user uploaded. Lexio narrows the answer's context to passages retrieved from that document.
The retrieval pipeline
The backend extracts page-level text with pypdf, splits content into approximately 500-word chunks with overlap, and creates embeddings through OpenAI. For each question, NumPy cosine similarity ranks chunks and selects the top five for context.
The source page numbers accompany the retrieved passages and are returned to the React interface along with the model's generated answer.
Interface and engineering decisions
The React interface includes PDF drag-and-drop upload, indexing feedback, suggested questions, an interactive Q&A view and badges for source pages.
Source references make an answer easier to check, but retrieval relevance does not guarantee factual correctness; the assistant still needs user verification.
Current scope
This is a prototype with in-memory sessions, no persistent document database, and no authenticated multi-user backend. Image-only PDFs require OCR, which is not implemented.
The inspected backend does not maintain genuine multi-turn conversational memory across questions, even though the interface presents a chat-like experience.