# AI Infrastructure

> Inference pipelines, RAG architectures and data pipelines for AI systems in production, built to run reliably and keep costs predictable.

Page: https://www.leafcompute.com/services/ai-infrastructure

## Moving an AI prototype into production

Getting a language model to produce impressive output in a notebook is quick. Serving that same model to many concurrent users with consistent latency, reasonable cost and reliable outputs takes a lot more infrastructure work.

We run infrastructure for an AI web-data platform that serves 18–25M API requests a day. The patterns that work in production look nothing like the quickstart tutorials.

## What we build

### Inference infrastructure

For model serving at scale, we work on:

- **GPU orchestration:** scheduling inference workloads across GPU instances, managing cold starts and balancing cost against latency SLAs.
- **Batching:** dynamic batching that groups requests to maximize throughput without exceeding latency budgets.
- **Model versioning:** deploying new model versions with canary routing, A/B testing responses, and automated rollback when quality metrics degrade.
- **Multi-model serving:** running several models on shared infrastructure and routing each request by complexity, cost and capability.

We aim for predictable performance at a manageable cost. In practice that means pricing every model call before it ships and sending clear cases to cheaper paths, without lowering response quality.

### RAG architectures

Retrieval-augmented generation is often the most practical pattern for production AI systems that need to work with proprietary data. The RAG pipelines we build cover:

- **Retrieval speed:** optimized vector indexes and hybrid search that combines semantic and keyword matching.
- **Accuracy:** chunking tuned to your content, re-ranking models that put the most relevant context first, and evaluation that catches retrieval failures before users do.
- **Upkeep:** automated ingestion that keeps your knowledge base current, version-controlled embedding configurations, and monitoring of retrieval quality over time.

### Data pipelines

The data pipelines behind an AI system need to:

- **Ingest reliably:** handle schema changes, partial failures and late-arriving data without manual intervention.
- **Transform efficiently:** compute features with the right tool for each job, using stream processing for real-time features and batch processing for historical ones.
- **Serve consistently:** use feature stores that give the same feature values in training and inference, which removes the training-serving skew that silently degrades model performance.

### Cost management

AI infrastructure costs can rise fast, because GPU instances are expensive and inference costs grow with traffic. We build cost tracking and controls into the system from the start:

- **GPU right-sizing:** matching instance types to model requirements and using spot instances for batch workloads.
- **Caching:** semantic caching that answers identical or near-identical requests from cache instead of running inference again.
- **Model distillation:** where it fits, training smaller models that approximate the behavior of larger ones at a much lower inference cost.
- **Usage monitoring:** dashboards that show cost per request, per user and per feature, so your team can make informed trade-offs.

## How we start

We start with the problem, before choosing a model: what your product needs the AI system to do, what latency is acceptable, what your budget per inference is, and what happens when the model gets it wrong.

Those constraints shape every infrastructure decision. A real-time recommendation system has very different requirements from a batch document processing pipeline, and using the same architecture for both usually leaves you with a system that's too expensive for one and too slow for the other.

## Models and providers

We are model-agnostic and cloud-agnostic, and choose between:

- **Open-source models** (Llama, Mistral) on self-hosted GPU infrastructure, for teams that need data privacy or cost control
- **API providers** (OpenAI, Anthropic, Google), for teams that want to move fast and can accept the vendor dependency
- **Hybrid architectures** that route different request types to different providers based on complexity, cost and latency requirements

Which of these fits depends on the constraints above.

## Common questions

### Should we use an API provider or host open-source models ourselves?

It depends on your constraints. API providers such as OpenAI, Anthropic and Google suit teams that want to move fast and can accept the vendor dependency. Self-hosted open-source models such as Llama and Mistral suit teams that need data privacy or cost control. Many systems end up hybrid, with each request type routed by complexity, cost and latency.

### How do you keep inference costs under control?

We price every model call before it ships and track cost per request, per user and per feature. The main levers are caching repeated requests, sending clear cases to cheaper paths, right-sizing GPU instances, spot capacity for batch work and, where it fits, a smaller distilled model.

### Do we need RAG or fine-tuning?

For systems that have to work with your own data, retrieval-augmented generation is often the most practical place to start. We tune chunking to your content, add re-ranking, and set up evaluation that catches retrieval failures before users do.

### What do you need from us to start?

Four answers: what the AI system has to do for your product, what latency is acceptable, your budget per inference, and what happens when the model gets it wrong. Those shape every infrastructure decision.

### Have you run AI workloads at scale?

Yes. We run infrastructure for an AI web-data platform that serves 18 to 25 million API requests a day.

---
Leaf Compute: https://www.leafcompute.com · hello@leafcompute.com
