<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Aryan Kasera</title>
    <description>The latest articles on DEV Community by Aryan Kasera (@aryankasera).</description>
    <link>https://dev.to/aryankasera</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4270036%2F1249bc57-7f9d-4e06-b1fa-078d43d008ce.jpg</url>
      <title>DEV Community: Aryan Kasera</title>
      <link>https://dev.to/aryankasera</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aryankasera"/>
    <language>en</language>
    <item>
      <title>How I built Ask the Repo: AST chunking vs fixed-size chunking for code RAG</title>
      <dc:creator>Aryan Kasera</dc:creator>
      <pubDate>Sat, 28 Nov 2026 04:38:24 +0000</pubDate>
      <link>https://dev.to/aryankasera/how-i-built-ask-the-repo-ast-chunking-vs-fixed-size-chunking-for-code-rag-1il0</link>
      <guid>https://dev.to/aryankasera/how-i-built-ask-the-repo-ast-chunking-vs-fixed-size-chunking-for-code-rag-1il0</guid>
      <description>&lt;p&gt;I'm a self-taught AI engineer, and I wanted to build something I could actually measure instead of just following a tutorial. The result is &lt;strong&gt;Ask the Repo&lt;/strong&gt;: paste a public Python repo from GitHub, ask a question, and get an answer with exact &lt;code&gt;file:line&lt;/code&gt; citations that link to the real code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Live demo:&lt;/strong&gt; &lt;a href="https://aryan-ask-the-repo.streamlit.app/" rel="noopener noreferrer"&gt;https://aryan-ask-the-repo.streamlit.app/&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Code:&lt;/strong&gt; &lt;a href="https://github.com/kaseraaryan5-star/ask-the-repo" rel="noopener noreferrer"&gt;https://github.com/kaseraaryan5-star/ask-the-repo&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;Generic code chatbots give answers that sound right, but I can't verify them. I wanted every claim to point to a specific place in the repo, so I could click through and check.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it works
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Clone the repo and split the Python files into chunks.&lt;/li&gt;
&lt;li&gt;Embed the chunks with Gemini embeddings and store them in Qdrant.&lt;/li&gt;
&lt;li&gt;For a question, retrieve the closest chunks, pass them to Gemini, and ask for an answer that cites the chunks it used.&lt;/li&gt;
&lt;li&gt;Each chunk keeps its file path and line range, so every citation becomes a link to those exact lines on GitHub.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The stack: Python, FastAPI, Qdrant, Gemini, and Streamlit for the frontend.&lt;/p&gt;

&lt;h2&gt;
  
  
  The interesting part: how you chunk code
&lt;/h2&gt;

&lt;p&gt;The usual approach is fixed-size chunks (for example, N characters with some overlap). For code, that cuts functions in half and mixes unrelated code into one chunk.&lt;/p&gt;

&lt;p&gt;Instead, I used the Python AST to split code along its natural boundaries: one chunk per function or class. Each chunk is a complete, meaningful unit, and its line range is exact, which also makes the citations precise.&lt;/p&gt;

&lt;h2&gt;
  
  
  Does it actually help?
&lt;/h2&gt;

&lt;p&gt;I wrote a small test set of 17 questions about repos, and measured top-1 retrieval accuracy (does the first retrieved chunk contain the answer?):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Chunking&lt;/th&gt;
&lt;th&gt;Top-1 accuracy&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Fixed-size&lt;/td&gt;
&lt;td&gt;53%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AST-based&lt;/td&gt;
&lt;td&gt;71%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Limitations (being honest)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The test set is small (17 questions), so treat these numbers as a signal, not a benchmark.&lt;/li&gt;
&lt;li&gt;The live demo shares one index between visitors, so indexing a new repo replaces the previous one.&lt;/li&gt;
&lt;li&gt;It supports Python repos only, because the chunker uses Python's AST.&lt;/li&gt;
&lt;li&gt;The demo runs on free hosting and Gemini's free tier. It can take about 30 seconds to wake up and may occasionally be busy.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I'd do next
&lt;/h2&gt;

&lt;p&gt;Per-user indexes, support for more languages, and a larger evaluation set.&lt;/p&gt;

&lt;p&gt;If you try it on a repo and it gets something wrong, I'd love to hear about it. The code is open source, and feedback is very welcome.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>rag</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
