ARE: Aviation Regulation Explainer
Plain-language answers about US aviation regulations, grounded in eCFR text.
Problem
Title 14 is large and deeply nested, so finding the section that answers a question is slow. The app turns the official XML into searchable chunks tagged with their Part and Section, and answers only from retrieved regulation text, saying so plainly when the answer isn’t there.
Architecture
A one-time build indexes a dated Title 14 snapshot. Each question retrieves 10 chunks, Cohere keeps the best 5, and the model answers only from those.
- Streamlit appapp.py
Builds the database on first run, then a question box with expandable sources.
- eCFR ingestiondata_processing.py
Fetches Title 14 XML and walks Part → Section into documents.
- Retrieval chainrag_setup.py
Chroma retriever wrapped in a Cohere reranking compressor, answer and sources in parallel.
Key decisions
Chunks follow the regulation’s structure
The parser walks Part → Section and makes one document per heading or paragraph element, splitting only elements longer than 800 characters (75 overlap).
data_processing.py:46-119Hierarchy kept as metadata
Each chunk carries title, part and section numbers plus a hierarchy id like Title-14/Part-x/Section-y, which the UI shows for every source.
data_processing.py:92-111Two-stage retrieval
Chroma returns 10 candidates and Cohere rerank-v3.5 keeps the top 5 through a contextual compression retriever.
rag_setup.py:51-80Context-only prompt with a refusal
The prompt allows answers only from the retrieved context, returns a fixed “cannot be found” sentence otherwise, gives no legal advice, and runs at temperature 0.
rag_setup.py:83-101
In action

Run it
streamlit run app.py