AI-generated editorial illustration; not a documentary photograph.
JetBrains has published the first installment of an engineering series explaining the production RAG pipeline behind JetBrains Context, its semantic code search system. The account focuses on how source files are parsed, divided into meaningful units and converted into compact vectors for retrieval by coding agents.
Code Structure Shapes Retrieval
JetBrains argues that fixed-size splitting can combine unrelated code or sever meaningful constructs, while line-by-line indexing removes context needed for useful matches. Its pipeline instead parses files into syntax nodes and groups declarations with associated documentation, modifiers and closing syntax. Oversized nodes are subdivided, and adjacent small units can be combined before whitespace and indentation are normalized.
Structure-aware chunking currently covers Kotlin, Java, Python, JavaScript, TypeScript, C#, PHP, Go and Rust. Other languages and documents fall back to line-based splitting. JetBrains says it evaluates boundaries with an LLM judge that checks for problems such as detached documentation and broken constructs, alongside end-to-end retrieval evaluation.
Storage Favors More Dimensions
Repository-scale indexing creates a storage problem: JetBrains estimates that a vector containing a few thousand 32-bit floating-point dimensions occupies about 16 kilobytes, allowing several million chunks to produce tens of gigabytes of index data before additional bookkeeping. Its tests found that retaining all 4,096 dimensions at one bit each performed better under a 512-byte budget than preserving 128 dimensions at full 32-bit precision.
JetBrains therefore uses binary quantization for this retrieval case, converting non-negative components to one and negative components to zero. That representation is 32 times smaller than the equivalent 32-bit vectors and replaces cosine similarity with Hamming distance, which counts differing bits.
Binary Search Has Limits
The company says binary quantization loses some recall but remains suitable when an agent can inspect several nearby results instead of relying on a perfectly ordered shortlist. The compromise is less effective when a feature must determine absolute relevance: binary vectors compress similarity scores into a narrow range, making reliable thresholds difficult.
For uses that must decide when no result is relevant, JetBrains retains 16-bit floating-point vectors despite the added storage. It also separates deployment priorities: indexing is optimized for throughput and batches of about 32 chunks on the GPU, while query processing is tuned to minimize the delay before results appear.
Source: Building a RAG Pipeline for Semantic Code Search: A Developer Diary and Field Notes

Leave a Reply