Built an MCP server for FinSight. Claude Desktop now calls my SEC filing RAG pipeline as a tool β discovers it, queries it, gets grounded answers.
Hardest part wasn't the code. It was a print() statement corrupting the JSON-RPC protocol and a 30s model load causing startup timeouts. Real integration problems, not tutorial problems.
Two tools: one returns answers, one returns raw chunks. Different agents want different things.
https://t.co/fm7LuWQJSd
#AIEngineering #MCP #RAG
Added RAGAS evaluation to my RAG pipeline. Immediately found the problem: dense financial tables embed as meaningless numbers β retriever can't find what it can't understand.
Fix: contextual chunking. LLM labels each chunk at ingestion. But labels in the generator context killed faithfulness. Had to separate embedding representation from generation input.
Context recall: 0.76 β 0.86. Lesson: if you're not measuring retrieval and generation separately, you're guessing.
https://t.co/fm7LuWQJSd
#AIEngineering #RAG #LLMOps
Built a two-stage retrieval pipeline in FinSight this week.
The problem: semantic search returns chunks that are "close" in vector space, but not necessarily the most relevant. Ask "Did Apple's services revenue decline?" and you get chunks containing "services" and "revenue" β but they might be about revenue growth, not decline. The embedding matched keywords, not meaning.
The fix: retrieve wide, then rerank precisely.
Stage 1 β Hybrid search (BM25 + vector + Reciprocal Rank Fusion) casts a wide net. Keyword matching catches exact financial terms that embeddings miss. Vector search catches semantic meaning. RRF merges both without needing score calibration.
Stage 2 β A cross-encoder reranker (BAAI/bge-reranker-base) takes the top 20 candidates and scores each query-chunk pair jointly β full cross-attention, not separate embeddings. Returns the top 5.
The key insight: bi-encoders encode query and document separately β fast but lossy. Cross-encoders read them together β slow but accurate. You can't afford cross-encoders on your whole corpus, so you use both: cheap recall first, expensive precision second.
Same architecture Google, Bing, and every production search system uses. Self-hosted model, no API dependency, no token cost.
One honest finding: on a simple revenue query, pure vector search actually returned more relevant chunks than the reranked pipeline. The reranker can only reorder what it receives β if the hybrid retriever's candidate pool is worse for a particular query type, reranking can't fix it. That's why evaluation matters more than any single technique.
Next up: RAGAS evaluation pipeline to measure impact across 20+ queries with real numbers.
https://t.co/fm7LuWQJSd
#BuildInPublic #AIEngineering #RAG #LLM #InformationRetrieval
Have a look , suggestions are welcome !