Building Production LLM Pipelines for Insurance Risk Assessment and Document Processing

vouch · Insurance · year n/a · source Agentic: no · promotional bias: low · source-backed · extracted with prompt 0.5.5 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Insurance underwriting risk classification and document AI pipelines

Vouch needed production LLM pipelines that could classify underwriting risk, extract useful information from insurance documents and web sources, serve predictions to product engineers, report prediction quality back to the warehouse, and control LLM cost and development friction in a modern data-stack environment.

Constraints:

Architecture

Vouch built Metaflow-centered LLM pipelines on AWS Batch. DBT prepares data, Metaflow orchestrates transformations and LLM calls through LangChain/OpenAI, post-processing steps repair or enforce structure when output parsers fail, predictions are written to PostgreSQL, a FastAPI service exposes them, a custom SDK lets product engineers retrieve predictions with a few lines of code, and reverse ETL sends predictions back into Snowflake for reporting. AWS Cognito secures the ALB-level sign-in flow, Docker Compose gives pipeline developers a local service stack, hourly risk-classification jobs poll for new work, and document AI jobs run when documents hit services.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  insurance-data-sources[Insurance data sources] --> dbt-transformations[DBT transformations]
  dbt-transformations --> metaflow-pipelines[Metaflow pipelines]
  metaflow-pipelines --> langchain-openai-calls[LangChain OpenAI calls]
  prediction-cache[Prediction cache] --> langchain-openai-calls
  langchain-openai-calls --> post-processing-steps[Post-processing steps]
  post-processing-steps --> postgresql-predictions[PostgreSQL predictions]
  postgresql-predictions --> fastapi-service[FastAPI service]
  fastapi-service --> product-sdk[Product SDK]
  product-sdk --> product-applications[Product applications]
  postgresql-predictions --> snowflake-reporting[Snowflake reporting]
  metaflow-pipelines --> aws-batch-runtime[AWS Batch runtime]
  aws-batch-runtime --> aws-cognito-alb-authentication[AWS Cognito ALB authentication]
  docker-compose-dev-stack[Docker Compose dev stack] --> metaflow-pipelines
  docker-compose-dev-stack --> fastapi-service
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Insurance data sources Structured, semi-structured, numeric, text, and document data used for underwriting risk and document AI. DBT transformations
DBT transformations Prepare data before LLM prediction workflows run. Metaflow pipelines
Metaflow pipelines Orchestrate data preparation, LLM calls, post-processing, prediction writes, and scheduled or triggered execution. LangChain OpenAI calls, Post-processing steps, AWS Batch runtime
LangChain OpenAI calls LLM integration layer used to call OpenAI APIs from the pipelines. Post-processing steps, Prediction cache
Prediction cache Checks whether an existing prediction already exists before paying for another LLM call. LangChain OpenAI calls
Post-processing steps Repair or enforce structure after LLM responses when parsers fail or do not fully work as expected. PostgreSQL predictions
PostgreSQL predictions Operational database where final prediction records are written. FastAPI service, Snowflake reporting
FastAPI service Serving layer placed in front of Metaflow so product systems can access predictions. Product SDK
Product SDK Developer-facing package that lets product engineers retrieve predictions with a few lines of code. Product applications
Product applications Downstream product code that consumes underwriting and document-AI predictions. —
Snowflake reporting Warehouse destination for reverse-ETL'd predictions and reporting on prediction quality. —
AWS Batch runtime Metaflow execution environment based on an extended AWS Batch Terraform template. AWS Cognito ALB authentication
AWS Cognito ALB authentication Authentication extension that lets Vouch users sign in through Gmail at the ALB level. —
Docker Compose dev stack Local development stack that runs pipelines, API, and databases in containers across developer machines. Metaflow pipelines, FastAPI service

Data flow

