<?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: Yaman Kavishwar</title>
    <description>The latest articles on DEV Community by Yaman Kavishwar (@yamankavishwar).</description>
    <link>https://dev.to/yamankavishwar</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%2F4173242%2F1fedbe98-8406-4b94-88a1-1fdfc36ef654.png</url>
      <title>DEV Community: Yaman Kavishwar</title>
      <link>https://dev.to/yamankavishwar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yamankavishwar"/>
    <language>en</language>
    <item>
      <title>Snowflake vs BigQuery vs Redshift vs Databricks: Start With How You're Billed</title>
      <dc:creator>Yaman Kavishwar</dc:creator>
      <pubDate>Thu, 19 Nov 2026 15:40:00 +0000</pubDate>
      <link>https://dev.to/yamankavishwar/snowflake-vs-bigquery-vs-redshift-vs-databricks-start-with-how-youre-billed-hkn</link>
      <guid>https://dev.to/yamankavishwar/snowflake-vs-bigquery-vs-redshift-vs-databricks-start-with-how-youre-billed-hkn</guid>
      <description>&lt;p&gt;&lt;em&gt;Notes for data engineers and tech leads choosing a cloud warehouse in 2026. Adapted from the full comparison on the &lt;a href="https://vectovateai.com/blogs/snowflake-vs-bigquery-vs-redshift-vs-databricks-cloud-data-warehouse-2026" rel="noopener noreferrer"&gt;VectovateAI blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsbszpx72glctk9l6vnk6.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsbszpx72glctk9l6vnk6.jpg" alt="Cost, speed, scaling and AI features compared across Snowflake, BigQuery, Redshift and Databricks" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Every few months someone on a team asks "should we move to Snowflake / BigQuery / Databricks?" and the thread fills up with benchmark links. Here's the shorter version we give clients: for normal BI and reporting, all four are fast enough. What actually bites you a year later is &lt;strong&gt;how you're billed&lt;/strong&gt;, &lt;strong&gt;which cloud you're tied to&lt;/strong&gt;, and &lt;strong&gt;how much tuning your team has to do&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How each one bills you
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Unit you pay for&lt;/th&gt;
&lt;th&gt;What drives the bill&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Snowflake&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Credits, per second, per virtual warehouse (60s minimum on resume)&lt;/td&gt;
&lt;td&gt;Warehouse size × time it's running&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;BigQuery&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Per TiB scanned (on-demand) or per slot-hour&lt;/td&gt;
&lt;td&gt;Bytes your queries scan, or reserved capacity&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Redshift&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Per RPU-hour (serverless) or per node-hour&lt;/td&gt;
&lt;td&gt;Capacity left running, cluster size&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Databricks&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;DBUs (plus cloud VMs on classic compute)&lt;/td&gt;
&lt;td&gt;Cluster/warehouse size × runtime&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two practical consequences:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;BigQuery on-demand punishes unpartitioned tables.&lt;/strong&gt; One &lt;code&gt;SELECT *&lt;/code&gt; on a big table can cost more than a day of everything else. Partition, cluster and set query quotas from day one.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Snowflake and Databricks punish idle compute.&lt;/strong&gt; Auto-suspend and right-sizing matter more than which warehouse you picked.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Who each one fits
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;BigQuery:&lt;/strong&gt; you're already on Google Cloud, your marketing data lives in GA4 / Google Ads, and your workload is spiky and ad-hoc. Nothing to manage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Redshift:&lt;/strong&gt; you're AWS-centred with steady reporting. Zero-ETL from Aurora, RDS and DynamoDB saves pipeline work, and reservations help with predictable load.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Snowflake:&lt;/strong&gt; you're multi-cloud or want the least admin. Separate warehouses keep one team's heavy job from slowing everyone else.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Databricks:&lt;/strong&gt; the same team does pipelines, streaming and ML on the same data. Open formats, more knobs, steeper learning curve.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Run a proof of concept that means something
&lt;/h2&gt;

&lt;p&gt;Vendor benchmarks are tuned to flatter the sponsor. Run your own:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Pick 15–20 &lt;strong&gt;real&lt;/strong&gt; queries, including your slowest report and your most frequent one.&lt;/li&gt;
&lt;li&gt;Load a realistic slice of data. A tiny sample makes everything look fast.&lt;/li&gt;
&lt;li&gt;Simulate peak hour: the number of people and dashboards hitting it at 9am on a Monday.&lt;/li&gt;
&lt;li&gt;Run for two weeks, then compare the &lt;strong&gt;full&lt;/strong&gt; bill and the hours your team spent tuning.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Compare total monthly cost, not unit price. Storage, cross-region transfer, serverless add-ons and BI tools hammering the warehouse all sit on top of the headline rate. Flexera's 2026 State of the Cloud report puts wasted cloud spend at around 29%, so budgets, alerts and quotas belong in week one, not after the first surprise invoice.&lt;/p&gt;

