Scaling and Optimizing Self-Hosted LLMs for Developer Documentation

various · Tech · 2023 · source Agentic: no · promotional bias: low · source-backed · extracted with prompt 0.5.6 (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: Self-hosted LLM optimization, structured outputs, and document analysis

The session covered three production LLM scaling problems: self-hosting a documentation RAG assistant with acceptable latency, producing reliable structured outputs efficiently, and reducing manual public-comment analysis with hybrid NLP and LLM workflows.

Constraints:

Architecture

The Fuzzy Labs RAG stack uses FastAPI orchestration, a vector database, guardrails, and self-hosted Mistral 7B Instruct on AWS GPU instances, optimized with vLLM and Ray Serve after Locust benchmarking. Boundary's BAML improves structured-output reliability and token efficiency through generated parsers and data-model-aware prompts. SAS combines traditional text analytics, entity extraction, bucketing, and LLM summarization to shrink public-comment analysis effort.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  A["Developer query API"] --> B["Vector database"]
  A --> C["Guardrails service"]
  A --> D["Mistral model server"]
  D --> E["vLLM inference runtime"]
  D --> F["Ray Serve scaling layer"]
  C --> F
  B --> F
  G["BAML structured output layer"] --> H["Structured output consumers"]
  I["Text analytics preprocessor"] --> J["LLM summarizer"]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Developer query API FastAPI orchestration service receiving documentation questions. Vector database, Guardrails service, Mistral model server
Vector database Stores documentation embeddings and retrieves context for RAG answers. Developer query API, Mistral model server
Guardrails service Filters off-topic, harmful, competitor, stock-price, or proprietary-information requests. Developer query API
Mistral model server Self-hosted Mistral 7B Instruct inference service on AWS GPU instances. vLLM inference runtime, Ray Serve scaling layer
vLLM inference runtime Paged-attention inference runtime used to reduce latency and increase throughput. Mistral model server
Ray Serve scaling layer Horizontal serving layer for sharing GPUs and scaling model/guardrail/vector services. Mistral model server, Guardrails service, Vector database
BAML structured output layer DSL and parser layer for reliable structured outputs with fewer tokens. Structured output consumers
Text analytics preprocessor Traditional NLP layer that extracts entities, filters, and buckets public comments before LLM summarization. LLM summarizer
LLM summarizer Summarizes salient buckets of public comment statements. Text analytics preprocessor

Data flow

For the RAG assistant, developer questions pass through FastAPI, retrieval, guardrails, and a self-hosted Mistral model. Benchmarks identify latency and throughput bottlenecks, then vLLM improves per-GPU inference and Ray Serve shares/scales GPU-backed services. For structured outputs, BAML converts model text into typed data models. For public comments, text analytics filters and buckets statements before LLM summarization.

3 supporting quotes
“that query goes over to a orchestration service that's running on python well of course it is and we use fast API”transcript, stated
“we're doing retrieval augmented generation or or rag here”transcript, stated
“what bamel does is when you write code using baml we're able to generate a bunch of algorithms behind the scene”transcript, stated

Why this architecture

The session emphasizes measuring first, then optimizing at the right layer: self-hosting satisfied data constraints, vLLM and Ray Serve addressed inference/scaling bottlenecks, BAML addressed structured-output reliability and token cost, and classic NLP reduced the amount of text the LLM had to summarize.

3 supporting quotes
“always Benchmark you must Benchmark performance before even starting to optimize something”transcript, stated
“we can get that horizontal scaling and the vertical scaling together”transcript, stated
“when you can do things like let's say engineer a prompt on one side and simultaneously get the right data against that prompt on the other side”transcript, stated

Models used: Mistral 7B Instruct · guardrails classifier · LLMs for structured outputs · SAS information extraction model · LLM summarization model

Scale

Alternatives considered (roads not taken)

Hosted third-party LLM APIs for proprietary documentation

Rejected because: The customer did not want proprietary documentation shared with external parties.

“the main reason for wanting it to be self-hosted was that they did not want to share their data with other parties”transcript, stated

Plain Hugging Face pipelines plus FastAPI

Rejected because: The initial setup had very high latency and was effectively unusable beyond one user.

“with' just our hugging face um pipeline for for model inference plus fast API we got very high latency”transcript, stated

LLM-only public-comment summarization

Rejected because: Traditional text analytics can focus the LLM on the right buckets and statements first.

“we use information extraction before we have large language models to vectorize and create embeddings”transcript, stated

Patterns

rag-retrieval (retrieval)

The documentation assistant retrieves relevant docs and combines them with the developer's question before generation.

“I have a question I want data that might answer that question so I will find data which is related to my question”transcript, stated

latency-optimization (optimization)

The team benchmarked latency and throughput, then adopted vLLM and Ray Serve for vertical and horizontal scaling.

“what we found when we replaced these pipelines with VM was an improved latency and a slower growth rate”transcript, stated

structured-output-contract (interface)

BAML turns model output into typed structures and parsers, improving reliability and lowering token use.

“we took the data that came out of the model and we processed it into this actual data model that represents your resume data type”transcript, stated

safety-policy-enforcement (governance)

A separate guardrails model filters off-topic, competitor, harmful, and proprietary-information requests.

“we have guard rails um this was a customer for whom professional reputation was very important”transcript, stated

hybrid-search (retrieval)

SAS combines traditional text analytics, entity extraction, bucketing, and LLM summarization instead of using only one retrieval/generation method.

“introduced a combination of text analytics and large language models”transcript, stated

Tradeoffs

Deployment model

Chose self-hosted Mistral on GPU instances over third-party hosted model APIs.

Rationale: The customer needed to keep proprietary documentation in-house and learn internal LLM operations.

“they did not want to share their data with other parties lots of propriatary stuff there”transcript, stated

Optimization order

Chose benchmark before optimizing over premature tuning.

Rationale: Load tests exposed actual bottlenecks and informed whether vertical or horizontal scaling mattered.

“always Benchmark you must Benchmark performance before even starting to optimize something”transcript, stated

Public-comment analysis design

Chose traditional NLP filtering plus LLM summarization over manual review or raw LLM summarization over everything.

Rationale: Bucketing and statement extraction focus the LLM on relevant subsets and reduce manual effort.

“use text analytics to essentially filter okay here's a comment it belongs in this particular bucket”transcript, stated

Gotchas (what bit them)

Self-hosted RAG was unusable without inference optimization.

Root cause: Plain Hugging Face inference plus FastAPI produced high latency and failed at low concurrency.

Resolution: Benchmark first, then adopt vLLM and Ray Serve.

“this is unusual usable for more than one user and even the one user isn't getting a great experience”transcript, stated

Production LLM stacks may contain multiple models that all need scaling.

Root cause: The RAG assistant used both a main LLM and a guardrails model, plus vector operations.

Resolution: Use a serving layer that can share GPUs and scale several services.

“there's a second model kind of hidden here we won't talk about scaling that but just to note we're not just scaling a langage model”transcript, stated

Structured outputs can be unparsable even when the text looks reasonable.

Root cause: Models do not naturally emit reliable typed data without a contract/parser layer.

Resolution: Use BAML to generate parsing algorithms and data-model-aware prompts.

“we're still streaming all the date out even though this is technically totally unparsable and garbage”transcript, stated

Evaluation

The session evaluates systems through Locust load testing, latency, throughput, request rate, failure-point testing, structured-output parsing/token metrics, and manual-hour reduction.

Metrics: latency · tokens per second · successful requests per minute · concurrent users · failure point · token count · manual hours reduced

“we also measured three different metrics one was latency”transcript, stated
“system throughput was a second metric so how many tokens are we outputting per unit time per second”transcript, stated

Outcomes

The session spans infrastructure-scale RAG, structured-output token efficiency, and public-comment workloads with tens of thousands of statements.

“the number of gpus we need Remains the Same”transcript, stated
“going from 4500 hours the closest closer to 600 hours”transcript, stated