Metaflow starts by preparing data transformations that are run through DBT. Prepared data is sent to LLM providers through LangChain, initially OpenAI, to generate risk or document predictions. Returned LLM outputs pass through Metaflow post-processing to enforce transformations when parsers fail. Final predictions are written to PostgreSQL, served through FastAPI, retrieved by product engineers through a custom SDK, and reverse-ETL'd into Snowflake for reporting on prediction quality. Risk pipelines run hourly and check for new data; document AI pipelines trigger as needed when documents arrive.

6 supporting quotes
“we start by using metaflow to prepare our data data Transformations that are run in DBT uh with metaflow and then once we've got that data prepared we send it out um not exclusively to open AI but that was the first like many folks that was like the first”transcript, stated
“once we've got that data prepared we send it out um not exclusively to open AI but that was the first like many folks that was like the first thing we tried”transcript, stated
“when the llm S something back it often still needs a fair bit of work so then we use the metap pipelines to do those additional transformations”transcript, stated
“we write those predi itions to the database um so we put in front of metaflow a uh fast API instance that allows us to serve those predictions”transcript, stated
“we also wrote an SDK to make it really easy for our product Engineers to integrate and to like retrieve those predictions with a couple lines of code”transcript, stated
“those predictions you can see also get um reverse ETL back into the data warehouse to make it easier for us to report on how well they're working”transcript, stated

Why this architecture

The architecture matches Vouch's modern data stack and product-integration needs: Metaflow fits the pipeline orchestration layer, DBT and Snowflake fit existing analytics workflows, FastAPI and the SDK expose predictions to engineers, and AWS Batch gave a fast production path. The team also wrapped LLM calls with post-processing and caching because raw LLM outputs and repeated calls are not production-safe enough on their own.

5 supporting quotes
“our stack we're a modern data stack company um so you'll see a lot of The Usual Suspects DBT snowflake um postgress dat bases”transcript, stated
“we really enjoy and felt like the AWS batch terraform template was really great for getting us up and running and into production like nothing beats that”transcript, stated
“when the output parsers fail or don't work entirely as expected we enforce those Transformations and then we write those predi itions to the database um so we put in front of metaflow a uh fast API instance that allows us to serve those predictions that we”transcript, stated
“all those calls are are expensive so trying to manage the amount of work the llm needs to do got it okay and there's like token management steps but I bet uh I bet that Eddie has all that in his content as well a little bit um sh did you have another”transcript, stated
“to serve those predictions that we have um and then we also wrote an SDK to make it really easy for our product Engineers to integrate and to like retrieve those predictions with a couple lines of code um and then those predictions you can see also get um reverse ETL back into the data warehouse”transcript, stated

Models used: Metaflow · AWS Batch · DBT · LangChain · OpenAI APIs · FastAPI · PostgreSQL · Snowflake · AWS Cognito · Docker Compose · Kubernetes

Scale

Alternatives considered (roads not taken)

Polling-style hourly Metaflow pipelines

Rejected because: The team says the current hourly cadence works, but as the project matures they probably need event-driven pipelines.

“they only run every hour and typically the amount of data we have does not overwhelm the pipeline at that Cadence”transcript, stated
“and into production like nothing beats that I think as our project matures we realize that what we probably need is event driven um pipeline so I know there is an example but it' be nice to have like a comprehensive example because when you read read it it says oh here's an example but we're missing”transcript, stated

Relying on raw LLM parser output

Rejected because: The team found LLM responses often need work, so they use Metaflow transformations to enforce expected structure when parsers fail.

“on that data and then we return those predictions and uh like many of you are familiar with when the llm S something back it often still needs a fair bit of work so then we use the metap pipelines to do those additional transformations to enforce our um when the output parsers fail”transcript, stated
“when the output parsers fail or don't work entirely as expected we enforce those Transformations and then we write those predi itions to the database um so we put in front of metaflow a uh fast API instance that allows us to serve those predictions that we”transcript, stated

Let every consumer run the full LLM project locally

Rejected because: SDK users point at the dev instance instead of running pipelines, API, and databases locally.