&lt;h2&gt;
  
  
  Migration mistakes we keep seeing
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Lift-and-shift of the old schema and nightly batches.&lt;/strong&gt; You get the old problems at cloud prices.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hand-converting SQL.&lt;/strong&gt; Use the vendor tools (e.g. SnowConvert, BigQuery Migration Service) for the first pass and review the output.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Skipping validation.&lt;/strong&gt; Run old and new side by side and reconcile row counts, totals and key reports before switching anyone.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Big-bang cutover.&lt;/strong&gt; Move one business domain at a time, starting with something valuable but low-risk.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Forgetting the BI layer.&lt;/strong&gt; Dashboards, semantic models and permissions have to move too.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Lock-in is lower than it used to be
&lt;/h2&gt;

&lt;p&gt;All four now work with Apache Iceberg tables, so data can sit in your own object storage and be read by more than one engine. Plenty of larger teams run two platforms on purpose, for example Databricks for engineering and Snowflake or BigQuery for BI. Just be honest that it means two bills and two skill sets.&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;There's no "best" warehouse, only the one that fits your cloud, your workloads and your team. Shortlist two, test them on your own queries, model the cost honestly and migrate in phases.&lt;/p&gt;

&lt;p&gt;Which one are you running, and what surprised you on the bill? Curious to hear in the comments.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I'm Yaman, founder of &lt;a href="https://vectovateai.com" rel="noopener noreferrer"&gt;VectovateAI&lt;/a&gt;. We do platform-neutral data warehouse and data engineering work across all four. The &lt;a href="https://vectovateai.com/blogs/snowflake-vs-bigquery-vs-redshift-vs-databricks-cloud-data-warehouse-2026" rel="noopener noreferrer"&gt;full article&lt;/a&gt; has current list prices and pros and cons for each platform.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>dataengineering</category>
      <category>database</category>
      <category>cloud</category>
      <category>sql</category>
    </item>
    <item>
      <title>Your RAG Index Is Already Out of Date: Building an Incremental Ingestion Pipeline</title>
      <dc:creator>Yaman Kavishwar</dc:creator>
      <pubDate>Wed, 11 Nov 2026 11:05:00 +0000</pubDate>
      <link>https://dev.to/yamankavishwar/your-rag-index-is-already-out-of-date-building-an-incremental-ingestion-pipeline-3ag6</link>
      <guid>https://dev.to/yamankavishwar/your-rag-index-is-already-out-of-date-building-an-incremental-ingestion-pipeline-3ag6</guid>
      <description>&lt;p&gt;Most retrieval-augmented generation (RAG) tutorials end at the same point: load some documents, split them into chunks, embed them, store them in a vector database and ask questions. That is enough for a demo. It is not enough for a system that a business relies on, because real documents change every day.&lt;/p&gt;

&lt;p&gt;Policies get revised, product pages get updated, a contract gets replaced and an old one should no longer be quoted. If your index does not reflect those changes, your assistant will confidently answer with yesterday's facts. In my experience, stale or duplicated chunks cause more wrong answers than the language model itself.&lt;/p&gt;

&lt;p&gt;The quick fix teams usually try is to rebuild the whole index every night. That works until the corpus grows, embedding bills climb and a nightly job fails halfway, leaving a half-built index in production. In this article I walk through a simpler pattern: an incremental pipeline that only re-embeds what changed, removes what was deleted and keeps a record of where every chunk came from.&lt;/p&gt;

&lt;h2&gt;
  
  
  The design in one picture
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fitam9if0pqyqkgl5kej7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fitam9if0pqyqkgl5kej7.png" alt="Incremental RAG ingestion pipeline: chunk registry with stable IDs and content hashes" width="800" height="276"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The key idea is a &lt;strong&gt;chunk registry&lt;/strong&gt;: a small table that stores, for every chunk, a stable ID and a hash of its content. On each run, we compute the chunks again, compare hashes and only touch what is different.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Chunk by structure, with stable IDs
&lt;/h2&gt;

&lt;p&gt;Chunking by fixed character counts creates two problems. It cuts sentences and clauses in half, and the chunk boundaries move every time someone edits the start of a document. If boundaries move, every chunk after the edit looks "new" and you re-embed the whole document.&lt;/p&gt;

&lt;p&gt;Chunking by headings solves both. A section is a natural unit of meaning, and an edit in one section does not change the others.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;hashlib&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;dataclasses&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;dataclass&lt;/span&gt;

&lt;span class="nd"&gt;@dataclass&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Chunk&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;doc_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;chunk_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;content_hash&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;source_url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;section&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;

