HMRC Tax RAG Assistant

A retrieval-augmented Q&A system that answers UK tax questions grounded in official HMRC internal manuals — not an LLM's memory

Overview

"Tax rules are precise, change often, and are a poor fit for an LLM to answer from memory." This project scrapes five HMRC internal manuals — corporation tax, VAT, PAYE, capital gains, and capital allowances — from GOV.UK, indexes every section, and answers questions using only retrieved context.

The pipeline runs query → index search → top-k retrieval → prompt building → LLM response, with the model declining to answer if the manuals don't cover the question, and every response linking back to its exact GOV.UK source page.

Key Results

1,299
Indexed sections across five HMRC manuals
5
HMRC manuals scraped: corp tax, VAT, PAYE, capital gains, capital allowances
100%
Source-traceable — every answer links back to its GOV.UK page

Tech Stack & Skills Demonstrated

Retrieval-Augmented Generation

  • Query → Index Search → Top-k Retrieval → Prompt → Response
  • minsearch (in-memory) or sqlitesearch (persistent)

Domain-Grounded AI

  • Refuses to answer outside retrieved context
  • Avoids hallucinated tax advice by design

Data Pipeline

  • Automated scraping via GOV.UK Content & Search APIs
  • Modular scraping / indexing / agent-logic design

Explore the Code

Full pipeline detail and dataset are on GitHub.

GitHub ↗ Visual Write-up on Notion ↗ ← Back to Portfolio