“if you are an SDK user and Sean was one of our uh really uh flexible guinea pigs one of our early SDK users um that is you don't necessarily have to run the project um because SDK points at the dev instance and so uh you should only have to use the SDK so”transcript, stated
“that is you don't necessarily have to run the project um because SDK points at the dev instance and so uh you should only have to use the SDK so you bring it in as a package and then um just drop it your code I don't know nice is there anything SDK users”transcript, stated

Native local installs across many developer machines

Rejected because: Mac/architecture differences caused enough friction that the team containerized Metaflow for local development.

“issues with Mac AMD we eventually came to um putting metlow inside a container just to try to insulate our cells from those problems”transcript, stated

Patterns

batch-offline-processing (execution)

Risk classification runs as scheduled Metaflow pipelines that check hourly for new data to process.

“for our risk classification use cases we can run those pipelines every hour and it checks to see if there's anything new”transcript, stated

structured-output-contract (reliability)

The pipeline treats LLM responses as intermediate outputs that must be transformed into the expected prediction structure before being written and served.

“when the output parsers fail or don't work entirely as expected we enforce those Transformations”transcript, stated
“enforce our um when the output parsers fail or don't work entirely as expected we enforce those Transformations and then we write those predi itions to the database um so we put in front of metaflow a uh fast API instance that allows us to serve those predictions that we have um and then we also”transcript, stated

semantic-caching (cost-control)

Before making an LLM call, the system checks whether it already has a prediction, reducing duplicate work and spend.

“I check and see if I already have a prediction to try and really narrow down the amount of work”transcript, stated

cost-aware-routing (operations)

The team controls LLM spend by caching predictions, narrowing the amount of work, and managing tokens on LLM steps.

“all those calls are are expensive so trying to manage the amount of work the llm needs to do”transcript, stated
“all those calls are are expensive so trying to manage the amount of work the llm needs to do got it okay and there's like token management steps but I bet uh I bet that Eddie has all that in his content as well a little bit um sh did you have another question no no go ahead go ahead I don't”transcript, stated

observability-tracing (quality-monitoring)

Predictions are reverse-ETL'd back into the warehouse so the team can report on how well the LLM predictions are working.

“reverse ETL back into the data warehouse to make it easier for us to report on how well they're working”transcript, stated

guardrails-io-filtering (output-repair)

Post-processing steps act as an output guardrail by enforcing transformations after parser failures instead of trusting raw LLM responses.

“when the output parsers fail or don't work entirely as expected we enforce those Transformations”transcript, stated

Tradeoffs

Use AWS Batch Metaflow infrastructure first

Chose Extending the AWS Batch Terraform template over Building a bespoke production workflow platform.

Rationale: The template got the team into production quickly, and the team extended it with Cognito/ALB authentication rather than replacing the foundation.

“we started with the batch terraform template and we made some extensions”transcript, stated
“really great for getting us up and running and into production like nothing beats that”transcript, stated

Serve predictions through FastAPI and an SDK

Chose A prediction service plus SDK abstraction over Requiring product engineers to know the pipeline internals.

Rationale: The SDK lets product engineers retrieve predictions with a couple lines of code while hiding Metaflow and database complexity.

“we put in front of metaflow a uh fast API instance that allows us to serve those predictions”transcript, stated
“wrote an SDK to make it really easy for our product Engineers to integrate and to like retrieve those predictions with a couple lines of code”transcript, stated

Run risk predictions hourly

Chose Hourly polling/checking for new work over Immediate event-driven processing for risk classification.

Rationale: Hourly execution fits the current business volume, but the team recognizes event-driven pipelines may be better as the system matures.

“they only run every hour and typically the amount of data we have does not overwhelm the pipeline at that Cadence”transcript, stated
“us up and running and into production like nothing beats that I think as our project matures we realize that what we probably need is event driven um pipeline so I know there is an example but it' be nice to have like a comprehensive example because when you read read it it says oh here's an”transcript, stated

Containerize local development

