Building Production-Grade LLM Applications: An Architectural Guide

github · Tech · 2023 · 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: Reference architecture for production LLM applications

GitHub’s guide addresses how developers should scope, select, customize, deploy, and evaluate LLM-powered applications when outputs are probabilistic, context must be retrieved and packaged, unsafe inputs/outputs must be filtered, and online user behavior must feed product iteration.

Constraints:

Architecture

The guide proposes a five-step LLM application lifecycle: focus on one problem, choose the right pretrained LLM, customize it with in-context learning/RLHF/fine-tuning, set up the application architecture, and run online evaluations. The runtime architecture includes an LLM API/host, UI/router, speech-to-text where needed, data sources, an embedding model, vector database, prompt optimization, a data filter, an LLM cache, content classifier/filter, and telemetry service. A hypothetical ISP assistant illustrates the flow: Dave’s spoken Wi-Fi issue is routed through the UI, translated to text, enriched with vector-search context from company complaints/solutions, filtered for authorized data, packaged into a prompt, answered by the LLM, moderated by safety tooling, cached when appropriate, and evaluated through telemetry.

Diagram confidence: explicit (topology described by the source).

flowchart LR
  problem-scoping["Problem scoping"] --> llm-selection["LLM selection"]
  llm-selection --> llm-customization["LLM customization"]
  llm-customization --> llm["LLM"]
  user["User"] --> ui-and-router["UI and router"]
  ui-and-router --> speech-to-text["Speech-to-text"]
  speech-to-text --> embedding-model["Embedding model"]
  data-source["Data source"] --> embedding-model
  embedding-model --> vector-database["Vector database"]
  vector-database --> prompt-optimization-tool["Prompt optimization tool"]
  data-filter["Data filter"] --> prompt-optimization-tool
  prompt-optimization-tool --> llm-api-and-host["LLM API and host"]
  llm-api-and-host --> llm-cache["LLM cache"]
  llm-api-and-host --> llm
  llm --> content-classifier["Content classifier"]
  content-classifier --> user
  llm --> telemetry-service["Telemetry service"]
  telemetry-service --> online-evaluation["Online evaluation"]
  online-evaluation --> problem-scoping
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
User End user with a task or support request, illustrated by Dave's ISP support scenario. UI and router
UI and router Application interface and routing layer that directs user interaction into the appropriate assistant path. Speech-to-text, LLM API and host
Speech-to-text Background translation layer for voice requests before text processing. Embedding model
LLM API and host Cloud or local model hosting and API layer for inference. LLM, LLM cache
LLM Pretrained or customized model that generates the response from prompt and retrieved context. Content classifier, Telemetry service
Data source Company-specific knowledge such as complaints, solutions, documents, and other relevant context. Embedding model
Embedding model Model that converts user queries and data into high-dimensional vectors for semantic retrieval. Vector database
Vector database Storage and search layer for embeddings that retrieves relevant context for the user query. Prompt optimization tool
Prompt optimization tool Context-packaging layer that prioritizes and orders retrieved snippets for the LLM prompt. Data filter, LLM API and host
Data filter Authorization and privacy filter that prevents unauthorized data, such as PII, from entering the LLM prompt. Prompt optimization tool
LLM cache Response cache for repeated or similar queries that reduces latency, compute cost, and variability. LLM API and host
Content classifier Responsible-AI component that prevents harmful or offensive assistant responses. User
Telemetry service Monitoring layer that captures real user behavior and supports online evaluation. Online evaluation
Online evaluation Evaluation loop that measures interaction metrics such as acceptance and retention/edit rates in production. Problem scoping
Problem scoping Initial product discipline that narrows the LLM app to one valuable, iteratable problem. LLM selection
LLM selection Pre-deployment choice of model based on licensing, size, performance, speed, cost, and offline evaluations. LLM customization
LLM customization Task adaptation through in-context learning, RLHF, or fine-tuning. LLM

Data flow

A user enters through a UI or voice channel. The UI/router sends the request to the right LLM assistant path, and speech-to-text converts voice into text when needed. Input enrichment embeds the query, retrieves relevant context from a vector database backed by company data, filters unauthorized data, and uses prompt optimization to prioritize and order context. The LLM API/host generates an answer, optionally reusing cached outputs for similar queries. A content classifier/filter blocks harmful responses, and telemetry captures user behavior for online evaluation and product improvement.

