LLMs Technical Reviews

How is retrieval (RAG) implemented?

Embedding models; vector store; top-k; how retrieved code reaches the prompt; or agentic file reading instead of RAG.

Verdict

Only deepwiki-open uses embedding RAG for every page and every chat turn. For pages that explain one subsystem in depth, the agent-based tools, OpenDeepWiki first, usually read more relevant code.

Embedding RAG. deepwiki-open uses a FAISS retriever with top_k: 20 over OpenAI text-embedding-3-small (256 dims) by default. Retrieved chunks are grouped by file with line ranges. If the query is over 7,500 tokens, retrieval is skipped, so outlines of large repos see no code. readmeX uses RAG only in website mode and only for Python. It embeds AST code blocks with a local 1.5B model (OASIS-code-embedding-1.5B) into FAISS and adds 8 blocks to each page prompt. The query is a fixed Chinese keyword string per page type, and the .rag_cache is never invalidated. RepoAgent has RAG only in its optional chat demo: Chroma over the generated docs, text-embedding-3-large, three query variants and a gpt-4o-mini rerank. Its doc generation does not retrieve. It puts the code and docs of each object’s callers and callees, found with Jedi, into the prompt.

Lexical search. RepoWiki uses TF-IDF over chunks of up to 30 lines and returns the top 5. The ModuleIndex boost for paraphrased questions is dead code at this commit (it reads a missing wiki.modules field), so only shared words match.

Agentic reading. OpenDeepWiki has no embeddings. Agents call ListFiles, Grep and ReadFile, with 6 calls per page and 240 lines per read. openDeepWiki (Go) gives agents list_dir, read_file, search_files and an unrestricted sh -c tool, with up to 100 iterations for the page writer.

No retrieval. deepwiki-rs has no RAG at all (not applicable). Earlier stage results are packed into each prompt from an in-process store and compressed when too large. Only three stage types get file_explorer and file_reader (200 lines per read).

Pick: deepwiki-open for similarity search over every file. Pick: OpenDeepWiki for in-depth pages from files the model chose to read. Pick: RepoWiki for chat with no embedding service.

Per-project answers

AsyncFuncAI/deepwiki-open

answered

Retrieval is implemented via a FAISS-based RAG pipeline using the adalflow framework. The core class is RAG in api/rag/rag.py (line 134), which wraps a FAISSRetriever (line 290) configured with top_k: 20 (from embedder.json). Documents are embedded using configurable embedders: OpenAI text-embedding-3-small (256 dims) by default, Google gemini-embedding-001, Ollama nomic-embed-text, or Bedrock amazon.titan-embed-text-v2:0 — selected via the DEEPWIKI_EMBEDDER_TYPE env var (config.py line 65).

The retrieval pipeline in research_chat() (api/services/research.py, line 60) first prepares the retriever index (loading from a .pkl pickle file or creating it fresh), then calls rag.acall(query) which invokes the FAISS retriever. Retrieved documents are grouped by file path and each chunk is annotated with its line range (line 178-184). The grouped context is assembled into a structured prompt that includes file-path headers and line-numbered chunks inside <START_OF_CONTEXT> / <END_OF_CONTEXT> tags (line 146-192).

The context is then injected into prompt_builder() (api/chat/_prompts.py, line 6), which builds a final prompt combining the system prompt, conversation history, context block, and user query. The response streamer (ChatStreamer in _stream.py) sends the full prompt to the LLM and streams back chunks. If the input exceeds ~7500 tokens, RAG context is omitted and a fallback note is inserted instead (line 27-29 of _prompts.py). The Memory class in rag.py (line 79) accumulates conversation turns for multi-turn dialogue.

AIDotNet/OpenDeepWiki

answered

There is no traditional RAG pipeline — no vector embeddings, no vector database, and no top-k similarity search. Instead, OpenDeepWiki uses agentic file and document reading via AI tool calls, implemented in two key classes.

Pre-generated document retrieval. The DocReadTool (src/OpenDeepWiki/Agents/Tools/DocReadTool.cs:14) exposes ReadDocumentAsync(path) and ListDocumentsAsync() to the AI chat agent. It looks up the repository, branch, and language in EF Core (DocCatalog + DocFile entities) and returns cached Markdown content. Each document record stores a SourceFiles JSON array (the source code files that were analyzed to generate it). The ChatDocReaderTool (src/OpenDeepWiki/Agents/Tools/ChatDocReaderTool.cs:15) provides a more granular ReadAsync(path, startLine, endLine) capped at 200 lines per request, with dynamic tool descriptions that embed the available-document catalog.