&lt;span class="n"&gt;HEADING&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;^(#{1,3})\s+(.*)$&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MULTILINE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;chunk_markdown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;doc_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;source_url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;max_chars&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Split a markdown document by headings; split long sections by paragraph.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="n"&gt;positions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;HEADING&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;finditer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;positions&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;positions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;positions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="n"&gt;chunks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;zip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;positions&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;positions&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:]):&lt;/span&gt;
        &lt;span class="n"&gt;section&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;section&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;
        &lt;span class="n"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;section&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;splitlines&lt;/span&gt;&lt;span class="p"&gt;()[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;lstrip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;# &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;buf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="sh"&gt;""&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;para&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;section&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n\n&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;buf&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;para&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;max_chars&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="n"&gt;buf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;""&lt;/span&gt;
            &lt;span class="n"&gt;buf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="se"&gt;\n\n&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;para&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;buf&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;para&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;part&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="c1"&gt;# Stable ID: document + section title + position inside the section
&lt;/span&gt;            &lt;span class="n"&gt;chunk_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;hashlib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sha1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;doc_id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;|&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;|&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="nf"&gt;hexdigest&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="n"&gt;content_hash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;hashlib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sha256&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;part&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="nf"&gt;hexdigest&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="n"&gt;chunks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Chunk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;doc_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;chunk_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;part&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;content_hash&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;source_url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;chunks&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two hashes do two different jobs. The &lt;code&gt;chunk_id&lt;/code&gt; identifies &lt;em&gt;where&lt;/em&gt; a chunk lives (document, section, position). The &lt;code&gt;content_hash&lt;/code&gt; tells us &lt;em&gt;whether its text changed&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Add document context to each chunk
&lt;/h2&gt;

&lt;p&gt;A chunk that reads "Refunds are processed within 14 days" is ambiguous on its own. Which product? Which region? Which version? Retrieval improves noticeably when each chunk carries a short header with the document title and section path. Anthropic described a more advanced version of this idea as &lt;a href="https://www.anthropic.com/news/contextual-retrieval" rel="noopener noreferrer"&gt;contextual retrieval&lt;/a&gt;. A plain header is a good, cheap start:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;with_context&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Chunk&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;doc_title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Document: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;doc_title&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;Section: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;section&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="se"&gt;\n\n&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Embed the contextualised text, but hash the raw text. That way, renaming a document does not force a full re-embed unless you want it to.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Compare against the registry
&lt;/h2&gt;

&lt;p&gt;The registry can live in the same Postgres database as your vectors if you use &lt;a href="https://github.com/pgvector/pgvector" rel="noopener noreferrer"&gt;pgvector&lt;/a&gt;, which keeps the update atomic. One table is enough:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="n"&gt;EXTENSION&lt;/span&gt; &lt;span class="n"&gt;IF&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;EXISTS&lt;/span&gt; &lt;span class="n"&gt;vector&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;IF&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;EXISTS&lt;/span&gt; &lt;span class="n"&gt;rag_chunks&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;chunk_id&lt;/span&gt;      &lt;span class="nb"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;PRIMARY&lt;/span&gt; &lt;span class="k"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;doc_id&lt;/span&gt;        &lt;span class="nb"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;content_hash&lt;/span&gt;  &lt;span class="nb"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;source_url&lt;/span&gt;    &lt;span class="nb"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;body&lt;/span&gt;          &lt;span class="nb"&gt;TEXT&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;embedding&lt;/span&gt;     &lt;span class="n"&gt;vector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;384&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;updated_at&lt;/span&gt;    &lt;span class="n"&gt;TIMESTAMPTZ&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt; &lt;span class="k"&gt;DEFAULT&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="n"&gt;IF&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;EXISTS&lt;/span&gt; &lt;span class="n"&gt;rag_chunks_doc&lt;/span&gt; &lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;rag_chunks&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;doc_id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For each document we load the existing hashes and sort the new chunks into three groups:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;diff_chunks&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new_chunks&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;existing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;]):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;existing maps chunk_id -&amp;gt; content_hash for one document.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="n"&gt;new_ids&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;chunk_id&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;new_chunks&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;to_upsert&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;new_chunks&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;existing&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;chunk_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content_hash&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;to_delete&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;cid&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;cid&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;existing&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;cid&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;new_ids&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;unchanged&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new_chunks&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;to_upsert&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;to_upsert&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;to_delete&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;unchanged&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4: Embed only what changed, in one transaction
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;psycopg&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pgvector.psycopg&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;register_vector&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sentence_transformers&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SentenceTransformer&lt;/span&gt;