6 supporting quotes
“he calls his internet service provider (ISP) and is directed to an LLM-powered assistant. The assistant asks Dave to explain his emergency, and Dave responds, “My TV was connected to my Wi-Fi, but I bumped the counter, and the Wi-Fi box fell off! Now, we can’t watch the game.””article, stated
“Dave’s verbal query then needs to be fed through a speech-to-text translation tool that works in the background.”article, stated
“Input enrichment tools aim to contextualize and package the user’s query in a way that will generate the most useful response from the LLM.”article, stated
“A vector database is where you can store embeddings, or index high-dimensional vectors. It also increases the probability that the LLM’s response is helpful by providing additional information to further contextualize your user’s query. Let’s say the LLM”article, stated
“A data filter will ensure that the LLM isn’t processing unauthorized data, like personal identifiable information.”article, stated
“An LLM cache stores outputs. This means instead of generating new responses to the same query (because Dave isn’t the first person whose internet has gone down), the LLM can retrieve outputs from the cache that have been used for similar queries. Caching”article, stated

Why this architecture

The guide recommends a layered architecture because LLM output quality depends on more than the model call. The app must start from a focused problem, pick a commercially appropriate and measurable model, enrich user input with retrieved context, block unauthorized data, package prompt context, reduce latency and variability with caching, filter harmful responses, and use telemetry/online evaluations to keep improving the user experience.

4 supporting quotes
“For one, rather than compiling source code into binary to run a series of commands, developers need to navigate datasets, embeddings, and parameter weights”article, stated
“Find a problem that’s the right size: one that’s focused enough so you can quickly iterate and make progress, but also big enough so that the right solution will wow users. For instance, rather than trying to address all developer problems with AI, the”article, stated
“The different components you’ll need to set up your LLM app can be roughly grouped into three categories: * User input which requires a UI, an LLM, and an app hosting platform. * Input enrichment and prompt construction tools. This includes your data”article, stated
“Efficient and responsible AI tooling, which includes an LLM cache, LLM content classifier or filter, and a telemetry service”article, stated

Models used: Pre-trained LLMs · Ada-scale models around 350 million parameters · 7B-13B parameter open models · 175B parameter large models · Embedding models · Reward models for RLHF · Fine-tuned task-specific models · Content classifiers

Scale

Alternatives considered (roads not taken)

Attempt to solve a broad class of user problems immediately.

Rejected because: GitHub recommends starting with a single scoped problem, citing Copilot's initial focus on coding functions in the IDE instead of all developer problems.

“rather than trying to address all developer problems with AI, the GitHub Copilot team initially focused on one part of the software development lifecycle”article, stated
“GitHub Copilot team initially focused on one part of the software development lifecycle: coding functions in the IDE. **2. Choose the”article, stated

Pick the largest model by default.

Rejected because: The guide notes that smaller models are faster and cheaper, and improved smaller-model performance challenges the bigger-is-always-better assumption.

