<?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: Rakshit Sharma</title>
    <description>The latest articles on DEV Community by Rakshit Sharma (@rakshitsharma0402).</description>
    <link>https://dev.to/rakshitsharma0402</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%2F503507%2F7800e88d-d1d7-4418-86f6-f7b413fde297.png</url>
      <title>DEV Community: Rakshit Sharma</title>
      <link>https://dev.to/rakshitsharma0402</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rakshitsharma0402"/>
    <language>en</language>
    <item>
      <title>🚢 DemurrageDesk: Stop Hallucinating the Math - Building a Local RAG Assistant for Port Logistics</title>
      <dc:creator>Rakshit Sharma</dc:creator>
      <pubDate>Sun, 04 Oct 2026 16:51:36 +0000</pubDate>
      <link>https://dev.to/rakshitsharma0402/demurragedesk-stop-hallucinating-the-math-building-a-local-rag-assistant-for-port-logistics-46p0</link>
      <guid>https://dev.to/rakshitsharma0402/demurragedesk-stop-hallucinating-the-math-building-a-local-rag-assistant-for-port-logistics-46p0</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/hacktoberfest-weekend-2026-10-01"&gt;Hacktoberfest Weekend Challenge: Build for a Friend&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;DemurrageDesk&lt;/strong&gt; is a local RAG assistant for working with shipping line and terminal documents.&lt;/p&gt;

&lt;p&gt;I built it around a problem I could easily imagine a friend working in logistics dealing with: finding demurrage and detention rules buried inside long tariff PDFs.&lt;/p&gt;

&lt;p&gt;These documents can contain rules such as:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;7 free days, days 8–14 at one rate, and day 15 onward at a higher rate.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Finding the right rule is only half the problem. The more dangerous part is applying the wrong container size, mixing up import and export terms, missing a tier boundary, or simply letting an LLM do the arithmetic.&lt;/p&gt;

&lt;p&gt;DemurrageDesk is designed around the assumption that the model &lt;strong&gt;can be wrong&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You ask a question in plain English, the system retrieves the relevant document sections, and the answer includes the source file, page number, and the exact sentence used as evidence.&lt;/p&gt;

&lt;p&gt;Then, when a charge needs to be estimated, the model extracts the relevant rules into structured data — but &lt;strong&gt;Python performs the actual calculation&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The goal isn't to make the LLM magically reliable.&lt;/p&gt;

&lt;p&gt;The goal is to build a system that checks it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;🎥 &lt;strong&gt;Watch the DemurrageDesk demo&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The video shows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Asking a question about a shipping tariff&lt;/li&gt;
&lt;li&gt;Retrieving the relevant source and page&lt;/li&gt;
&lt;li&gt;Verifying the citation&lt;/li&gt;
&lt;li&gt;Extracting the demurrage rate tiers&lt;/li&gt;
&lt;li&gt;Calculating the final charge deterministically with Python&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/0rzp8J_cE7c" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/rakshitsharma0402" rel="noopener noreferrer"&gt;
        rakshitsharma0402
      &lt;/a&gt; / &lt;a href="https://github.com/rakshitsharma0402/DemurrageDesk" rel="noopener noreferrer"&gt;
        DemurrageDesk
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;🚢 DemurrageDesk: Port Terms Assistant&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;DemurrageDesk is a professional-grade, local RAG (Retrieval-Augmented Generation) assistant designed to parse complex port and shipping terminal documents. It allows users to query free-time rules, demurrage rates, and procedures, providing strictly cited answers and deterministic charge calculations.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Everything runs locally.&lt;/strong&gt; Your documents never leave your machine.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;✨ Key Features&lt;/h2&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Strict Citations&lt;/strong&gt;: The assistant provides direct quotes from documents. A verification layer ensures that the AI didn't hallucinate the quote.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deterministic Calculator&lt;/strong&gt;: Instead of letting the LLM do math (which is error-prone), the AI extracts the rules into a structured format, and a pure-Python engine calculates the final charges.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Provider Filtering&lt;/strong&gt;: Organize documents by shipping line or terminal; filter queries using the sidebar to avoid cross-provider confusion.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Privacy First&lt;/strong&gt;: Built with Ollama, ChromaDB, and Streamlit for a 100% local execution environment.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;🛠️ Tech Stack&lt;/h2&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;LLM&lt;/strong&gt;: Gemma (via Ollama)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Embeddings&lt;/strong&gt;: nomic-embed-text…&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/rakshitsharma0402/DemurrageDesk" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;The repository contains the complete implementation along with the calculator tests and setup instructions.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I Built It
&lt;/h2&gt;

