Building Production-Grade Generative AI Applications with Comprehensive LLMOps

block_(square) · Tech · 2023 · source Agentic: no · promotional bias: med · 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: Enterprise LLMOps for production generative AI applications across multiple business units

Block needed a flexible platform for generative AI applications across Square, Cash App, TIDAL, and TBD that could support fast-moving model choices, many serving endpoints, RAG, feedback logging, cost attribution, rate limits, sensitive-data handling, self-hosted models, fine-tuning, and monitoring without requiring every application to be rewritten whenever prompts or models changed.

Constraints:

Architecture

Block treats LLM chains as versioned MLflow models served behind stable endpoints. Application-specific chains handle prompts, validation, retries, fallback, retrieval, and pre/post-processing, while MLflow AI Gateway routes foundation-model calls to self-hosted Llama, OpenAI, Claude, fine-tuned models, or other vendors. Vector Search keeps RAG context decoupled from model hosting, Delta tables and Kafka feedback feed inference analysis, Lakehouse Monitoring connects data and model lineage, and optimized GPU serving/self-hosted models protect sensitive data and latency budgets. Fine-tuning smaller models is used selectively when enough endpoint volume justifies the upfront and operational costs.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  business-unit-applications["Business unit applications"] --> serving-endpoint["Serving endpoint"]
  serving-endpoint --> versioned-llm-chain["Versioned LLM chain"]
  serving-endpoint --> inference-logging["Inference logging"]
  versioned-llm-chain --> preprocessing-filters["Preprocessing filters"]
  versioned-llm-chain --> vector-search-endpoint["Vector Search endpoint"]
  vector-search-endpoint --> delta-context-tables["Delta context tables"]
  versioned-llm-chain --> mlflow-ai-gateway["MLflow AI Gateway"]
  mlflow-ai-gateway --> foundation-and-fine-tuned-models["Foundation and fine-tuned models"]
  mlflow-ai-gateway --> central-credentials-and-rate-limits["Central credentials and rate limits"]
  foundation-and-fine-tuned-models --> optimized-gpu-serving["Optimized GPU serving"]
  versioned-llm-chain --> output-validator["Output validator"]
  inference-logging --> inference-tables["Inference tables"]
  kafka-feedback-pipeline["Kafka feedback pipeline"] --> inference-tables
  inference-tables --> lakehouse-monitoring["Lakehouse Monitoring"]
  delta-context-tables --> lakehouse-monitoring
  mlflow-tracking["MLflow tracking"] --> versioned-llm-chain
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Business unit applications Square, Cash App, TIDAL, TBD, support chat, action-calling, and other GenAI applications that need reusable platform capabilities. Serving endpoint
Serving endpoint Stable application-facing endpoint that hosts a versioned LLM chain/model and shields application code from prompt/model changes. Versioned LLM chain, Inference logging
Versioned LLM chain Python/LangChain-style model artifact that packages prompts, validation, retries, fallback, retrieval, and model calls as a versioned MLflow model. Preprocessing filters, Vector Search endpoint, MLflow AI Gateway, Output validator
Preprocessing filters Input-time checks for prompt injection, bad actors, and other risky input before the model call. Versioned LLM chain
Vector Search endpoint Semantic search endpoint that serves updatable context for RAG without requiring model redeploys. Delta context tables, Versioned LLM chain
Delta context tables Structured and unstructured enterprise data stored in Delta tables and synchronized into vector indexes or feature endpoints. Vector Search endpoint, Lakehouse Monitoring
MLflow AI Gateway Stable routing and proxy layer for internal Databricks models, external model providers, self-hosted Llama, ChatGPT, Claude, and fine-tuned models. Foundation and fine-tuned models, Central credentials and rate limits
Foundation and fine-tuned models General-purpose, self-hosted, external, and fine-tuned LLMs that generate responses or structured outputs. MLflow AI Gateway, Optimized GPU serving
Optimized GPU serving Databricks model-serving infrastructure used for self-hosted and fine-tuned models when sensitive data, latency, or cost requires it. Foundation and fine-tuned models
Central credentials and rate limits Gateway-managed API keys, vendor access, company-wide quota enforcement, usage visibility, and cost attribution. MLflow AI Gateway
Output validator Post-processing layer that checks output toxicity or asks a second model whether the answer is hallucinated. Versioned LLM chain
Inference logging Endpoint logging that captures model inputs and outputs into inference tables. Inference tables
Inference tables Logged inference data that can be joined with application feedback and monitored. Kafka feedback pipeline, Lakehouse Monitoring
Kafka feedback pipeline Application feedback stream, such as accept rates, made available as Delta tables for analysis. Inference tables
Lakehouse Monitoring Unified data and model monitoring layer with lineage, dashboards, metrics, alerts, and root-cause analysis. Inference tables, Delta context tables
MLflow tracking Experiment tracking and model versioning layer used to compare prompt/model-chain versions and A/B test improvements. Versioned LLM chain