&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;SentenceTransformer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;all-MiniLM-L6-v2&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# 384 dimensions
&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;sync_document&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;doc_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;doc_title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;source_url&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;new_chunks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;chunk_markdown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;doc_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;source_url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;SELECT chunk_id, content_hash FROM rag_chunks WHERE doc_id = %s&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;doc_id&lt;/span&gt;&lt;span class="p"&gt;,)&lt;/span&gt;
    &lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;fetchall&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;to_upsert&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;to_delete&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;unchanged&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;diff_chunks&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new_chunks&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="n"&gt;vectors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="nf"&gt;with_context&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;doc_title&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;to_upsert&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;to_upsert&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;transaction&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;zip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;to_upsert&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vectors&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;INSERT INTO rag_chunks (chunk_id, doc_id, content_hash, source_url, body, embedding)
                   VALUES (%s, %s, %s, %s, %s, %s)
                   ON CONFLICT (chunk_id) DO UPDATE SET
                     content_hash = EXCLUDED.content_hash, body = EXCLUDED.body,
                     embedding = EXCLUDED.embedding, source_url = EXCLUDED.source_url,
                     updated_at = now()&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;chunk_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;doc_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content_hash&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;source_url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;to_delete&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;DELETE FROM rag_chunks WHERE chunk_id = ANY(%s)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;to_delete&lt;/span&gt;&lt;span class="p"&gt;,))&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;upserted&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;to_upsert&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;deleted&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;to_delete&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;unchanged&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;unchanged&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;psycopg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;postgresql://localhost/rag&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;register_vector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;sync_document&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;refund-policy&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Refund Policy (EU)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                        &lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;refund_policy.md&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://intranet/refund-policy&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because the upserts and deletes run in one transaction, a failure halfway leaves the previous version of the document intact rather than a mix of old and new chunks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Handle deleted documents
&lt;/h2&gt;

&lt;p&gt;The diff above handles deleted &lt;em&gt;sections&lt;/em&gt;. Deleted &lt;em&gt;documents&lt;/em&gt; need one more check: compare the list of document IDs in your source system with the IDs in the table and remove the ones that no longer exist. Skipping this step is the most common reason old policies keep showing up in answers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;remove_missing_documents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;live_doc_ids&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;]):&lt;/span&gt;
    &lt;span class="n"&gt;indexed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;SELECT DISTINCT doc_id FROM rag_chunks&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
    &lt;span class="n"&gt;gone&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;indexed&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;live_doc_ids&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;gone&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;DELETE FROM rag_chunks WHERE doc_id = ANY(%s)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gone&lt;/span&gt;&lt;span class="p"&gt;,))&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;gone&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What this changes in practice
&lt;/h2&gt;

&lt;p&gt;On a typical business corpus, only a small share of chunks changes on any given day, so most runs embed very little. A nightly full rebuild re-embeds every chunk whether it changed or not, so its cost grows with the size of the corpus. The incremental run grows with the amount of change instead, which is usually a small fraction.&lt;/p&gt;

&lt;p&gt;Two other benefits matter as much as cost:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Traceability.&lt;/strong&gt; Every answer can cite &lt;code&gt;source_url&lt;/code&gt; and &lt;code&gt;updated_at&lt;/code&gt;, so users can check the source and see how recent it is.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Debuggability.&lt;/strong&gt; When an answer is wrong, you can see exactly which chunk version was retrieved and when it was last updated.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Things to watch
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Changing the embedding model&lt;/strong&gt; invalidates every vector. Store the model name in the table and do a full rebuild into a new table when you switch, then swap.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Changing the chunking logic&lt;/strong&gt; changes chunk IDs. Treat it the same way as a model change.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Very large sections&lt;/strong&gt; still need a size limit, as in the paragraph splitting above, or retrieval quality drops.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test retrieval on its own.&lt;/strong&gt; Keep a small set of real questions with known source sections, and check after each pipeline change that the right chunk still appears in the top results.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;A RAG system is only as current as its index. Chunk by structure, give every chunk a stable ID and a content hash, re-embed only what changed and delete what disappeared. It is a few dozen lines of code, and it removes a whole class of confidently wrong answers.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I'm Yaman Kavishwar, founder of &lt;a href="https://vectovateai.com" rel="noopener noreferrer"&gt;VectovateAI&lt;/a&gt;, where we build RAG systems, AI agents and data platforms for businesses. If you've solved index freshness differently, I'd like to hear how in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>rag</category>
      <category>python</category>
      <category>postgres</category>
      <category>ai</category>
    </item>
    <item>
      <title>Deep Learning vs Machine Learning: Which Does Your Project Actually Need?</title>
      <dc:creator>Yaman Kavishwar</dc:creator>
      <pubDate>Sat, 07 Nov 2026 05:34:00 +0000</pubDate>
      <link>https://dev.to/yamankavishwar/deep-learning-vs-machine-learning-which-does-your-project-actually-need-fmb</link>
      <guid>https://dev.to/yamankavishwar/deep-learning-vs-machine-learning-which-does-your-project-actually-need-fmb</guid>
      <description>&lt;p&gt;&lt;em&gt;A practical guide for developers and tech leads who get asked "should we use deep learning for this?" Adapted from the original article on the &lt;a href="https://vectovateai.com/blogs/deep-learning-vs-machine-learning-when-does-your-business-need-deep-learning" rel="noopener noreferrer"&gt;VectovateAI blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbcvtgguxmh5i9e5qwp3j.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbcvtgguxmh5i9e5qwp3j.jpg" alt="Business data splitting into two paths: tables and numbers to traditional ML, images, audio and text to deep learning" width="799" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A client has a churn problem, a CSV export from their CRM, and a vendor pitching a neural network. It's almost never the right call. A well-tuned gradient-boosted model will usually get there faster and cheaper.&lt;/p&gt;

