Building A Generative AI Platform
- Source
- huyenchip.com
- Publisher
- Chip Huyen
- Author
- Chip Huyen
- Date

Context
Choosing a model and connecting to it are separate responsibilities in an AI application. Chip Huyen's platform guide calls the selection component a router and the common connection layer a gateway. A router can send a request to an appropriate model, a help page or a human, depending on the task.
The gateway gives applications a consistent way to reach different models and a central place for access controls and usage limits. When a provider changes its interface, that connection can be updated centrally. This supplies the operational machinery around ideas such as query-specific model selection.
- Keyword retrieval (BM25, Elasticsearch) is far cheaper and faster than and is a formidable baseline alone. The common production pattern is hybrid: a cheap term-based pass fetches candidates, then a costlier embedding step reranks them.
- construction is to foundation models what feature engineering was to classical ML. It is also how a model stays current: one trained through last week cannot answer about this week unless this week is in the context.
- Document order matters less in RAG than in search ranking. Models do read the start and end of a context better than the middle, but whether a document made it in at all matters far more than where it landed.
- Structured data takes a different path than documents: turn the question into , execute it, then generate an answer from the rows. If more table schemas exist than fit in context, add a step that first predicts which tables the query needs.
- Judge a vector index on four numbers, not one: recall, queries per second, build time, and index size. Build time is the forgotten one, and it decides whether you can re-index as fast as your data changes.
- Model selection — Choosing a model using workload evidence and operating constraints.
- Vector search — Finding content by similarity between embeddings.
- Context and context window — Context is the information available for a generation; the context window is the capacity available to hold it.
- Database and SQL — Persistent structured storage queried and changed through explicit operations.
“Context construction for foundation models is equivalent to feature engineering for classical ML models.”
“Combining term-based retrieval and embedding-based retrieval is called hybrid search .”
“You can think of prompt injection as social engineering done on AI instead of humans.”
“Just as you shouldn't give an intern the authority to delete your production database, you shouldn't allow an unreliable AI to initiate bank transfers.”