Data flow

A Block application sends a request to a serving endpoint that wraps an LLM chain. The chain may validate inputs, run retrieval against a Vector Search endpoint backed by Delta tables, hydrate the prompt with retrieved context, call MLflow AI Gateway for a foundation model or fine-tuned model, and validate output for toxicity or hallucination before returning to users. Inference logging captures inputs and outputs into inference tables. Application feedback such as accept rates flows through Kafka into Delta tables, where it can be joined back to inferences for A/B analysis and bad-output analysis. AI Gateway centralizes model routing, credentials, rate limits, usage, and cost attribution; Lakehouse Monitoring monitors both data and model outputs with shared lineage.

6 supporting quotes
“You can just implement this in Python or maybe something like LangChain, and then put that version model into the LLM ops tools and track it.”transcript, stated
“Each of them is going to be calling out for its foundational capabilities through AI gateway. And then that can just route to a collection of different models like Llama self-hosted but also ChatGPT or Claude, or any other vendor that you wanna fit into”transcript, stated
“same infrastructure, but instead of the chain being kind of a simple prompt and validate, now we're retrieving documents. So this is where the vector search comes in. I think it's been really crucial for us, I think most of our applications so far are retrieval-based. That lets us take”transcript, stated
“before, that's really easy to do in the Databricks solution. So you just take an endpoint, and you set up inference logging, and now you've got input and outputs. But to actually make use of that data, you probably wanna join it back to some form of customer feedback. So your application”transcript, stated
“you can then easily join your feedback back to your inferences and start actually measuring A/B test outcomes or even doing analysis on what inputs cause bad outputs. Okay, so let me talk through one more use case, and I think this is maybe the most common”transcript, stated
“lakehouse monitoring allows you to do. It allows you to keep the data lineage and the ML lineage connected because the observability layer is the same. There is no different stacks for monitoring your data and monitoring your ML models. So we're really,”transcript, stated

Why this architecture

Block chose a platform architecture because direct calls to individual endpoints quickly break down once teams need version tracking, A/B testing, model swaps, sensitive-data controls, endpoint proliferation management, quota enforcement, retrieval updates, and cost/latency optimization. The separation between application endpoints, gateway-routed foundation models, vector-search context, inference logs, and monitoring allows teams to iterate without rewriting applications for every prompt or model change.

5 supporting quotes
“we need a platform and a toolkit that's gonna generalize to be able to cover everything that we're gonna need out of that.”transcript, stated
“we don't wanna overbuild something that will just become invalidated in three or six months. So we're looking for something that's very flexible but also quick to integrate. And so let me try to motivate the tools that we're using from the Databricks stack”transcript, stated
“quickly lose track of the performance of the different versions and what were the best prompts unless you're treating this whole stack as a version model. So this is where the MLflow comes in. You can just implement this in Python or maybe something like LangChain, and then”transcript, stated
“change, you're actually gonna have to change code to call out a different endpoint. And so it quickly becomes much easier to do this through AI gateway. So you have a whole stack of serving endpoints. Each of them is going to be calling out for its foundational capabilities”transcript, stated
“decoupling those gives you this really valuable workflow where you can separately iterate on your prompt or your different model selections”transcript, stated

Models used: GPT-4 · OpenAI ChatGPT · Anthropic Claude · Self-hosted Llama · Llama 70B · Fine-tuned 13B and 3B parameter models · BERT-based chat models under 1B parameters · Embedding models for vector search · Second-model hallucination validators

Scale

Alternatives considered (roads not taken)

Directly integrate each application with one model endpoint.

Rejected because: Block found direct endpoint integrations tempting but fragile because prompt/model versions proliferate, applications need frequent updates, and AI Gateway provides stable routing and operational controls.

“to keep up as all these use cases proliferate. The second is that even simple applications, it's tempting to just do a direct integration with an endpoint. But it is very valuable to treat them as version models and make a process out of improving them and giving them standalone”transcript, stated
“You don't need to be just changing your application every time you're making a change to the models. So one of the problems for us was that this proliferated very quickly. We had a lot of different applications calling a lot of different endpoints. I think”transcript, stated

