Architecture of High-Load RAG Systems: 10 Chunking Optimization Strategies and Integration with Weaviate, Qwen / Llama / Gemma

Andrei Nosov5 Dec 2025

Problem

Legal and medical teams search long documents: a contract with appendices runs about 300 pages, and a doctor gets packages of up to 10 guidelines of up to 310 pages each. Manual checks are slow and miss things. Plain RAG with fixed-size chunks cuts text mid-idea, so retrieval misses the right chunk and the LLM answers from its own knowledge. The team needed answers that cite a source and a pipeline that stays fast under load.

Example from the article: a check of contracts against the requirements of Federal Law No. 115-FZ, where risks hide in appendices and tables.

Solution in brief

The team compared 10 chunking strategies on two real cases (MedTech guidelines, LegalTech contracts) using a 100-item golden benchmark and RAGAS-style metrics in CI/CD. Semantic, hierarchical and their own hybrid chunking (regex structure, topic modeling, a small good/bad-split classifier) did best. The stack moved to Weaviate, the FRIDA embedder and a small Gemma model.

Questions this case answers
  • How to choose a document-splitting strategy for retrieval over long structured documents when fixed-size splitting breaks meaning and answers must be traceable to a source
  • How to detect quality regressions of a retrieval-augmented generation pipeline on every release when no human can review answers each time
  • How to choose a chunking strategy for a RAG system over long, structured contracts and clinical guidelines?
  • How to measure RAG quality on every release with a small golden benchmark and automatic metrics in CI/CD?

Tools and methods

  • Chunking strategies — 10 variants compared: fixed size, sentence, semantic, recursive, sliding window, hierarchical, topic (LDA), modality, agentic, hybrid
  • RAGAS and a golden benchmark — Recall, Precision and Faithfulness computed on every update in CI/CD
  • Weaviate — vector database with built-in sharding and replication
  • FRIDA, Gemma 3-4B — Russian-capable embedder and a small generator
  • Docling and Unstructured — document parsing; Unstructured for tables and a lighter Docker image
Continue reading — it's free

Google or a one-time email code. No password.