&lt;p&gt;I wanted the entire pipeline to run locally because shipping tariffs, contracts, and terminal documents can contain sensitive commercial information.&lt;/p&gt;

&lt;p&gt;The stack is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Gemma 3&lt;/strong&gt; through Ollama for local generation&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;nomic-embed-text&lt;/strong&gt; through Ollama for embeddings&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ChromaDB&lt;/strong&gt; for local vector search&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PyMuPDF&lt;/strong&gt; for PDF text extraction&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pydantic&lt;/strong&gt; for structured model output&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Streamlit&lt;/strong&gt; for the interface&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Plain Python&lt;/strong&gt; for the actual demurrage calculation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The application stores the provider/terminal as metadata during ingestion, which allows the UI to filter retrieval by shipping line or terminal rather than mixing documents from different providers.&lt;/p&gt;

&lt;h3&gt;
  
  
  The important part: evidence before answers
&lt;/h3&gt;

&lt;p&gt;The RAG pipeline doesn't simply ask the model for an answer.&lt;/p&gt;

&lt;p&gt;The response schema requires citations containing a source, page number, and a complete sentence copied from the retrieved text. The application then normalizes the citation and checks whether that quoted sentence actually exists in the retrieved document chunk. Only verified citations count toward &lt;code&gt;found=True&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;That means the model cannot simply invent a convincing-looking citation and have the application accept it.&lt;/p&gt;

&lt;p&gt;The system prompt also explicitly tells the model to respect container size, import/export direction, and the applicable shipping line or terminal — and not to perform the charge calculation itself.&lt;/p&gt;

&lt;h3&gt;
  
  
  The LLM extracts the rule. Python does the math.
&lt;/h3&gt;

&lt;p&gt;For a charge calculation, the model extracts structured information such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;free days&lt;/li&gt;
&lt;li&gt;starting day of each tier&lt;/li&gt;
&lt;li&gt;ending day of each tier&lt;/li&gt;
&lt;li&gt;rate&lt;/li&gt;
&lt;li&gt;currency&lt;/li&gt;
&lt;li&gt;notes about the rule&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The result is represented as a structured &lt;code&gt;Rule&lt;/code&gt;/&lt;code&gt;Tier&lt;/code&gt; model rather than free-form text.&lt;/p&gt;

&lt;p&gt;The actual calculation is deliberately kept outside the LLM.&lt;/p&gt;

&lt;p&gt;The Python calculator resolves open-ended tiers automatically. For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Days 1–7: free&lt;/li&gt;
&lt;li&gt;Days 8–14: $40/day&lt;/li&gt;
&lt;li&gt;Day 15 onward: $80/day&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The calculator converts the open-ended first tier into days 8–14 and then calculates each applicable day deterministically. &lt;/p&gt;

&lt;p&gt;This gives me a much clearer failure boundary:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LLM:&lt;/strong&gt; retrieve and interpret the document.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python:&lt;/strong&gt; perform arithmetic.&lt;/p&gt;

&lt;h3&gt;
  
  
  I also tested the failure cases
&lt;/h3&gt;

&lt;p&gt;One of the useful things about building this was discovering that a seemingly correct RAG application can still produce a dangerously wrong number.&lt;/p&gt;

&lt;p&gt;The calculator tests include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;days inside free time → &lt;code&gt;$0&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;days 8–10 at &lt;code&gt;$40/day&lt;/code&gt; → &lt;code&gt;$120&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;crossing into the second tier at day 16&lt;/li&gt;
&lt;li&gt;open-ended tiers&lt;/li&gt;
&lt;li&gt;tiers supplied in reverse order&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, the test suite explicitly checks that 10 days held with 7 free days produces &lt;code&gt;$120&lt;/code&gt;, and that 16 days correctly crosses into the &lt;code&gt;$80&lt;/code&gt; tier.&lt;/p&gt;

&lt;p&gt;The Streamlit UI also lets the user inspect and edit the extracted free days and rate tiers before the final calculation, rather than hiding the intermediate rule.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Does Open Innovation Matter?
&lt;/h2&gt;

&lt;p&gt;This project is a good example of where local and open AI can be more useful than simply calling a hosted API.&lt;/p&gt;

&lt;p&gt;Shipping tariffs and contracts can be commercially sensitive. Sending those documents to a third-party AI service may not be acceptable in some workflows.&lt;/p&gt;

&lt;p&gt;With DemurrageDesk, the generation model, embedding model, vector database, document parsing, retrieval, and calculation all run locally.&lt;/p&gt;

&lt;p&gt;The models can be pulled through Ollama, and the application uses ChromaDB as its local vector store. &lt;/p&gt;

&lt;p&gt;More importantly, open/local AI gave me control over the &lt;strong&gt;entire reliability layer&lt;/strong&gt; around the model.&lt;/p&gt;