Source-code retrieval. The GitTool (src/OpenDeepWiki/Agents/Tools/GitTool.cs:13) exposes three AI tools: ReadFile(path, offset, limit) (line 180), ListFiles(glob, maxResults) (line 493), and Grep(pattern, glob, ...) (line 283). These let the agent read arbitrary source files (respecting .gitignore and hidden-path filtering), glob for project structure, and regex-search across files. Lines are capped at 2000 characters; reads default to 2000 lines; grep results default to 50 with 2 context lines. Binary files are skipped by extension.

How it reaches the prompt. In ChatAssistantService.StreamChatAsync() (src/OpenDeepWiki/Services/Chat/ChatAssistantService.cs:372), tools are constructed at request time: a GitTool is initialized from the cloned repository path on disk, a ChatDocReaderTool loads the document catalog from the database, and optionally MCP/skill tools. The system prompt (line 963–1138) instructs the agent to first ReadDoc for documentation, check the sourceFiles field, then use ReadFile/Grep for deeper source code investigation. The DocumentSourceToolBudget (src/OpenDeepWiki/Agents/Tools/DocumentSourceToolBudget.cs) caps how many source-discovery tools (ListFiles/Grep/ReadFile) the agent can use per page.

OpenBMB/RepoAgent

answered

Retrieval (RAG) is implemented only in the optional chat-with-repo sub-package installed via pip install repoagent[chat-with-repo]. The main documentation-generation pipeline does not use RAG at all — it retrieves code context statically via the DocItem tree and reference relationships.

Within chat-with-repo, retrieval works as follows:

Embedding model: OpenAI's text-embedding-3-large, configured in vector_store_manager.py:52-55. It uses the same api_key and api_base as the chat completion.

Vector store: ChromaDB (persistent, stored at ./chroma_db). Documents are indexed into a ChromaVectorStore via LlamaIndex's VectorStoreIndex (vector_store_manager.py:48-113). The index is built by extracting markdown content and metadata from the project_hierarchy.json file, which is the output of the main doc-generation pipeline.

Chunking for RAG: The vector store uses SemanticSplitterNodeParser (buffer_size=1, breakpoint_percentile_threshold=95) with a SentenceSplitter fallback at chunk_size=1024 (vector_store_manager.py:60-63).

Top-k: default 5 (rag.py:34: top_k=5). On each query, the vector store is queried, then results are reranked by an LLM (gpt-4o-mini) that scores each document's relevance on a 0–100 scale via JSON output (rag.py:44-55). The top-5 reranked documents are kept.

How retrieved code reaches the prompt: The RepoAssistant.respond() method (rag.py:84-176) orchestrates a multi-stage pipeline:

  1. Extracts keywords via TextAnalysisTool.keyword() (text_analysis_tool.py:13-16)
  2. Generates 3 query variants via generate_queries() (rag.py:36-42)
  3. Queries Chroma with each variant, deduplicates by text content
  4. Reranks by LLM relevance score
  5. Runs a first-pass RAG generation via rag() (gpt-4o-mini)
  6. Extracts named entities (class/function names) from bot and user text via nerquery(), then looks up raw source code from the JSON (text_analysis_tool.py:42-55)
  7. Passes both the retrieved documents AND the raw source code into a final RAG-AR (Advanced RAG) call using the strong model (gpt-4o) (rag.py:74-82)

The final RAG-AR prompt includes related_code (source code snippets) and embedding_recall (documentation text) as separate sections (chat_with_repo/prompt.py:43-64).

aibox22/readmeX

answered

