Skip to main content

FiftyFive Tech

Email Us sales@fiftyfivetech.io
Get in Touch
A woman in a checked blazer working on a laptop in a dim archive office with document binders and charts pinned to a board

Generative AI applications

One question box for PDFs and PostgreSQL: RAG plus NL2SQL routing

FiftyFive built an MVP that answers plain-language questions from PDFs or PostgreSQL, routing each query to a RAG or NL2SQL pipeline built on Gemini Pro.

Discuss your document and data search
Industry
Enterprise (cross-industry)
Region
Solution
Hybrid RAG and NL2SQL query system
Story

About the client

The client's teams worked across two disconnected systems. Knowledge lived in PDF documents; operational records lived in a PostgreSQL database. Answering a business question often meant searching documents in one place and querying data in another. The client engaged FiftyFive for a full-cycle build of one natural-language interface over both sources, on a fixed MVP timeline.

Challenge

How do you let people ask one question of documents and a database?

  • Two retrieval mechanics. Unstructured documents need semantic search; structured records need exact queries. Users should not have to know which applies.
  • Meaning, not keywords. Documents had to be chunked and embedded so relevant passages surface from large document sets.
  • Correct SQL. Plain-English questions had to become valid PostgreSQL that runs against the live schema and returns exact results.
  • Routing without agent memory. Each query had to be classified and sent to the right pipeline, without the stateful agent memory the original architecture assumed.
  • Cost and time. Every layer adds inference cost and latency, and the timeline ruled out a long build, without closing off a more advanced design later.
Solution

What FiftyFive built

FiftyFive covered system architecture, AI engineering, the RAG and NL2SQL pipelines, orchestration logic and backend integration. The central design decision was to replace the originally planned agentic architecture with modular function orchestration. That removed the agent memory layer and simplified the system, while keeping modules independent so agent capabilities can be added later.

How the solution works

  1. Query classification and routing

    • A thin orchestration layer uses prompt-engineered classification to decide whether each question needs document knowledge or database records, then calls the matching pipeline.
    • Routing is stateless: no conversation or agent memory is kept between queries.
  2. RAG pipeline for documents

    • PDF content is chunked and embedded with Vertex AI text-embedding-004.
    • Milvus stores and retrieves the semantic chunks.
    • Gemini Pro re-ranks the retrieved passages and writes the final answer.
  3. NL2SQL pipeline for records

    • Gemini Pro converts the question into a PostgreSQL query.
    • The query runs directly against the database, and results come back as a table with a plain-language explanation.
  4. Designed to extend

    • Because classification, retrieval and SQL generation are separate functions, each can be improved or replaced on its own, and an agent layer can be added on top later without rebuilding the core.

Technology stack

Vertex AI text-embedding-004Embeddings for document chunks
MilvusVector storage and semantic retrieval
Gemini ProRe-ranking and answer generation; natural language to SQL
PostgreSQLSource of structured operational records
Prompt-engineered classifierRouting questions between the two pipelines

What the solution enabled

Outcomes

Business transformation

2

Pipelines, RAG and NL2SQL, in one interface

Stateless

No agent memory between queries

Gemini Pro

Re-ranks passages and writes SQL

One interface, two sources

Natural-language questions answered from either PDF documents or PostgreSQL records.

A working RAG pipeline

Embedding, vector retrieval, re-ranking and generation over enterprise documents.

A working NL2SQL pipeline

Generated SQL executed against PostgreSQL, returned as tables with explanations.

A simpler architecture, on time

Stateless function orchestration in place of the planned agentic design, delivered within the client's MVP timeline.

FAQ

Technical questions

How do you route a natural-language question to either RAG or text-to-SQL?

In this MVP, FiftyFive Technologies placed a prompt-engineered classification step in front of two pipelines. The classifier decides whether a question needs document knowledge or database records, then calls the RAG pipeline (Vertex AI embeddings, Milvus, Gemini Pro) or the NL2SQL pipeline (Gemini Pro generating PostgreSQL). Routing is stateless, so no agent memory is required.

Why replace an agentic design with function orchestration for an MVP?

The original architecture assumed an agent with stateful memory. For a fixed MVP timeline, FiftyFive Technologies replaced it with independent functions called by a lightweight router. This removed the memory layer and reduced complexity, while keeping the modules separate so agent capabilities can be layered on later.

Discuss your document and database search challenge with FiftyFive's AI engineers.

Book a call

Project snapshot

Industry
Enterprise (cross-industry)
Services
System architecture, AI/ML engineering, RAG and NL2SQL development, data engineering, backend integration
Status
MVP delivered
Core technologies
Vertex AI text-embedding-004, Milvus, Gemini Pro, PostgreSQL