&lt;p&gt;The opposite mistake happens too: someone tries to read scanned invoices or inspect product photos with rules and simple models, then can't get accuracy high enough to trust.&lt;/p&gt;

&lt;p&gt;Here is the checklist we use to decide which side of the line a project sits on.&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Deep learning is a subset of machine learning. The practical difference: in classic ML, &lt;strong&gt;you&lt;/strong&gt; engineer the features; in deep learning, &lt;strong&gt;the network&lt;/strong&gt; learns them from raw data.&lt;/li&gt;
&lt;li&gt;On rows-and-columns data, classic ML usually wins. A &lt;a href="https://arxiv.org/abs/2207.08815" rel="noopener noreferrer"&gt;NeurIPS benchmark across 45 tabular datasets&lt;/a&gt; found tree-based models still state-of-the-art on medium-sized data (~10k samples).&lt;/li&gt;
&lt;li&gt;Deep learning earns its cost on images, video, audio, free text and long sensor sequences.&lt;/li&gt;
&lt;li&gt;You rarely train from scratch anymore. Transfer learning cuts the data and compute you need.&lt;/li&gt;
&lt;li&gt;Data readiness kills more projects than model choice. &lt;a href="https://www.gartner.com/en/newsroom/press-releases/2025-02-26-lack-of-ai-ready-data-puts-ai-projects-at-risk" rel="noopener noreferrer"&gt;Gartner expects 60% of AI projects without AI-ready data to be abandoned through 2026&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Classic ML is usually enough when…
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The data is structured.&lt;/strong&gt; Churn, lead scoring, credit risk, demand forecasting, pricing: all rows and columns.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Labeled data is limited.&lt;/strong&gt; Thousands of examples, not millions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Decisions must be explained.&lt;/strong&gt; Lending, insurance and healthcare need answers to "why?", and simpler models give them more easily.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Running costs matter.&lt;/strong&gt; These models run on ordinary CPUs and respond in milliseconds.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Worth knowing: the gap is narrowing. &lt;a href="https://www.nature.com/articles/s41586-024-08328-6" rel="noopener noreferrer"&gt;TabPFN (Nature, 2025)&lt;/a&gt; is a pre-trained model for tables that beat tuned baselines on datasets up to 10k samples. But that's a ready-made model you apply, not a custom network you build. The rule still holds: start with the simplest model that meets the target.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deep learning is worth it when…
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Images and video:&lt;/strong&gt; defect detection, medical scans, shelf monitoring, document field extraction.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Text and language:&lt;/strong&gt; routing tickets by meaning, extracting contract clauses, intent-based search.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Voice and audio:&lt;/strong&gt; transcription, voice interfaces, acoustic anomaly detection on machines.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Large sequential data:&lt;/strong&gt; sensor streams, clickstreams, long time series where hand-built features miss the pattern.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You've hit a ceiling:&lt;/strong&gt; the classic model stopped improving, more features don't help, and you have plenty of data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And you rarely start from zero. With &lt;a href="https://www.tensorflow.org/tutorials/images/transfer_learning" rel="noopener noreferrer"&gt;transfer learning&lt;/a&gt; you take a network pre-trained on a large dataset and fine-tune it on your much smaller one. A visual inspection pilot can often start with thousands of labeled images instead of millions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A quick test:&lt;/strong&gt; could a person make this decision by looking at one row of a spreadsheet? Classic ML. Would they need to look at a picture, listen to a recording or read a document? Deep learning.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvhwvl4tgdayk5n2oo4tb.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvhwvl4tgdayk5n2oo4tb.jpg" alt="Flowchart: structured tabular data at moderate volume leads to machine learning; unstructured images, audio and text at large volume to deep learning" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the money actually goes
&lt;/h2&gt;

&lt;p&gt;Training is rarely the biggest cost. In order of how often they surprise teams:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Labeled data.&lt;/strong&gt; The real expense. Budget for labeling and data engineering before modeling.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compute.&lt;/strong&gt; GPUs for training and often for serving. Prices have dropped (&lt;a href="https://aws.amazon.com/blogs/aws/announcing-up-to-45-price-reduction-for-amazon-ec2-nvidia-gpu-accelerated-instances/" rel="noopener noreferrer"&gt;AWS cut P4/P5 instance prices by up to 45% in June 2025&lt;/a&gt;), but experiments add up and serving runs for the life of the product.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;People.&lt;/strong&gt; Engineers who know neural architectures &lt;em&gt;and&lt;/em&gt; the MLOps that keeps models healthy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Upkeep.&lt;/strong&gt; Models drift. Monitoring and retraining need a budget from day one.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Three habits keep the bill in check:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ship a classic ML baseline first. If it delivers most of the value, stop there.&lt;/li&gt;
&lt;li&gt;Start from a pre-trained model.&lt;/li&gt;
&lt;li&gt;Label a small pilot set, prove the idea, then invest in more data.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Framework note
&lt;/h2&gt;