Retrieval is implemented via the CodeRAG class (code_rag.py:92-948). It has two vectorization paths configured by local_embedding (default true in config.py:197). Local path: loads a SentenceTransformer model, defaulting to Kwaipilot/OASIS-code-embedding-1.5B (code_rag.py:115). Web path: uses the OpenAI embeddings API (text-embedding-3-small) with configurable base_url/api_key (code_rag.py:591-637), sending texts in batches of 100. In either case, embedding text is built from Type, Name, Signature, docstring, code preview (first 500 chars), and dependencies (code_rag.py:526-552). The vectors are stored in a FAISS IndexFlatIP (inner-product similarity) index (code_rag.py:639-649), with L2 normalization applied. semantic_search(query, top_k=5, min_score=0.3) (code_rag.py:651-662) dispatches to either _vector_search() (FAISS or numpy dot-product) or _text_search() (term-matching fallback with weighted keyword scoring). The generate_enhanced_prompt() method (code_rag.py:789-828) wraps retrieved CodeBlock results — type, name, file path, signature, docstring, code snippet (truncated to 300 chars), and dependencies — into a === 相关代码上下文 === section appended to the base page-generation prompt. This is consumed by WebsiteGenerator._generate_page_content() (website_core.py:672-687), which calls code_rag.generate_enhanced_prompt() with a page-specific RAG query (e.g. '项目 {name} 架构 设计 模块结构 类关系 组件' for the architecture page). All code blocks, relations, embeddings, and the FAISS index are cached to pickle and .bin files under .rag_cache/ and loaded from there on subsequent runs (code_rag.py:868-933).

he-yufeng/RepoWiki

answered

Retrieval uses pure TF-IDF with no embedding models or vector database — no external service is needed. The core class is SimpleRAG (src/repowiki/core/rag.py:52-209). At index time, every project file is split into chunks via _split_into_chunks() (rag.py:358-387), tokenized by _tokenize() (rag.py:316-328), and stored as term-frequency vectors (Counter objects) alongside an inverse-document-frequency map built by _compute_idf() (rag.py:331-340). The tokenizer handles CJK by generating character bigrams (rag.py:324-327).

Retrieval for a question: rag.retrieve(query, top_k=5) (rag.py:170-209). Each chunk gets a TF-IDF cosine similarity score against the query tokens. Results are sorted by (direct-hit flag, score), so lexical matches always rank above boost-only chunks. The top 5 chunks are returned.

A second index, ModuleIndex (rag.py:212-256), runs TF-IDF over the LLM-generated module card text (purpose, key concepts, file purposes — vocabulary not present in raw code). Its file_scores() method produces a per-file boost map. In the chat endpoint, this boost is passed into rag.retrieve() as a boost parameter (rag.py:177-178), so a paraphrased question with zero lexical overlap against code can still reach the right files through the module card match. The built-in TF-IDF index is persisted to ~/.repowiki/rag/ as JSON and loaded incrementally: only files whose content hash changed are re-tokenized (rag.py:78-121). Retrieved chunks are formatted by format_context() (rag.py:299-313) into fenced code blocks labelled with file path and line range, then injected into the chat prompt as "Relevant Code".

Editor's note. Correction: the ModuleIndex boost is effectively unused at this commit. The web chat reads wiki.modules from a Wiki object that has no such field, so boost is always None, and the CLI chat never passes one; both paths are plain lexical TF-IDF.

weibaohui/openDeepWiki

answered

There is no vector embeddings model or vector store. Retrieval is entirely keyword-based. DocumentService.SearchDocuments() performs case-insensitive substring matching across document title, filename, and content fields (lines 331–401 of document.go). Results are capped at 20 with snippet generation (200 characters around the keyword match). The MCP server exposes search_documents, read_document, and get_document_summary tools that wrap these same keyword searches. In the Q&A chat system, the assistant agent receives the full repo metadata and a list of all documents (titles and DocIDs) injected into the system message. It can then call the read_doc(doc_id) tool to retrieve the complete document content when answering questions — this is agentic file reading, not RAG. There is no embedding, no top-k vector search, no similarity scoring anywhere in the codebase. The use of ModelWithMetadata and ChatModel wrappers (e.g., ProxyChatModel) shows that after an LLM receives context through the agent tools, generation happens directly via the configured provider model.

sopaco/deepwiki-rs

not applicable

DeepWiki-rs does not implement RAG or vector retrieval. There is no embedding model, vector store, or similarity search. Instead, it uses a Memory-based data access pattern where all preprocessing and research results are stored in an in-memory Memory store (key-value with scopes) and retrieved by key lookup. Agents declare their required data sources via AgentDataConfig — e.g. DataSource::MemoryData, DataSource::ResearchResult, or DataSource::ExternalKnowledgeByCategory — and the StepForwardAgent framework assembles them into a prompt via GeneratorPromptBuilder.build_standard_user_prompt(). This is not retrieval-augmented generation in the embedding sense: the system gathers all relevant context (project structure, code insights, relationship analysis, research reports, external knowledge) and packs it directly into the LLM prompt as formatted text. Large content is compressed via PromptCompressor or emergency-truncated.

← How is a repository ingested and chunked? · How is the wiki structure (table of contents) determined? →