← Back to work

LLM & Agents

Energy

BasinIQ

Ask questions across 8 AER directives and 200 wells. Hybrid retrieval with a cross encoder reranker grounds every answer in cited source passages.

BasinIQ screenshot

The problem

Energy companies live under the AER's directives, hundreds of pages of dense regulatory text. When an engineer needs to answer a compliance question, say the emergency planning requirements for a facility with H2S potential, they dig through PDFs by hand, and getting it wrong carries real regulatory cost. General purpose chatbots make this worse, because they answer confidently without saying where the answer came from.

What I built

  • Indexed 8 AER directives and a set of well records, then answered questions with hybrid retrieval: dense vector search with pgvector alongside keyword search, merged and then reranked by a cross encoder for precision.
  • Wired it into a Claude tool use loop with two tools, one that runs SQL over the well data and one that searches the documents, so the model picks the right source for each question.
  • Grounded every answer in cited source passages, so a user can check the directive text themselves instead of trusting the model.
  • Streamed responses over server sent events and kept session history server side for multi turn context.

The outcome

When Elasticsearch fell over in production, I found the cross encoder reranker was doing most of the work and vector only retrieval held its accuracy. The lesson stuck: for grounded answers, the reranker mattered more than the second index.

Stack

  • FastAPI
  • pgvector
  • Cross encoder
  • Claude tool use
  • Next.js