<?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: OrienSpec</title>
    <description>The latest articles on DEV Community by OrienSpec (@orienspec).</description>
    <link>https://dev.to/orienspec</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%2F4055326%2F7976a8b9-843e-4065-a5c6-f6ba829535ab.jpg</url>
      <title>DEV Community: OrienSpec</title>
      <link>https://dev.to/orienspec</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/orienspec"/>
    <language>en</language>
    <item>
      <title>The RAG Bug That Isn't an Error: Bad Retrieval</title>
      <dc:creator>OrienSpec</dc:creator>
      <pubDate>Thu, 30 Jul 2026 15:34:47 +0000</pubDate>
      <link>https://dev.to/orienspec/the-rag-bug-that-isnt-an-error-bad-retrieval-5f4</link>
      <guid>https://dev.to/orienspec/the-rag-bug-that-isnt-an-error-bad-retrieval-5f4</guid>
      <description>&lt;p&gt;Most broken RAG pipelines don't crash. They run fine and quietly feed the LLM the wrong context — so you get confident, slightly-wrong answers. The two fixes that catch most of it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add a relevance floor. Vector search always returns your top-k, even when nothing is actually relevant. Reject weak matches instead of feeding the model noise:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;results = store.similarity_search_with_score(query, k=5)&lt;/p&gt;

&lt;p&gt;relevant = [doc for doc, score in results if score &amp;gt;= 0.75]&lt;/p&gt;

&lt;p&gt;if not relevant:&lt;/p&gt;

&lt;p&gt;return "I couldn't find anything relevant." # better than hallucinating&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Rewrite the query before retrieving. Users ask messy questions. One cheap LLM call to clean it up sharpens the query vector a lot: python&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;search_query = llm.invoke(&lt;/p&gt;

&lt;p&gt;f"Rewrite as a clear, standalone search query. Return only the query.\n\n{user_question}"&lt;/p&gt;

&lt;p&gt;).content&lt;/p&gt;

&lt;p&gt;results = store.similarity_search(search_query, k=5)&lt;/p&gt;




&lt;p&gt;I build full stack and AI systems. My work is on GitHub: &lt;a href="https://github.com/OrienSpec" rel="noopener noreferrer"&gt;github.com/OrienSpec&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I build full stack and AI systems. My work is on GitHub: &lt;a href="https://github.com/OrienSpec" rel="noopener noreferrer"&gt;github.com/OrienSpec&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>python</category>
      <category>llm</category>
    </item>
  </channel>
</rss>