&lt;p&gt;PyTorch leads new development, with about 59M monthly &lt;a href="https://pypistats.org/packages/torch" rel="noopener noreferrer"&gt;PyPI downloads&lt;/a&gt; against roughly 12M for TensorFlow. TensorFlow still runs a lot of enterprise systems and, via &lt;a href="https://ai.google.dev/edge/litert" rel="noopener noreferrer"&gt;LiteRT&lt;/a&gt;, plenty of on-device inference. If a client's stack is already on TensorFlow, extending it usually beats a rewrite.&lt;/p&gt;

&lt;h2&gt;
  
  
  Questions to ask before you commit
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Did we run a baseline first? If the proposal jumps straight to a neural network, ask why.&lt;/li&gt;
&lt;li&gt;Who owns the data pipeline? Models fail when the data feeding them breaks; the same team should own both.&lt;/li&gt;
&lt;li&gt;Where does a human review the output? High-stakes predictions need a person in the loop.&lt;/li&gt;
&lt;li&gt;What gets delivered? Not just a model: the data pipeline, a deployed service, monitoring, a retraining plan and docs the client's team can follow.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;Deep learning is the right tool for pictures, sound, language and very large data. Classic ML is the right tool for almost everything that fits in a table. The expensive mistakes come from mixing the two up.&lt;/p&gt;

&lt;p&gt;What's your rule of thumb for this call? Let me know in the comments.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I'm Yaman, founder of &lt;a href="https://vectovateai.com" rel="noopener noreferrer"&gt;VectovateAI&lt;/a&gt;. We build ML, deep learning and data systems for businesses. The full version of this article, with industry examples and cost detail, is on &lt;a href="https://vectovateai.com/blogs/deep-learning-vs-machine-learning-when-does-your-business-need-deep-learning" rel="noopener noreferrer"&gt;our blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>deeplearning</category>
      <category>ai</category>
      <category>datascience</category>
    </item>
    <item>
      <title>AI-Native Software Development: Why Bolted-On AI Fails and What Building AI-First Actually Looks Like</title>
      <dc:creator>Yaman Kavishwar</dc:creator>
      <pubDate>Fri, 09 Oct 2026 11:07:28 +0000</pubDate>
      <link>https://dev.to/yamankavishwar/ai-native-software-development-why-bolted-on-ai-fails-and-what-building-ai-first-actually-looks-4jm0</link>
      <guid>https://dev.to/yamankavishwar/ai-native-software-development-why-bolted-on-ai-fails-and-what-building-ai-first-actually-looks-4jm0</guid>
      <description>&lt;p&gt;Every software vendor claims “AI-powered” today. But most of that AI is duct-taped onto systems built for a different era.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://vectovateai.com/services/ai-native-software-development" rel="noopener noreferrer"&gt;AI-native software development&lt;/a&gt; flips that model putting AI at the core of the architecture. This guide breaks down what that actually means, why bolted-on AI keeps failing, and what a real AI-first build looks like in 2026.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;AI-native software development puts AI in the core architecture, not on top of it. The removal test settles the question: take AI away, and if the product breaks, it was AI-native.&lt;/li&gt;
&lt;li&gt;Bolted-on AI inherits every weakness of the legacy system underneath it, including data rigidity, per-seat pricing conflicts, and clunky UX.&lt;/li&gt;
&lt;li&gt;Gartner predicts &lt;a href="https://www.gartner.com/en/newsroom/press-releases/2025-06-25-gartner-predicts-over-40-percent-of-agentic-ai-projects-will-be-canceled-by-end-of-2027" rel="noopener noreferrer"&gt;over 40% of agentic AI projects will be canceled by the end of 2027&lt;/a&gt;, mostly from automating broken processes instead of rebuilding around AI-native principles.&lt;/li&gt;
&lt;li&gt;Real AI-native platforms track rich, multi-attribute data foundations and adapt continuously, not reactively.&lt;/li&gt;
&lt;li&gt;The right build order is: define the task, design the data model, choose the AI integration pattern, then build the interface last.&lt;/li&gt;
&lt;li&gt;Human-in-the-loop review stays essential for high-stakes decisions, even in a fully agent-first system.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What Is AI Native Development?
&lt;/h2&gt;

&lt;p&gt;In simple terms, it means designing a product’s data, workflows, and interface around AI from day one, instead of adding a chatbot to an existing system.&lt;/p&gt;

&lt;p&gt;Bolted-on AI sits on top of legacy architecture, it reads data, suggests actions, and stops there. AI-native development instead makes the model part of the core, structures data so the model can reason over it, and assumes intelligence is available at every step of the workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  AI-Native vs Traditional Enterprise Development Tools
&lt;/h2&gt;

&lt;p&gt;This is where AI native app building platforms vs traditional enterprise development tools really diverge.&lt;/p&gt;