Host a separate GPU foundation model behind every application endpoint.

Rejected because: The number of application chains is much larger than the number of foundation models, so hosting a GPU model per chain would be egregiously expensive.

“you wouldn't possibly want to be hosting a GPU serving endpoint for every one of these chains. It would be egregiously expensive.”transcript, stated

Keep RAG context inside the model-hosting process.

Rejected because: In-memory vector search works early, but it becomes operationally difficult to update context when every data change requires redeploying the model.

“get it into the model. Some of our first efforts, we actually did most of the vector search within memory. And that goes a long way. Like as in you don't need a separate vector search endpoint to hold that. You can instead just have it in the model hosting. But even even if you don't have scaling”transcript, stated
“it's really operationally difficult to update your context if you have to redeploy the model anytime you wanna add new data to it.”transcript, stated

Send all customer-facing data to third-party hosted models.

Rejected because: For sensitive data, Block relied on self-hosted models and optimized GPU serving to avoid sending data out to a third party.

“for our most sensitive data, we were going to rely on self-hosted models for that security. But if you just try to set this up and you build your own container and try to run PyTorch for some of these big models, you'll see that it is dramatically slower”transcript, stated
“if there's any risk that will have sensitive data flowing through this pipeline, that we're not necessarily sending that data out to a third party.”transcript, stated

Fine-tune every use case immediately.

Rejected because: Fine-tuning only pays off when endpoint usage justifies upfront training, GPU hosting, and operational costs, so Block frames it as an iterative maturity step.

“pointing to that same fine-tuned model. The last thing I'll mention for fine-tuning is that there's definitely a minimal scale to justify this investment. So both in the, like, upfront costs of doing the fine-tuning, the operational costs of hosting this on GPUs, if you have”transcript, stated
“hosting this on GPUs, if you have even one A10 that ends up being relatively expensive. So you need enough usage of these endpoints to justify it. But on the flip side, I think a year ago, there was also a significant upfront talent cost to this where you'd have to go”transcript, stated

Patterns

prompt-versioning (operations)

Block treats the whole LLM stack of prompts, chains, validation, model choice, and endpoint behavior as a versioned MLflow model so teams can compare versions and avoid losing track of prompt/model performance.

“you will quickly lose track of the performance of the different versions and what were the best prompts unless you're treating this whole stack as a version model.”transcript, stated
“you can start doing something like A/B testing, one version versus another”transcript, stated

model-routing (architecture)

MLflow AI Gateway provides a stable API route that can point to self-hosted Llama, ChatGPT, Claude, Bedrock, Databricks-served models, external vendors, or fine-tuned models.

“MLflow AI Gateway acts as a proxy to LLMs that could sit internally in Databricks but also externally.”transcript, stated
“route to a collection of different models like Llama self-hosted but also ChatGPT or Claude”transcript, stated

rag-retrieval (architecture)

Customer-facing chat applications retrieve Block-specific context through Vector Search rather than relying on the base model's reference material.

“if you're gonna have someone ask a question about Square, you wanna make sure it's not just using the reference material from the base model.”transcript, stated
“I think it's been really crucial for us, I think most of our applications so far are retrieval-based. That lets us take our context, which is kind of already in our data systems and just transparently get it into the model.”transcript, stated

observability-tracing (operations)

Inference logging, inference tables, customer feedback joins, cost attribution, usage visibility, and lakehouse monitoring provide operational visibility into model behavior.

3 supporting quotes
“you set up inference logging, and now you've got input and outputs.”transcript, stated
“single place for visibility into things like rate limits or usage and cost attribution”transcript, stated
“There is no different stacks for monitoring your data and monitoring your ML models.”transcript, stated

guardrails-io-filtering (safety)

Customer-facing chains add pre-processing for prompt injection or bad actors and post-processing for toxicity or hallucination checks.

3 supporting quotes
“you really wanna filter for potential bad actors trying to do prompt injection or things like that”transcript, stated
“on the output, you put a validation set that says, "Okay, nothing toxic is coming out of this."”transcript, stated
“And then similarly, on the output, you put a validation set that says, "Okay, nothing toxic is coming out of this." Or even more ambitiously, you can actually ask a second model, is this a hallucination? And then be confident, more confident in your results.”transcript, stated

privacy-preserving-processing (safety)

For the most sensitive data, Block relies on self-hosted models and optimized GPU serving rather than third-party model providers.

“for our most sensitive data, we were going to rely on self-hosted models for that security.”transcript, stated

fine-tuning-adaptation (modeling)

