LLMs Meet the FAR: A New Semantic Search API Cuts Hallucination Risk in Government Contracting
Share this article
The Hallucination Hazard in Gov‑Contracting
When a large language model (LLM) generates a legal citation that isn’t actually in the Federal Acquisition Regulation (FAR), the consequences can be dire. A wrong clause can invalidate an entire bid, trigger audits, and damage a company’s reputation. The new FAR‑RAG API tackles this problem head‑on by providing a semantic search layer that maps natural‑language queries to the exact FAR clauses that apply.
“LLMs will hallucinate legal citations. A wrong FAR clause = disqualification.” – Source: YCombinator discussion on the project.
How the API Works
The service is built on FastAPI and leverages sentence‑transformers (the all‑MiniLM‑L6‑v2 model) to pre‑vectorize every clause in FAR Part 52. The resulting 384‑dimensional embeddings are stored in a FAISS index, enabling sub‑millisecond similarity searches.
GET /search?query=“procurement of data centers”
HTTP/1.1 200 OK
Content-Type: application/json
{
"results": [
{
"clause": "52.204‑2 – Types of Contracting Methods",
"score": 0.92
},
{
"clause": "52.204‑3 – Types of Contracting Methods – Firm Fixed Price",
"score": 0.88
}
]
}
The API returns the most relevant clauses along with cosine similarity scores, so developers can weigh how closely the model’s suggestion matches the query.
Daily Auto‑Updates and OpenAPI Spec
The FAR text is refreshed daily from acquisition.gov, ensuring the index stays current with regulatory changes. An OpenAPI specification is available, making it straightforward to integrate the service into existing AI agents or chatbots.
Open Source and Community Feedback
All code lives on GitHub under the MIT license: https://github.com/blueskylineassets/far-rag-api. The project is open to pull requests and community feedback, encouraging collaboration on improving embeddings, adding more FAR sections, or extending to other procurement documents.
Why It Matters for Developers
- Risk Mitigation: By grounding LLM outputs in verified legal text, the API reduces the risk of disqualifying hallucinations.
- Developer Efficiency: The semantic search layer removes the need to manually parse and index FAR clauses.
- Compliance Assurance: Automated daily updates keep the search results aligned with the latest regulations.
Getting Started
The API is free to try via the interactive honeypot demo: https://blueskylineassets.github.io/far-rag-api/honeypot/. For production use, subscribe on RapidAPI: https://rapidapi.com/yschang/api/far-rag-federal-acquisition.
“All data is public domain (17 U.S.C. § 105).” – Repository README.
By marrying semantic search with the FAR’s public‑domain text, this tool gives developers a reliable safety net when building AI for government contracting. Instead of guessing or trusting the model’s hallucinations, they can now let the system point to the exact clause that applies—saving time, money, and, most importantly, the chance of a disqualification.