&lt;p&gt;A useful benchmark test involves removing all AI features from a product; if it still functions as a viable tool, the AI was added on, and if it collapses, the product is AI-native.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Approach&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Data Model&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;AI’s Role&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;What Breaks Without AI&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Bolted-on AI&lt;/td&gt;
&lt;td&gt;Built for humans, AI reads it later&lt;/td&gt;
&lt;td&gt;Suggests, summarizes, chats&lt;/td&gt;
&lt;td&gt;Nothing. Core product still runs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AI-native development&lt;/td&gt;
&lt;td&gt;Built for AI agents to act on&lt;/td&gt;
&lt;td&gt;Core execution engine&lt;/td&gt;
&lt;td&gt;The entire product&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;In a bolt-on platform, the core execution engine still runs on scripts, not intent, so tests behave exactly as the scripts define them, and while the AI module may suggest fixes, the underlying rigid structure stays unchanged. That’s the trap. AI patched onto an old foundation inherits every weakness of that foundation.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Why Bolted-On AI Fails: The Three Structural Traps&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;AI native development platforms solve three problems that bolt-on tools structurally cannot fix:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Data model rigidity.&lt;/strong&gt; Legacy databases expect humans to enter data slowly and carefully. AI agents generate and act on data at machine speed. Forcing that into an old schema breaks reports, integrations, and workflows built on top of it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pricing model conflict.&lt;/strong&gt; Per-seat pricing assumes humans are the primary users. When AI agents handle work that used to need five people, that revenue model collapses on its own.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;UX design conflict.&lt;/strong&gt; Old interfaces are built around menus and forms. AI-native interfaces accept natural language and let agents act. Bolting one onto the other creates a clumsy hybrid that satisfies neither.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The 2025 &lt;a href="https://dora.dev/research/2025/dora-report/" rel="noopener noreferrer"&gt;DORA Report&lt;/a&gt;, based on nearly 5,000 technology professionals globally, found that AI does not fix a team, it amplifies whatever is already there. That single line explains why so many “AI transformation” projects on old platforms quietly fail. You cannot automate your way out of a broken foundation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gartner AI-Native Development Platforms 2026: What the Data Says
&lt;/h2&gt;

&lt;p&gt;The numbers back this up clearly. Here’s what the research firms are projecting for AI-native development platforms trends 2026:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Source&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Finding&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://www.gartner.com/en/newsroom/press-releases/2025-08-26-gartner-predicts-40-percent-of-enterprise-apps-will-feature-task-specific-ai-agents-by-2026-up-from-less-than-5-percent-in-2025" rel="noopener noreferrer"&gt;Gartner&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;40% of enterprise apps will feature task-specific AI agents by end of 2026, up from under 5% in 2025&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://www.gartner.com/en/newsroom/press-releases/2025-10-20-gartner-identifies-the-top-strategic-technology-trends-for-2026" rel="noopener noreferrer"&gt;Gartner&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;80% of organizations will evolve large dev teams into smaller, AI-augmented teams by 2030&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://www.gartner.com/en/newsroom/press-releases/2025-06-25-gartner-predicts-over-40-percent-of-agentic-ai-projects-will-be-canceled-by-end-of-2027" rel="noopener noreferrer"&gt;Gartner&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;40% of agentic AI projects will fail by 2027, largely because teams automate broken processes instead of redesigning around AI-native principles&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://www.deloitte.com/us/en/insights/topics/technology-management/tech-trends/2026/ai-future-it-function.html" rel="noopener noreferrer"&gt;Deloitte&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;78% of tech leaders anticipate broad AI agent integration into their architecture within the next five years&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;That Gartner failure statistic matters more than the growth ones. It tells you the risk isn’t underusing AI. The risk is bolting AI onto broken processes and calling it transformation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Features of AI-Native Software Development Platforms
&lt;/h2&gt;

&lt;p&gt;If you’re evaluating AI native development firms, here’s what to actually look for. These are the key features of ai-native software development platforms 2025 2026 that separate real AI-native builds from marketing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Intent-driven design&lt;/strong&gt;: You describe the outcome. The system determines the steps, instead of forcing you to script every action manually.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multi-attribute data foundations&lt;/strong&gt;: Instead of tracking a single data point per element, resilient architectures track hundreds of attributes per element, so no single change breaks the system.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Continuous adaptation, not reactive patching&lt;/strong&gt;: real self-healing monitors how the application changes and updates the model automatically before failures accumulate, rather than alerting a human after something breaks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Human-in-the-loop governance&lt;/strong&gt;: AI acts, but a person reviews high-stakes decisions before they go live.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Agent-first workflows&lt;/strong&gt;: Routine, repeatable work runs through AI agents. People supervise outcomes instead of performing every step by hand.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What an AI-Native Developer Actually Does Differently
&lt;/h2&gt;