Fine-tuning is used selectively to reduce latency and cost by moving from larger models to smaller models when use-case scale justifies it.

“we've been looking at fine-tuning mostly as a way to drive down latency or improve those costs.”transcript, stated
“fine-tuning, you might be able to take that down to a 3 billion parameter model.”transcript, stated

cost-aware-routing (operations)

The gateway prevents duplicate GPU hosting, centralizes cost attribution, enforces company-wide rate limits, and lets fine-tuned models be reused by multiple endpoints.

“that really helps reduce the cost by not needing to host your models multiple times”transcript, stated
“one application is not gonna use up the whole quota and end up shutting down production apps.”transcript, stated

Tradeoffs

Build a flexible platform but avoid overbuilding for a fast-moving space.

Chose Minimal platform capabilities that speed integration, versioning, routing, and monitoring over Heavy infrastructure that could be invalidated in three to six months.

Rationale: Block needed a general toolkit across business units while preserving speed as model and vendor choices changed.

“we don't wanna overbuild something that will just become invalidated in three or six months.”transcript, stated
“So we're looking for something that's very flexible but also quick to integrate. And so let me try to motivate the tools that we're using from the Databricks stack by walking through a couple of examples and how you might go about building them.”transcript, stated

Centralize model routing through AI Gateway.

Chose Stable gateway route with centralized credentials, usage, cost, and quota controls over Application code directly calling model-specific endpoints.

Rationale: The gateway keeps application endpoints stable while model vendors, rate limits, and foundational model choices change underneath.

“stable API, and connect the rest of your architecture, the rest of your LLM ops, to AI gateway”transcript, stated
“You can set up AI gateway, which is gonna have a stable API, and connect the rest of your architecture, the rest of your LLM ops, to AI gateway and have the flexibility to swap the model that it's pointing to. Here's the codes, that it's more clear.”transcript, stated

Decouple vector context from model endpoints.

Chose Separate Vector Search endpoints for changing context over Keeping retrieved context in memory inside model hosting.

Rationale: Separate retrieval lets teams update knowledge without redeploying the model and lets prompt/model selection iterate independently.

“we actually did most of the vector search within memory. And that goes a long way.”transcript, stated
“And so decoupling those gives you this really valuable workflow where you can separately iterate on your prompt or your different model selections in the main chain while also just adding new context over time into the separate vector search endpoint.”transcript, stated

Self-host sensitive workloads despite serving complexity.

Chose Self-hosted models on optimized GPU serving over Third-party hosted models for all customer data.

Rationale: Sensitive-data pipelines require security control, but usable latency required optimized GPU serving rather than naive self-hosting.

“for our most sensitive data, we were going to rely on self-hosted models for that security.”transcript, stated
“Being able to build these solutions without optimized GPU serving, it was just too slow. The latency per token was too high to really make this function.”transcript, stated

Fine-tune smaller models only when volume justifies it.

Chose Fine-tuning to reduce latency and cost for high-volume endpoints over Always using larger general models or fine-tuning every endpoint.

Rationale: Generation dominates latency and spend, but fine-tuning has upfront and hosting costs that require enough usage.

“the vast majority of your latency budget and your spend is coming from the generation step.”transcript, stated
“The last thing I'll mention for fine-tuning is that there's definitely a minimal scale to justify this investment. So both in the, like, upfront costs of doing the fine-tuning, the operational costs of hosting this on GPUs, if you have even one A10 that ends up being relatively expensive.”transcript, stated

Gotchas (what bit them)

Prompt/model variants become unmanageable if teams do not version the whole LLM stack.

Root cause: A simple structured-output app can quickly accumulate prompt changes, model swaps, validation, retries, fallback, and six or seven versions before shipping.

Resolution: Package the chain as a versioned MLflow model and compare versions through A/B tests rather than rewriting application code.

“you've quickly built up a more complicated chain, and you've tried out six or seven different versions of it before you've shipped that.”transcript, stated
“And I think one of the key insights we had early on was that you will quickly lose track of the performance of the different versions and what were the best prompts unless you're treating this whole stack as a version model. So this is where the MLflow comes in.”transcript, stated

Endpoint proliferation creates cost, visibility, and quota failures.

Root cause: Many application-specific chains called many model endpoints, and each endpoint otherwise had to know which model it called.

Resolution: Route foundational model calls through MLflow AI Gateway for centralized visibility, rate limits, usage, cost attribution, and model swaps.

“We had a lot of different applications calling a lot of different endpoints. I think we're at a couple hundred of these today.”transcript, stated
“single place for visibility into things like rate limits or usage and cost attribution”transcript, stated