&lt;p&gt;I could decide:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;what evidence the model must provide&lt;/li&gt;
&lt;li&gt;how citations are verified&lt;/li&gt;
&lt;li&gt;when an answer is considered “found”&lt;/li&gt;
&lt;li&gt;what information gets converted into structured rules&lt;/li&gt;
&lt;li&gt;and exactly how the final charge is calculated&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I don't have to trust the model to do everything correctly.&lt;/p&gt;

&lt;p&gt;I can put deterministic software around the parts where deterministic software is better.&lt;/p&gt;

&lt;p&gt;That's the part of open innovation I found most interesting: &lt;strong&gt;the model doesn't have to be perfect if the system around it is designed to catch its mistakes.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Limitations
&lt;/h2&gt;

&lt;p&gt;This is intentionally a focused prototype rather than a billing authority.&lt;/p&gt;

&lt;p&gt;There are still important limitations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PDF tables can extract poorly.&lt;/li&gt;
&lt;li&gt;Scanned PDFs require OCR preprocessing.&lt;/li&gt;
&lt;li&gt;Small local models can still misunderstand complex language.&lt;/li&gt;
&lt;li&gt;Calendar-day vs. working-day rules require human confirmation.&lt;/li&gt;
&lt;li&gt;The extracted rule should be reviewed before acting on a calculated charge.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The README therefore explicitly treats human verification as part of the workflow.&lt;/p&gt;

&lt;p&gt;The next step would be to put DemurrageDesk in front of someone who actually works with shipping tariffs every day and see which failure cases I haven't anticipated yet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prize Categories
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Best Use of Gemma&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Most Helpful Tool for a Friend&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devchallenge</category>
      <category>weekendchallenge</category>
      <category>hf26challenge</category>
      <category>gemmachallenge</category>
    </item>
    <item>
      <title>Hacktoberfest 2021</title>
      <dc:creator>Rakshit Sharma</dc:creator>
      <pubDate>Tue, 26 Oct 2021 16:45:17 +0000</pubDate>
      <link>https://dev.to/rakshitsharma0402/hacktoberfest-2021-3k9n</link>
      <guid>https://dev.to/rakshitsharma0402/hacktoberfest-2021-3k9n</guid>
      <description>&lt;p&gt;✨Completed my 4 PR's, but this year I learned how to use Github Desktop.✨&lt;/p&gt;

</description>
      <category>hacktoberfest</category>
      <category>opensource</category>
      <category>github</category>
      <category>devops</category>
    </item>
    <item>
      <title>My First Hacktoberfest...</title>
      <dc:creator>Rakshit Sharma</dc:creator>
      <pubDate>Sun, 01 Nov 2020 06:41:48 +0000</pubDate>
      <link>https://dev.to/rakshitsharma0402/my-first-hacktoberfest-2n4g</link>
      <guid>https://dev.to/rakshitsharma0402/my-first-hacktoberfest-2n4g</guid>
      <description>&lt;p&gt;✨My First Hacktoberfest...✨&lt;/p&gt;

&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;This was my first Hacktoberfest and I thoroughly enjoyed it. I exchanged 4 pull requests as per the guidelines and learned how to use GitHub. &lt;/p&gt;

&lt;h3&gt;
  
  
  Background
&lt;/h3&gt;

&lt;p&gt;The idea and inspiration were given by my elder sister who is a software engineer and has been associated with the fest for the past 3 years. I have been taught by her how to proceed with the fest and what all has to be done.&lt;/p&gt;

&lt;h3&gt;
  
  
  Progress
&lt;/h3&gt;

&lt;p&gt;I am a beginner. I like the way GitHub has helped me to get my self introduced to various open-source code over the platform I wish to explore it more and would continue contributing to it.  &lt;/p&gt;

&lt;h3&gt;
  
  
  Contributions
&lt;/h3&gt;

&lt;p&gt;I made a beginner project on CALCULATOR. I initially added square root, factorial, cube root, power functions, and send pull requests for the same. Therefore, I completed 4 pull request successfully.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reflections
&lt;/h3&gt;

&lt;p&gt;Overall, I enjoyed the Hacktoberfest 2020, it was really nice working with the open-source for the first time. I will surely participate again in the coming years. I have learned how to use GitHub successfully and also how to work with open-source. Yes, I have made a few connections while working with the project CALCULATOR @riya-17 @divyagupta-98 @Vyvy-vi. I am looking forward to building some new projects and contribute to Github and take help from GitHub for my upcoming project completion.&lt;/p&gt;

</description>
      <category>hacktoberfest</category>
    </item>
  </channel>
</rss>
