Scaling Chatbot Platform with Hybrid LLM and Custom Model Approach

voiceflow · 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: Hybrid conversational AI platform with LLM and custom model workloads

Voiceflow needed to add generative AI features to a chatbot/voice assistant platform while preserving low-latency, low-cost custom NLU for intent and entity tasks.

Constraints:

Architecture

Voiceflow built an ML Gateway that exposes a unified interface over custom language models and third-party LLM providers such as OpenAI, Azure OpenAI, Anthropic Claude, and Claude Instant. The gateway handles prompt validation, rate limiting, usage tracking, and provider abstraction. Voiceflow kept custom self-hosted NLU for core intent/entity workloads, used provider APIs for generative features, added regex/prompt handling for JSON, benchmarked provider latency, and refactored custom-model serving when Pub/Sub caused p99 spikes.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  A["Voiceflow product features"] --> B["ML Gateway"]
  B --> C["Provider LLM APIs"]
  B --> D["Custom NLU model service"]
  B --> E["Prompt validation layer"]
  B --> G["Usage tracking"]
  C --> F["JSON parsing cleanup"]
  F --> A
  D --> H["Redis queue"]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Voiceflow product features Creation-time and runtime chatbot-building features that need model capabilities. ML Gateway
ML Gateway Unified model service for custom LMs and third-party LLM APIs. Provider LLM APIs, Custom NLU model service, Prompt validation layer, Usage tracking
Provider LLM APIs OpenAI, Azure OpenAI, Anthropic Claude, and Claude Instant endpoints for generative tasks. ML Gateway, JSON parsing cleanup
Custom NLU model service Voiceflow-hosted intent/entity model for core conversational NLU. ML Gateway, Redis queue
Prompt validation layer Validates generative prompts before model calls. ML Gateway
JSON parsing cleanup Prompt engineering, regex, and handwritten rules for malformed generated JSON. Provider LLM APIs, Voiceflow product features
Usage tracking Tracks model usage for cost, rate limits, and production visibility. ML Gateway
Redis queue Refactored lower-latency queue closer to the application layer for custom NLU serving. Custom NLU model service

Data flow

Creation-time and runtime product features call the ML Gateway. The gateway routes custom NLU requests to Voiceflow-hosted models and generative requests to provider APIs, applying prompt validation, rate limiting, and usage tracking. Outputs are parsed and cleaned when needed, while latency and cost benchmarks guide provider/model choices.

3 supporting quotes
“it's called ml Gateway it basically connects with our services and for each of our models we have an endpoint and a service”transcript, stated
“then we do some prompt validation rate limiting and usage tracking”transcript, stated
“we have chat GPT Azure chat GPT and we tried out Claude and Cloud instant”transcript, stated

Why this architecture

Voiceflow uses LLM APIs for flexible generative capabilities while keeping specialized NLU in-house because the custom model is faster, cheaper, and more accurate for their core intent/entity workload.

3 supporting quotes
“we've chosen to use an API and that's how we integrated it”transcript, stated
“we invested in that language modeling capability because it was core to our business”transcript, stated
“our nlu model still outperforms gpt4 in this one test that we did both on cost and on accuracy”transcript, stated

Models used: OpenAI ChatGPT · Azure ChatGPT · Anthropic Claude · Claude Instant · Voiceflow custom NLU model · GPT-4

Scale

Alternatives considered (roads not taken)

Self-host LLMs for generative features

Rejected because: Self-hosting LLM research/infrastructure was not core to Voiceflow's business.

“infrastructure because it's not core to our business our core to our business is giving these supportive features to our customers”transcript, stated

Use GPT-4 for custom NLU tasks

Rejected because: The custom NLU model outperformed GPT-4 on accuracy and cost for Voiceflow's specific task.

“our nlu model still outperforms gpt4 in this one test that we did both on cost and on accuracy”transcript, stated

Keep Pub/Sub serving for latency-sensitive custom NLU

Rejected because: Pub/Sub caused high p99s even though the model itself had stable low latency.

“with this Pub sub architecture for for our language model right we were getting too high p99s”transcript, stated

Patterns

model-routing (model-ops)

Voiceflow routes tasks through an ML Gateway to custom NLU or third-party LLM providers depending on workload fit.

“we use the same service for integrating it because we already built it out”transcript, stated

cost-aware-routing (optimization)

Custom NLU remains in-house because GPT-4 is far more expensive for the same core task.

“it costs a thousand times more than than our model to actually do inference on”transcript, stated

structured-output-contract (interface)

Generated JSON required prompt engineering plus regex/handwritten cleanup rules.

“we use large language models to generate Json and that takes some time um to figure out exactly what the format is”transcript, stated

latency-optimization (optimization)

Provider benchmarks and serving refactors addressed inconsistent latency and p99 spikes.

“we decided to Benchmark it and think through okay are we offering Azure chat GPT here or just regular chat GPT”transcript, stated

Tradeoffs

Generative feature integration

Chose third-party LLM APIs through ML Gateway over self-hosted LLM infrastructure.

Rationale: Voiceflow wanted to focus on platform features rather than LLM research and hosting.

“our core to our business is giving these supportive features to our customers rather than doing the research and self-hosting side of things”transcript, stated

Core NLU workload

Chose self-hosted custom NLU model over GPT-4 for intent/entity detection.

Rationale: The custom model was more accurate, lower latency, and dramatically cheaper for the task.

“latency is quite High um that that's one of the challenges the other thing is that the accuracy and the cost just don't make sense”transcript, stated

Gotchas (what bit them)

LLM JSON output was messy.

Root cause: Generative models did not reliably produce clean JSON formats.

Resolution: Add prompt engineering, regex, handwritten rules, and tests around format handling.

“these models don't produce the cleanest stuff right so we have to implement some prompt engineering to fix this even then it wasn't great”transcript, stated

Provider latency varied enough to affect product decisions.

Root cause: OpenAI-style APIs had inconsistent latency and p99s across providers.

Resolution: Benchmark Azure ChatGPT versus regular ChatGPT and choose lower-variance providers where appropriate.

“there's a lot of fluctuation between latency”transcript, stated

A serving architecture designed for one model class failed for another.

Root cause: The Pub/Sub design worked for earlier workloads but produced high p99s for latency-sensitive NLU.

Resolution: Refactor to Redis closer to the application layer.

“it worked great until it didn't so then we had to do a refactor and a re-architecture”transcript, stated

Evaluation

Voiceflow evaluates through provider latency benchmarks, p50/p99 serving metrics, cost comparisons, accuracy tests against custom NLU, and production fit by use case.

Metrics: latency · p50 latency · p99 latency · standard deviation · inference cost · NLU accuracy

“we decided to Benchmark it and think through okay are we offering Azure chat GPT here or just regular chat GPT”transcript, stated
“our nlu model still outperforms gpt4 in this one test that we did both on cost and on accuracy”transcript, stated

Outcomes

The case emphasizes production routing and serving metrics rather than end-user volume; the clearest scale signal is the cost gap between GPT-4 and a custom model at production inference volume.

“it costs a thousand times more than than our model to actually do inference on”transcript, stated