CASE STUDYCASE STUDY / RAG / PROTOTYPE

Lexio.

Retrieval-first answers for PDF documents.

A React and FastAPI document assistant that extracts PDF text, embeds overlapping chunks, retrieves relevant passages, and gives GPT-4o-mini the selected context for a page-referenced answer.

ReactPythonFastAPIOpenAI embeddingsGPT-4o-miniNumPypypdf
01 / DETAIL

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.

02 / DETAIL

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.

03 / DETAIL

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.

04 / DETAIL

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.