“models](https://spectrum.ieee.org/large-language-models-size) is challenging that belief. Smaller models are also usually faster and cheaper, so improvements to the quality of their predictions make them a viable contender compared to big-name models that might”article, stated
“models](https://spectrum.ieee.org/large-language-models-size) is challenging that belief. Smaller models are also usually faster and cheaper, so improvements to the quality of their predictions make them a viable contender compared to big-name models that might”article, stated

Fine-tune before measuring the base model.

Rejected because: The guide says teams should evaluate the pretrained model's speed, consistency, and desired output before customization.

“Before you customize your LLM using techniques like fine-tuning and in-context learning (which we’ll cover below), evaluate how well and fast—and how consistently—the model generates your desired output. To measure model performance, you can use **offline”article, stated
“and in-context learning (which we’ll cover below), evaluate how well and fast—and how consistently—the model generates your desired output. To measure model performance, you can use offline evaluations. 3. Customize the LLM. When you train an LLM, you’re building the scaffolding and neural”article, stated

Use only prompt/in-context learning for adaptation.

Rejected because: The guide presents in-context learning, RLHF, and fine-tuning as different adaptation mechanisms with different supervision and labeling costs.

“To customize a pre-trained LLM to your specific needs, you can try in-context learning, reinforcement learning from human feedback (RLHF), or fine-tuning.”article, stated

Generate every response fresh from the model.

Rejected because: Caching similar-query outputs can reduce latency, computational cost, and variability.

“Caching outputs can reduce latency, computational costs, and variability in suggestions. You can experiment with a tool like zilliztech/GPTcache to cache your app’s responses. * A content classifier or filter can”article, stated

Patterns

rag-retrieval (architecture)

The assistant enriches the user query with company-specific context retrieved from embeddings stored in a vector database.

“the LLM assistant uses information not only from the internet’s IT support documentation, but also from documentation specific to customer problems with the ISP.”article, stated
“retrieve information from the vector database that’s relevant to a user’s query”article, stated

retrieval-ranking (architecture)

Prompt optimization prioritizes relevant embeddings and orders context snippets before sending the prompt to the LLM.

“prioritize which context embeddings are most relevant, and in which order those embeddings should be organized”article, stated
“retrieve embeddings from the vector database, grab snippets of the relevant context, and order them.”article, stated

guardrails-io-filtering (safety)

The architecture includes a data filter to block unauthorized/PII input and a content classifier to prevent harmful or offensive responses.

“A data filter will ensure that the LLM isn’t processing unauthorized data, like personal identifiable information.”article, stated
“A content classifier or filter can prevent your automated assistant from responding with harmful or offensive suggestions”article, stated

semantic-caching (operations)

The LLM cache reuses outputs for repeated or similar queries to lower latency, cost, and response variability.

“An LLM cache stores outputs. This means instead of generating new responses to the same query”article, stated
“Caching outputs can reduce latency, computational costs, and variability in suggestions.”article, stated

observability-tracing (operations)

Telemetry captures production user behavior so developers can evaluate and improve the LLM app.

“A telemetry service will allow you to evaluate how well your app is working with actual users.”article, stated
“monitors user activity (like how often they accept or change a suggestion)”article, stated

eval-driven-development (quality)

The guide recommends offline evaluations before customization and online evaluations after deployment, using metrics like acceptance and retention/edit rate.

“To measure model performance, you can use offline evaluations.”article, stated
“Conduct online evaluations of your app.** These evaluations are considered “online” because they assess the LLM’s performance during user interaction.”article, stated

fine-tuning-adaptation (modeling)

Fine-tuning is presented as a supervised customization technique for task-specific behavior when labeled examples are available.

“Fine-tuning can result in a highly customized LLM that excels at a specific task”article, stated
“it uses supervised learning, which requires time-intensive labeling.”article, stated

Tradeoffs

Start with a narrow problem scope.

Chose A focused use case that supports quick iteration and visible user value over Trying to address all user problems with AI from the start.

Rationale: A narrow scope makes iteration and measurement more practical while still enabling expansion later.

“focused enough so you can quickly iterate and make progress, but also big enough so that the right solution will wow users.”article, stated
“For instance, rather than trying to address all developer problems with AI, the GitHub Copilot team initially focused on one part of the software development lifecycle:”article, stated

Consider smaller models for production apps.

Chose Smaller/faster/cheaper models when quality is sufficient over Automatically choosing the largest model.

Rationale: The guide says smaller-model performance is improving and may be viable where large models are out of scope.

“Smaller models are also usually faster and cheaper, so improvements to the quality of their predictions make them a viable contender compared to big-name models that might be out of scope for many apps.”article, stated
“viable contender compared to big-name models that might be out of scope for many apps.”article, stated

Use RLHF when exact labels are unavailable but user preference feedback exists.

Chose Reward-model learning from accept/reject behavior over Supervised fine-tuning with exactly labeled outputs for every sample.

Rationale: RLHF expands acceptable-output criteria without requiring exact labels, while fine-tuning can be powerful but labeling-intensive.

“The benefit to RLHF is that it doesn’t require supervised learning and, consequently, expands the criteria for what’s an acceptable output.”article, stated
“each input sample requires an output that’s labeled with exactly the correct answer.”article, stated

Cache similar outputs for efficiency.

Chose LLM cache reuse for repeated or similar queries over Always generating a fresh answer.

Rationale: Caching reduces latency and cost but must be paired with filters and telemetry for responsible behavior.

“ensure that Dave doesn’t become even more frustrated by waiting for the LLM assistant to generate a response, the LLM can quickly retrieve an output from a cache. And in the case that Dave does have an outburst, we can use a content classifier to make sure the LLM app doesn’t respond in”article, stated
“Caching outputs can reduce latency, computational costs, and variability in suggestions.”article, stated

Host locally for tinkering but use cloud hosting for volume.

Chose Cloud hosting for production call volume, local hosting for low-cost experimentation over One hosting strategy for every lifecycle stage.

Rationale: The guide distinguishes production scale from experimentation cost management.

“In an ISP’s case, it’s probably hosted in the cloud to handle the volume of calls like Dave’s.”article, stated
“hosting the model on your machine might be more cost effective so that you’re not paying to spin up your cloud environment every time you want to experiment.”article, stated

Gotchas (what bit them)

LLM apps cannot be engineered like deterministic compiled software.

Root cause: Developers must navigate datasets, embeddings, and parameter weights, and outputs are probabilistic.

Resolution: Use evaluation, retrieval, prompt construction, guardrails, telemetry, and iterative product scoping around the model call.

“rather than compiling source code into binary to run a series of commands, developers need to navigate datasets, embeddings, and parameter weights”article, stated
“LLM outputs are probabilistic and don’t produce the same predictable outcomes.”article, stated

Starting too broad slows learning and makes evaluation vague.

Root cause: A general-purpose AI ambition does not provide the focused iteration loop needed for measurable progress.

Resolution: Choose a focused problem first, as Copilot initially did with coding functions in the IDE.

“Find a problem that’s the right size: one that’s focused enough so you can quickly iterate and make progress”article, stated
“the GitHub Copilot team initially focused on one part of the software development lifecycle”article, stated

Commercial model licensing can block deployment if ignored during model selection.

Root cause: Some models/APIs may not be licensed for commercial use.

Resolution: Include licensing as an explicit LLM selection criterion before building a sellable application.

“If you hope to eventually sell your LLM app, you’ll need to use a model that has an API licensed for commercial use.”article, stated

Context retrieval can leak unauthorized or personal data into the LLM.

Root cause: The prompt construction layer pulls company data into model context.

Resolution: Add a data filter that blocks unauthorized data and PII before prompt construction.

“A data filter will ensure that the LLM isn’t processing unauthorized data, like personal identifiable information.”article, stated

Unsafe user behavior can produce unsafe model behavior if outputs are not filtered.

Root cause: Users may be frustrated or abusive, and the automated assistant might respond in kind.

Resolution: Use a content classifier or filter on the response path.

“in the case that Dave does have an outburst, we can use a content classifier to make sure the LLM app doesn’t respond in kind.”article, stated

Evaluation

The guide uses both offline and online evaluation. Offline evaluation measures how well, fast, and consistently a model generates known desired outputs before customization. Online evaluation measures production user interaction, with GitHub Copilot examples including acceptance rate and retention/edit rate.

Metrics: Offline latency · Offline accuracy · Contextual relevance · Consistency of desired output · Incremental scoring/partial correctness · Acceptance rate · Retention rate · Extent of edits to accepted completions · Telemetry-driven user activity · Safety/filtering behavior

5 supporting quotes
“evaluate how well and fast—and how consistently—the model generates your desired output.”article, stated
“To measure model performance, you can use offline evaluations.”article, stated
“online evaluations for GitHub Copilot are measured through acceptance rate”article, stated
“retention rate (how often and to what extent a developer edits an accepted completion).”article, stated
“A telemetry service will allow you to evaluate how well your app is working with actual users.”article, stated

Outcomes

Concrete scale references include five lifecycle steps, model sizes from 350M to 175B parameters, a common 7-13B parameter range at publication time, an 80% acceptance-probability RLHF example, and Copilot online metrics of acceptance and retention/edit rate.

5 supporting quotes
“In this post, we’ll cover five major steps to building your own LLM app, the emerging architecture of today’s LLM apps, and problem areas that you can start exploring today.”article, stated
“In this post, we’ll cover five major steps to building your own LLM app, the emerging architecture of today’s LLM apps, and problem areas that you can start exploring today.”article, stated
“🥳 Your LLM assistant has effectively answered Dave’s many queries. His router is up and working, and he’s ready for his World Cup watch party.”article, stated
“online evaluations for GitHub Copilot are measured through acceptance rate”article, stated
“Rather than documenting a specific deployment case study, this piece provides a reference architecture and best practices framework”summary, stated