&lt;p&gt;An AI native developer doesn’t start with wireframes. They start by defining the decision or task the AI will own, then design the data model around that task first. Only after that comes the interface. This order matters. Build the screen first, and you’ll end up retrofitting AI later, which is exactly the bolt-on trap this whole guide is about.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Developer-first AI-native companies&lt;/strong&gt; treat the model choice and &lt;a href="https://vectovateai.com/services/ai-integration" rel="noopener noreferrer"&gt;AI integration&lt;/a&gt; pattern as a foundational decision, not an afterthought bolted on before launch. They keep a human review step for anything high-stakes, whether that’s a financial transaction, a healthcare workflow, or a customer-facing action. AI moves fast. Judgment still needs a person in the loop.&lt;/p&gt;

&lt;h2&gt;
  
  
  Who’s Actually Behind These Builds?
&lt;/h2&gt;

&lt;p&gt;If you look closely at AI deployment manager profiles at developer-first AI-native companies, a pattern shows up fast. They’re people who sit between the agent and the business outcome, decide what the agent is allowed to touch, and own the rollback plan before anything goes live.&lt;/p&gt;

&lt;p&gt;That’s the real difference between a company that talks about being AI-native and one that actually is. Developer-first AI-native companies don’t treat deployment as an afterthought handled by whoever’s free that week. They build it into the role from day one, the same way they build AI into the architecture from day one.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Building AI-First Actually Looks Like: A Practical Example
&lt;/h2&gt;

&lt;p&gt;Picture two ways to build the same thing: an internal client portal with status tracking and a support assistant.&lt;/p&gt;

&lt;h3&gt;
  
  
  The bolted-on route:
&lt;/h3&gt;

&lt;p&gt;Build database tables, design pages by hand, wire up a chatbot widget at the end. The chatbot can summarize what’s already there. It cannot restructure the workflow, act on data, or run anything autonomously.&lt;/p&gt;

&lt;h3&gt;
  
  
  The AI-native route:
&lt;/h3&gt;

&lt;p&gt;Design the task first (client wants project status without asking a human). Build the data model so an agent can query it directly. Deploy the agent with real context and a clear boundary on what it can do without approval. The interface comes last, shaped around what the agent needs to work well.&lt;/p&gt;

&lt;p&gt;The difference isn’t speed alone. It’s capability. One produces a page with a chatbot stapled to it. The other produces a system where intelligence is load-bearing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Best AI Native Software Development Firms: What to Ask Before You Hire
&lt;/h2&gt;

&lt;p&gt;If you’re comparing best AI-native software development firms, skip the marketing deck and ask these directly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Where does AI live in your architecture? Is it the execution engine, or a layer sitting on top of an older script-based system?&lt;/li&gt;
&lt;li&gt;Can your platform work from a plain description of the outcome, without a developer writing every step first?&lt;/li&gt;
&lt;li&gt;What happens when the underlying application changes? Does the system adapt on its own, or does someone get an alert to fix it manually?&lt;/li&gt;
&lt;li&gt;Show a live build, not a recorded demo.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Any firm that answers vaguely, or leans on phrases like “AI-enhanced,” is likely bolting AI onto an older system. That’s not automatically wrong for every project. But it’s not AI-native, and you should know which one you’re paying for.&lt;/p&gt;

&lt;h2&gt;
  
  
  Our Take: Agent-First, Human-in-the-Loop, Built at VectovateAI
&lt;/h2&gt;

&lt;p&gt;Most AI-native conversations happen at the platform level: pricing tiers, SaaS dashboards, no-code app builders. We come at this from a different angle. As an Ahmedabad-based software engineering team, our focus is agent-first custom development, where AI agents handle the repeatable work and a human always reviews the outcomes that matter.&lt;/p&gt;

&lt;p&gt;That combination, agent-first execution paired with human-in-the-loop governance, is what separates AI-native systems that actually hold up in production from demos that look good in a pitch meeting. We build the data layer and the agent layer together, from the first sprint, not as a phase-two upgrade.&lt;/p&gt;

&lt;p&gt;That approach is documented in our &lt;a href="https://vectovateai.com/case-studies/travel-hospitality-aggregator-performance" rel="noopener noreferrer"&gt;AI-native architecture case study&lt;/a&gt;, where a global travel aggregator scaled to 80% efficiency. For the delivery side, see how &lt;a href="https://vectovateai.com/blogs/ai-powered-web-development-generative-engineering-2x-faster" rel="noopener noreferrer"&gt;AI-powered web development ships production software 2x faster&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Planning an AI-first build or replacing a bolted-on layer? &lt;a href="https://vectovateai.com/contact" rel="noopener noreferrer"&gt;&lt;strong&gt;Book a Free AI Architecture Review with VectovateAI&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://vectovateai.com/blogs/ai-native-software-development-why-bolted-on-ai-fails" rel="noopener noreferrer"&gt;VectovateAI blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>softwareengineering</category>
      <category>architecture</category>
      <category>machinelearning</category>
    </item>
  </channel>
</rss>
