Downloads · 30 days
0
ryanadoremos/government-procurement-rag-assistant
government-procurement-rag-assistant is a machine learning model from ryanadoremos. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
A Retrieval-Augmented Generation (RAG) system that answers questions about U.S. federal procurement opportunities using semantic search and a Large Language Model (LLM).
Downloads · 30 days
0
Access
Public
Updated Aug 5, 2026
Repo size
1.9 MB
Likes
0
Public
Click a slice to open those files.
.pdf1.9 MB · 90%
From the Hugging Face model README
A Retrieval-Augmented Generation (RAG) system that answers questions about U.S. federal procurement opportunities using semantic search and a Large Language Model (LLM).
Government procurement opportunities contain lengthy descriptions, technical terminology, and agency-specific language that can make locating relevant information difficult. Traditional keyword search often returns unrelated results, while large language models (LLMs) alone may hallucinate information that is not present in the underlying data.
This project develops a Retrieval-Augmented Generation (RAG) assistant that combines semantic retrieval with a large language model to produce grounded responses using publicly available procurement data from the USAspending.gov API.
Instead of relying solely on an LLM's internal knowledge, the assistant retrieves the most relevant procurement records first and then generates answers based only on those retrieved documents.
The project consists of four major components:
The complete pipeline minimizes hallucinations by ensuring responses are based on retrieved procurement records rather than model memorization.
The knowledge base is built from publicly available procurement records collected through the USAspending.gov API.
Each procurement record contains information including:
Each record is:
The final corpus contains approximately 100 procurement opportunities collected between January 2024 and December 2025.
The Government Procurement RAG Assistant follows a Retrieval-Augmented Generation (RAG) workflow that combines semantic search with a Large Language Model (LLM) to answer questions about federal procurement opportunities. Rather than relying solely on the language model's internal knowledge, the system first retrieves the most relevant procurement records and then uses those records as context for response generation. This retrieval-first approach helps reduce hallucinations and ensures that generated answers remain grounded in publicly available procurement data. The complete pipeline consists of data collection, document preprocessing, semantic embedding, vector indexing, retrieval, prompt construction, and response generation. Each stage was designed to improve the accuracy, relevance, and transparency of the final responses while maintaining an efficient workflow suitable for real-world applications. The following sections describe each stage of the pipeline in greater detail, from collecting procurement records through generating grounded responses using the Qwen2.5 language model.
Relevant fields include:
Each procurement record is converted into a structured retrieval document.
Text cleaning includes:
Each document becomes one searchable chunk stored inside
government_procurement_chunks.csv
Semantic embeddings are generated using:
sentence-transformers/all-MiniLM-L6-v2
Embeddings are indexed using Facebook AI Similarity Search (FAISS).
For every user question:
Retrieved procurement records are inserted into the prompt provided to
Qwen/Qwen2.5-3B-Instruct
The model is instructed to:
User Question
│
▼
Sentence Transformer
│
▼
Query Embedding
│
▼
FAISS Vector Search
│
▼
Top 3 Procurement Documents
│
▼
Prompt Construction
│
▼
Qwen2.5-3B-Instruct
│
▼
Grounded Response
The RAG system was evaluated using multiple procurement-related benchmark questions.
Example evaluation questions include:
Evaluation focused on:
The evaluation demonstrated that retrieval substantially improved response quality by grounding generated answers in procurement records.
from rag_pipeline import GovernmentProcurementRAGAssistant
assistant = GovernmentProcurementRAGAssistant(
chunks_path="government_procurement_chunks.csv"
)
response, sources = assistant.answer(
"Which federal agency awarded the largest healthcare contract?"
)
print(response)
print(sources)
government-procurement-rag-assistant/
│
├── README.md
├── rag_pipeline.py
├── example_usage.py
├── requirements.txt
├── Adoremos_Ryan_Final.ipynb
├── government_procurement_chunks.csv
│
├── results/
│ ├── pre_rag_eval_results.csv
│ ├── post_rag_eval_results.csv
│ ├── pre_post_rag_comparison.csv
│ ├── comparison_model_detailed_results.csv
│ ├── comparison_model_benchmark_summary.csv
│ └── final_huggingface_model_comparison.csv
│
└── data/
The Government Procurement RAG Assistant follows a Retrieval-Augmented Generation (RAG) prompting strategy in which the user's question is combined with the most relevant procurement records before being sent to the language model. Instead of allowing the model to answer from its pre-trained knowledge alone, the prompt includes procurement information retrieved through semantic search, providing factual context for response generation.
Each prompt contains:
A simplified prompt structure is shown below:
Question: <user question>
Retrieved Procurement Context: <Document 1>
<Document 2>
<Document 3>
Instructions: • Answer only using the retrieved procurement information. • Do not invent procurement records or regulations. • Clearly state when additional information is required.
The assistant produces structured responses designed to clearly separate factual procurement information from explanatory text. This formatting improves readability while ensuring that responses remain grounded in the retrieved procurement records.
Each generated response follows the structure below:
Direct Answer
Supporting Procurement Evidence
Important Considerations
Additional Context
Insufficient Information (when applicable)
This structured output format promotes transparency, improves interpretability, and helps reduce hallucinations by ensuring that generated responses remain closely aligned with the retrieved procurement records.
While the current system demonstrates that Retrieval-Augmented Generation (RAG) can effectively answer questions about U.S. federal procurement data, several enhancements could further improve both retrieval quality and the overall user experience.
The current knowledge base contains approximately 100 procurement opportunities collected from USAspending.gov. Expanding the corpus to include thousands of procurement records across multiple years and agencies would improve retrieval coverage and allow the assistant to answer a broader range of procurement-related questions with greater accuracy.
The current implementation relies solely on semantic embeddings generated by Sentence Transformers. Future work could combine traditional keyword search (BM25) with semantic retrieval to better capture both exact keyword matches and contextual meaning. Hybrid retrieval is widely used in modern production RAG systems because it often improves retrieval precision for specialized terminology and government-specific language.
Procurement records contain valuable structured metadata such as awarding agency, recipient organization, award amount, award year, contract type, and industry classification. Allowing users to filter retrieval by these fields would significantly narrow the search space and produce more targeted responses for complex procurement queries.
After FAISS retrieves the most similar procurement documents, a cross-encoder reranking model could be applied to reorder the retrieved results based on a deeper understanding of the relationship between the user query and each document. This additional ranking stage has the potential to improve retrieval accuracy, especially for ambiguous or highly detailed procurement questions.
Future versions of the assistant could include explicit citations to the retrieved procurement records used during response generation. Displaying Award IDs, recipient names, agencies, and links to the original procurement records would improve transparency, increase user trust, and make it easier to verify generated responses.
The project could be deployed as an interactive web application using Gradio or Hugging Face Spaces. A web interface would allow users to submit procurement questions, view the retrieved procurement documents alongside generated responses, and explore the retrieval process without requiring programming knowledge.
Government procurement information changes frequently as new awards are published. A future enhancement would automate data collection from the USAspending.gov API on a scheduled basis so that the knowledge base remains current without requiring manual updates. This would enable the assistant to answer questions using more recent procurement information.
Additional retrieval improvements could include query expansion, document chunk optimization, adaptive chunk sizing, and multi-query retrieval. These techniques may improve retrieval robustness by capturing procurement information expressed using different terminology while reducing the likelihood of missing relevant documents.
Core libraries used in this project include:
torch
transformers
sentence-transformers
faiss-cpu
numpy
pandas
scikit-learn
requests
accelerate
Install dependencies using:
pip install -r requirements.txt
Lewis, P., Perez, E., Piktus, A., Petroni, F., Karpukhin, V., Goyal, N., et al. (2020). Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks. https://arxiv.org/abs/2005.11401
Qwen Team. (2024). Qwen2.5 Technical Report. https://arxiv.org/abs/2412.15115
Wolf, T., Debut, L., Sanh, V., et al. (2020). Transformers: State-of-the-Art Natural Language Processing. https://arxiv.org/abs/1910.03771
Reimers, N., & Gurevych, I. (2019). Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks. https://arxiv.org/abs/1908.10084
Johnson, J., Douze, M., & Jégou, H. (2017). Billion-Scale Similarity Search with GPUs (FAISS). https://arxiv.org/abs/1702.08734
USAspending.gov. https://www.usaspending.gov/
USAspending API Documentation. https://api.usaspending.gov/docs/
Federal Spending Guide. https://www.usaspending.gov/federal-spending-guide
Hugging Face Transformers Documentation. https://huggingface.co/docs/transformers
Sentence Transformers Documentation. https://www.sbert.net/
FAISS Documentation. https://faiss.ai/
Hugging Face Model Hub. https://huggingface.co/
Ryan Adoremos
University of Virginia
MS Data Science
DS 5002 — Final Project
Summer 2026