RAG context becomes hard to update if it is embedded inside model hosting.

Root cause: In-memory vector search can work early, but adding new context requires redeploying the model when retrieval is coupled to hosting.

Resolution: Decouple retrieval into a separate Vector Search endpoint that can receive new context while prompts and model selections iterate separately.

“it's really operationally difficult to update your context if you have to redeploy the model anytime you wanna add new data to it.”transcript, stated
“adding new context over time into the separate vector search endpoint.”transcript, stated

Self-hosting large models can be too slow without optimized serving infrastructure.

Root cause: Naive containers running PyTorch for big models had token latency too high for customer-facing applications.

Resolution: Use optimized GPU serving endpoints for self-hosted or fine-tuned models.

“without optimized GPU serving, it was just too slow. The latency per token was too high to really make this function.”transcript, stated
“those optimized GPU serving endpoints that we talked about, those were really enabling.”transcript, stated

Customer-facing model outputs need both input and output guardrails.

Root cause: Freeform customer input can include prompt injection or bad actors, and model output can be toxic or hallucinated.

Resolution: Add pre-processing filters and post-processing validators, including second-model hallucination checks where needed.

“if you just take unfiltered input, pass it out and then put the output of the model in front of a customer, there's a lot that can go wrong there.”transcript, stated
“So I think we've started to focus on solutions kind of as a pre and post-processing step. So at the input time, you really wanna filter for potential bad actors trying to do prompt injection or things like that, which you can pretty reliably detect.”transcript, stated

Fine-tuning has a minimum scale threshold.

Root cause: Fine-tuning has upfront data/model work and ongoing GPU hosting costs, so low-volume endpoints may not justify the investment.

Resolution: Use fine-tuning as an iterative maturity step only when it improves performance or reduces costs enough for the endpoint volume.

“The last thing I'll mention for fine-tuning is that there's definitely a minimal scale to justify this investment. So both in the, like, upfront costs of doing the fine-tuning, the operational costs of hosting this on GPUs, if you have even one A10 that ends up being relatively expensive.”transcript, stated
“So you need enough usage of these endpoints to justify it. But on the flip side, I think a year ago, there was also a significant upfront talent cost to this where you'd have to go figure out the training pipeline and actually implement RLHF or something like that and then run this.”transcript, stated

Evaluation

Block evaluates production GenAI systems by treating chains as versioned models, running A/B tests between versions, logging inputs/outputs through inference tables, joining feedback back to inferences, analyzing bad outputs, validating against prompt-injection/toxicity/hallucination risks, and tracking cost, usage, rate limits, latency, and monitoring lineage.

Metrics: A/B test outcomes between chain versions · Accept rates on suggested actions · Inputs that cause bad outputs · Rate-limit usage by application · Usage and cost attribution by endpoint/model · Inference latency per token · Output toxicity · Hallucination detection by a second model · Retrieval recall · Lakehouse monitoring alerts and default/custom metrics

6 supporting quotes
“you can start doing something like A/B testing, one version versus another”transcript, stated
“your application is maybe measuring accept rates on the suggested actions or something like that.”transcript, stated
“start actually measuring A/B test outcomes or even doing analysis on what inputs cause bad outputs.”transcript, stated
“single place for visibility into things like rate limits or usage and cost attribution”transcript, stated
“you put a validation set that says, "Okay, nothing toxic is coming out of this."”transcript, stated
“And then similarly, on the output, you put a validation set that says, "Okay, nothing toxic is coming out of this." Or even more ambitiously, you can actually ask a second model, is this a hallucination? And then be confident, more confident in your results.”transcript, stated

Outcomes

The case reports a couple hundred endpoints, six or seven versions before shipping one chain, company-wide GPT-4 rate-limit concerns, a shift from 13B to 3B fine-tuned model targets, prior sub-1B BERT-based chat models, and an A10 GPU as a meaningful hosting-cost threshold.

5 supporting quotes
“I think we're at a couple hundred of these today. And so operationally, it's really important that you figure out a way to manage this from the platform side and for teams to have visibility into what everything is doing.”transcript, stated
“I think it's been really crucial for us, I think most of our applications so far are retrieval-based. That lets us take our context, which is kind of already in our data systems and just transparently get it into the model.”transcript, stated
“those optimized GPU serving endpoints that we talked about, those were really enabling.”transcript, stated
“we've been looking at fine-tuning mostly as a way to drive down latency or improve those costs.”transcript, stated
“every investment you're making is either driving more performance or reducing costs.”transcript, stated