Chose Docker Compose running the pipeline, API, and databases over Each developer configuring a native local stack.

Rationale: The team accepted some container quirks to insulate developers from platform-specific Mac/CPU issues.

“putting metlow inside a container just to try to insulate our cells from those problems um but it's not without its quirks”transcript, stated
“Docker compos build Docker comose up and it spins up the entire service so the pipeline the API um so you have everything running the databases”transcript, stated

Gotchas (what bit them)

LLM responses are not reliably ready to write directly to production stores.

Root cause: Output parsers can fail or not entirely work as expected, leaving responses that still need transformation.

Resolution: Run additional Metaflow post-processing transformations before writing predictions to the database.

“when the llm S something back it often still needs a fair bit of work”transcript, stated
“when the output parsers fail or don't work entirely as expected we enforce those Transformations”transcript, stated

The initial polling/scheduled architecture may not remain ideal as the project matures.

Root cause: Hourly polling works at current volume, but document arrivals and pipeline maturity point toward event-driven execution.

Resolution: Plan to adopt event-driven Metaflow/Kubernetes patterns once documentation and implementation gaps are addressed.

“as our project matures we realize that what we probably need is event driven um pipeline”transcript, stated
“there is an example but it' be nice to have like a comprehensive example because when you read read it it says oh here's an example but we're missing this this and that”transcript, stated

Local development across developer machines caused enough friction to change the dev environment.

Root cause: Mac/AMD and cross-machine differences made running Metaflow locally inconsistent.

Resolution: Put Metaflow inside a container and use Docker Compose to spin up pipelines, API, and databases locally.

“issues with Mac AMD we eventually came to um putting metlow inside a container just to try to insulate our cells from those problems”transcript, stated
“you run you know Docker compos build Docker comose up and it spins up the entire service so the pipeline the API”transcript, stated

LLM API cost can grow from avoidable duplicate work.

Root cause: External LLM calls are expensive, and naive pipelines may re-run predictions that already exist.

Resolution: Check for existing predictions and narrow work before making LLM calls; manage tokens and timeouts on LLM steps.

“I check and see if I already have a prediction to try and really narrow down the amount of work”transcript, stated
“all those calls are are expensive so trying to manage the amount of work the llm needs to do”transcript, stated

Evaluation

The source describes reporting on prediction quality through reverse ETL into the data warehouse, operational checks for existing predictions before new LLM calls, hourly workflow cadence monitoring, and developer feedback from SDK users. It does not describe a formal offline evaluation harness.

Metrics: Prediction quality/performance reporting in the data warehouse · Hourly risk-classification cadence · Existing-prediction checks before LLM calls · LLM cost/token-management checks · Developer usability through SDK usage

4 supporting quotes
“reverse ETL back into the data warehouse to make it easier for us to report on how well they're working”transcript, stated
“for our risk classification use cases we can run those pipelines every hour and it checks to see if there's anything new”transcript, stated
“I check and see if I already have a prediction to try and really narrow down the amount of work”transcript, stated
“all those calls are are expensive so trying to manage the amount of work the llm needs to do got it okay and there's like token management steps but I bet uh I bet that Eddie has all that in his content as well a little bit um sh did you have another question no no go ahead go ahead I don't”transcript, stated

Outcomes

The system operates on hourly risk-classification workflows, on-demand document AI, terabytes or hundreds of terabytes of relevant feature-engineering data, structured/semi-structured data plus PDFs, and SDK integration that requires only a couple lines of product code.

5 supporting quotes
“she has led the development of AI and llm Technologies in production at wou she's developed classification and document AI solutions”transcript, stated
“for our risk classification use cases we can run those pipelines every hour”transcript, stated
“for the document AI workflows those will be kind of on an as needed basis or as soon as the documents hit our services”transcript, stated
“we put in front of metaflow a uh fast API instance that allows us to serve those predictions”transcript, stated
“that is you don't necessarily have to run the project um because SDK points at the dev instance”transcript, stated