Loicen
Ask a question about a legal file, then open the document that supports the answer.
My role Co-founder and AI engineer
Reading a result
Ask for the daily rental rate. The agreement states €48 including tax. Select the answer to inspect the matching document, then open the vehicle agreement PDF. This browser exhibit uses fictional documents and quotes the best sentence from its local lexical search.
Find legal passages by exact wording and meaning
In the demo RAG backend, BM25 helps surface exact references while embeddings help match paraphrases. Reciprocal rank fusion uses 1 / (60 + rank) to combine positions across the two rankings. It shortlists documents first, then ranks passages within them for the answer prompt.
Tech stack
- FastAPI + Next.js
- The API proxies the chat stream over WebSockets to the document workspace.
- BM25 + Qdrant
- The demo backend combines lexical search with a local vector index for semantic matches.
- OpenAI
- Supplies embeddings and streams answers from retrieved passages for retrieval-augmented generation (RAG).
- Build environment
- uv bootstraps Python 3.12 and installs the demo dependencies.
Challenges and approaches
Reuse the index without serving stale vectors
The Qdrant manifest checks the corpus fingerprint, embedding backend and chunk settings. Changing the overlap or embedding model triggers a rebuild.
Keep evidence visible when generation fails
The prompt asks the model to flag insufficient context. If generation is unavailable, the backend can return excerpts from the retrieved documents.
Original retrieval deployment
The Runpod-backed mode uses Elasticsearch for sparse and dense retrieval, then applies the BGE multilingual cross-encoder to rerank selected candidates.
Development harness
- Validation
- make test checks retrieval ranking and index reuse with fixture embeddings.
- Integration
- make smoke checks that the WebSocket returns sources, answer tokens and an end-of-stream event.