Policy-Grounded Claim Decisions with RAG

Type
University project
Domain
Retail: returns and warranty
Client
Alternate
Team
Team of two
My role
RAG: policy ingestion, retrieval and the decision step
Date
January 2026

A retrieval-augmented decision step for a return and warranty system: it checks each claim against the written policy and sends unclear cases to a person.

  • Python
  • RAG
  • ChromaDB
  • LangChain
  • BAAI/bge-m3
  • Qwen2.5-7B
  • OpenAI-compatible API

Try it: click a stage, or trace a claim through all six

    The settings shown are the ones in the pipeline I built. Nothing here is a real claim or a real policy.

    Problem

    The task was to optimise a return and warranty system. An agent uploads photos of an item, and the question is whether the claim should be approved, denied or sent to a person, according to the company's written policy.

    Two things mattered. The decision had to follow the policy document, not a language model's memory of what such policies usually say, and uncertain cases had to go to a human instead of being guessed.

    What we built

    The system has three parts: a web app for agents, an API that orchestrates the checks, and models served from a separate GPU server. A vision model turns the photos into structured findings, and a second step decides the claim against the policy. That second step is the RAG service I built.

    The policy document is split into overlapping chunks, embedded with BAAI/bge-m3 and stored in a persistent Chroma vector store, which fills itself on first start-up if it is empty. For each claim I build one search query from the product type, the customer's description and the vision model's findings, so retrieval sees both what was claimed and what was seen.

    The three closest passages go to a Qwen2.5-7B model together with the claim and the findings. It answers in JSON with a decision, approved, denied or needs human inspection, plus its reasoning and a confidence score. The embedding and language models sit behind OpenAI-compatible endpoints, so either can be swapped without touching the pipeline, and changing a rule means editing the policy document rather than the code.

    My role

    We were a team of two. I was responsible for the RAG part: ingesting and chunking the policy document, embedding and storing it, retrieving the relevant passages for each claim, and the policy-grounded decision step.

    Result

    The RAG service is part of the claim flow end to end: a claim with photos goes in, and a decision with reasoning and a confidence score comes out, with unclear cases routed to human inspection.

    Chunking, in numbers

    Chunk size and overlap decide how the policy is cut up, and so what the model can see. Move the sliders to see an example document of 6,000 characters (illustrative) being split.

    chunks in the example
    context sent per claim (3 passages)

    Counts are approximate: the real splitter breaks on paragraph and line ends, so they differ slightly. Bigger chunks keep a rule together but send more text with every claim.

    What I'd do now

    • Show the evidence. The decision model already has a field for the policy excerpts it relied on, but the API returns only the decision, reasoning and confidence. Returning the cited passages would let an agent check any decision against the policy in seconds.
    • Measure retrieval before tuning it. Build a labelled set of claims, note which policy passages should be found for each, and check whether they land in the top 3. Chunk size, overlap and the number of passages should be tuned against that, not by feel.
    • Constrain the output. The JSON is currently cut out of the reply between its first and last brace. Schema-constrained generation with validation would remove that fragility, with an invalid reply falling back to human inspection.
    • Improve the retriever. Combine keyword and embedding search, and rerank the candidates, so exact policy terms are not lost in a purely semantic match.
    • Calibrate the confidence score. It is the model's own estimate. Comparing it with agents' final decisions would show whether it can be trusted for routing low-confidence claims to a person.

    Skills gained

    • RAG pipeline design: chunking, embeddings, a persistent vector store and top-k retrieval, from a raw policy document to a grounded answer
    • Grounding language models: building prompts and queries so that decisions follow retrieved policy text, with a safe route to a human
    • Structured LLM output: getting decisions, reasoning and confidence back as JSON that the rest of the system can use
    • Service integration: connecting embedding, language and vision models through OpenAI-compatible endpoints
    • Working with a client: building to a real company's policy and splitting a system across a team of two

    Contact

    Open to internships

    Looking for a data science or AI intern?

    I'm open to internships in machine learning, retrieval and language models, and robotics for February 2027. Email is the quickest way to reach me.