Genuinely practical RAG? It’s not just about building a vector index and hoping the LLM will find everything on its own. When you’re working on a project, you’re counting on an assistant that actually understands your code, your context and your questions. That’s why Refio came to be – an open source, local AI assistant for IntelliJ, written in Kotlin, with all data kept locally.
In this article:
- I show how Refio works (from the inside, not the marketing version)
- I explain what Retrieval-Augmented Generation (RAG) is in practice
- I lay out 6 concrete RAG techniques that make a difference – and how you can use them in Refio so it doesn’t just “search”, but actually hits the mark
- I give you ready-made example scenarios
Refio – what is it and who’s it for?
Refio is an IntelliJ plugin that:
- runs completely locally (SQLite, embeddings, zero cloud without your consent)
- doesn’t need a webview or an external backend
- launches directly in the JVM as a native application, not over HTTP
- uses OpenAI or Ollama (embedding models local or in the cloud)
- analyzes the project automatically
- has its own system of context providers (
@file,@folder,@grep,@codebase,@commit,@diff…) - gives you a convenient UI with a chat and an advanced panel (context preview, retrieval debugging)
- offers three working modes: Chat, Planning (read-only), Agent (full automation, code editing)
Refio came out of a need: to have an assistant that minimizes context.
How does the RAG pipeline work in Refio?
- Project indexing – when the IDE starts, Refio analyzes all the files (detecting changes with a SHA-256 checksum), breaks the code down into classes, functions, imports (AST-aware).
- Semantic chunking – it splits the code into logical fragments.
- Embeddings – each fragment goes into an embedding (OpenAI or Ollama, local or remote), all kept in SQLite.
- Search – cosine similarity picks the most relevant fragments for a given query (results above the 0.5 threshold).
- Building the context – from the RAG results and the metadata, a coherent context is built for the LLM.
- The model’s answer – the LLM gets a selected, concise context and generates a response.
- For Plan/Agent mode – a loop of planning and carrying out steps, with the option to roll back.
Sounds simple, but the real value is in the details and… in the modern retrieval techniques.
Six techniques that make a difference in modern RAG – and how you can use them in Refio
1. PageIndex – navigating the project structure, like in a file explorer
What it’s good for:
In big projects it’s hard to find where the logic you care about lives. A plain search treats the code like a flat list of fragments – PageIndex lets you go through the code “top to bottom”, like a directory tree.
How you can use it in Refio:
Quickly narrow the search down to a specific module, directory or file before you go deeper into the classes and functions. Refio can first point you to the files related to a given problem (e.g. authorization), and only then search for functions or classes. Perfect when you’ve got hundreds of files and you can’t remember exactly where the fragment you’re looking for is.
What you get out of it:
You get to the right spot faster, with less risk of stumbling onto an irrelevant fragment.
2. Multivector Retrieval – one fragment, many perspectives
What it’s good for:
People ask in different ways – once about a function’s name, once about what it does, sometimes about the description in a comment. A single embedding doesn’t catch that.
How you can use it in Refio:
Refio can create several embeddings for the same fragment: from the name and signature, from the documentation, from the full content, from a summary. That way, even if you ask in your own words (“where are the retries?”), the tool will find the fragment by its docstring, not just by its name.
What you get out of it:
You don’t have to know the names – you can ask like a human.
3. Metadata Augmentation – searching with metadata, not just content
What it’s good for:
The content isn’t always the most important thing – sometimes what matters is the location, the file type, the date, the author or the environment (prod/test/dev).
How you can use it in Refio:
You can weight and filter results based on the path, the file type, the last edit or the directory. For example: you ask about the backend, Refio favors the core/ directory and ignores test/. Or – if you recently edited a file in ui/, results from that module will show up higher.
What you get out of it:
Less noise, a better fit to what you’re currently working on, and you get back to the most important fragments faster.
4. CAG (Cache-Augmented Generation) – instant access to the most important information
What it’s good for:
Constantly searching through the same fragments (e.g. the project summary) is inefficient.
How you can use it in Refio:
Refio can cache the project summary and conversation recaps, always attaching them to the context. That allows instant access to the most important information and faster answers, especially during long sessions.
What you get out of it:
Lower token usage, fast answers, and the certainty that the key knowledge is always available.
5. Contextual Retrieval – embeddings with the full context of where they sit in the project
What it’s good for:
Without context it’s easy to lose the meaning – especially with repetitive function or class names.
How you can use it in Refio:
Every code fragment in Refio can have a “header” describing where it sits (module, file, class) along with a summary of what it does. Queries about general topics (e.g. “login handling”) can land precisely, even when the code has generic names.
What you get out of it:
More precise results, fewer random hits, a better fit to the actual context of the project.
6. Reranking – a second stage of selection, to pick the genuinely best results
What it’s good for:
Not every cosine similarity result is worth it – especially with complex queries.
How you can use it in Refio:
After picking the topK fragments, Refio can run an additional ranking, e.g. with a lightweight scoring model or with heuristics (does the result contain the keyword, is it from the currently open file). Only the most sensible fragments make it to the LLM.
What you get out of it:
Stability, less noise, more on-point answers – better quality of work with an AI assistant.
What’s it all for? – Practice, and practice again
By combining these techniques, it:
- builds a plugin that doesn’t flood the LLM with irrelevant data,
- searches accurately, drawing on structural context, metadata, cache and reranking,
- reacts to the current context of the project
Wrapping up
RAG isn’t just a fad, and Refio isn’t “yet another chat in the IDE”. It’s a tool that:
- understands your code,
- optimizes the context,
- uses modern retrieval techniques,
- and makes a real difference in your day-to-day work.
If you want to learn more or see the source code, head over to github.com/shadoq/refio.