Book a free call

How to Implement a Foundation Model Step by Step

Implementing a foundation model means picking a model, grounding it in your own data, wiring it into a product and measuring it on real tasks before users see it.

Hertiv engineering teamReviewed by a senior engineer
6 min read
How to Implement a Foundation Model Step by Step
On this page

Short answer

A foundation model is a large pre-trained model you adapt to your product instead of training one from scratch. To implement it, pick a model that fits your task and budget, ground it in your own documents, add guardrails and evaluation, and ship behind a human review step so a bad answer is caught before it reaches a user.

What is a foundation model?

A foundation model is a large model trained on broad data that can be adapted to many tasks, such as writing, summarising, classifying and answering questions, without training a new model for each one.

Common examples are large language models and image models. You use them through an API or by hosting a copy, and you shape their behaviour with prompts, retrieved documents, fine-tuning or a mix of all three.

The model itself is not your product. Your product is the task around it: the data it reads, the rules it follows, the checks on its output and the way it fits into a workflow people already use.

That distinction matters because most implementation failures are not model failures. They come from poor data, missing evaluation and no fallback when the model is wrong. For the cost side, see foundation model cost before you pick a model.

When does a foundation model fit your product?

A foundation model fits when the task needs language or pattern understanding that rules alone cannot provide, and when a human or a system already checks the output before it matters.

Option When it fits Effort Risk
Use an API model Fast start, changing needs Low Cost scales with use
Host an open model Data must stay in-house Medium You run the servers
Fine-tune a model Consistent tone or format Medium Needs labelled data
Rules only Fixed answers, strict logic Low Cannot handle new phrasing
Train from scratch Truly novel capability Very high Cost and time

Most products start with an API model plus retrieval over their own documents. That combination is fast to build and easy to change, and it is enough for support, search, drafting and summarising.

Fine-tuning is worth it when you need a consistent format or tone at scale, or when the model must follow a strict style. It is rarely the first step, because it needs labelled examples and an evaluation set to prove it helped.

How do you choose the right model?

You choose a model by testing it on your own tasks, not by reading a vendor benchmark. A model that scores well on general tests can still fail on your documents, your tone or your edge cases.

Build a small evaluation set first: twenty to fifty real inputs with known good outputs. Run each candidate model on the same set and score the answers by hand. That one exercise tells you more than any leaderboard.

Then check the practical constraints. What does a single call cost at your expected volume? How fast is it? Can it run where your data is allowed to live? Does it support the languages your users write in?

Also check the licence and the data rules. Some models may not be used for certain purposes, and some API providers keep prompts for training unless you opt out. Read the terms before you build on a model.

How do you implement a foundation model?

You implement a foundation model by building a narrow path from a user request to a checked answer, then widening it once the checks hold up in practice.

  1. Define one task. Pick a single workflow with a clear input, a clear output and a human who reviews the result.
  2. Prepare the data. Clean the documents the model will read, remove duplicates and old versions, and set access rules.
  3. Build retrieval. Index the documents so the model gets the right passages with each request, and cite them in the answer.
  4. Write the prompt and the rules. State what the model should do, what it must not invent, and when it must say it does not know.
  5. Add an evaluation set. Run the same real cases after every change and record the score, so you can see whether a change helped.
  6. Ship behind review. Let a human approve output first, log every request and answer, and add a kill switch before you go live.

Keep the model call behind your own service, not inside the user interface. That way you can change models, add logging and enforce limits without shipping a new client.

Teams that need help scoping this work often start with an AI proof of concept on one workflow, with a fixed evaluation set and a clear success threshold.

Example (hypothetical): a support assistant for a parts supplier

Example (hypothetical): a parts supplier gets 500 support tickets a day, mostly asking which part fits a machine and how long delivery takes. The team builds an assistant that reads the parts catalogue and the delivery rules, then drafts answers for human agents to approve.

They start with an evaluation set of 100 past tickets with known good answers. The first version answers 82 of 100 correctly, and the failures are mostly cases where two parts share a name. The team adds a clarification step that asks which machine the part is for, and the score rises to 94 of 100.

At 500 tickets a day, the assistant costs about $0.004 per call, which is $2 a day, or about $60 a month. The agents save roughly 3 minutes per ticket, which is 25 hours a day across the team, and they spend that time on the tickets the assistant cannot handle.

The team also logs every draft and every human edit, so when the catalogue changes they can see which answers went stale. That log is what lets them improve the assistant instead of guessing.

How do you keep the model accurate and safe?

You keep a foundation model accurate by grounding it in your own documents and by checking its output against a fixed evaluation set after every change.

Grounding means the model answers from retrieved passages, not from memory. If the answer cannot be traced to a document, it should say so. That single rule removes most invented facts, because the model is no longer free to fill gaps with plausible text.

Safety needs the same discipline. Set rules for what the model may not do, such as giving legal or medical advice, sharing personal data or making promises. Add a filter for harmful output, and route sensitive topics to a human.

Watch the cost as well. Log every call with its token count and price, and set alerts for sudden jumps. A prompt that grows with each new feature can quietly double the bill, as the foundation model cost guide explains.

What are the common mistakes?

The most common foundation model mistakes are skipping the evaluation set, letting the model answer from memory, and giving it write access before the checks exist.

  • No evaluation set. Without fixed test cases, quality debates are anecdotal and every change is a guess.
  • No grounding. A model that answers from memory will invent details that sound right, and nobody can trace them.
  • Too broad a first task. A general assistant with no owner and no success metric drifts, while one narrow workflow ships.
  • Prompts that grow without review. Each added instruction changes behaviour, and nobody re-tests the old cases.
  • Write access without approval. A model that can change records or send messages needs a human gate and a full log.
  • Ignoring cost per call. A feature that looks cheap in testing can cost far more at real volume.

For the definition and the comparison with smaller models, see what is a foundation model.

For the ongoing cost of running models in production, see LLMOps cost.

Key takeaways

  • The product is the task around the model, not the model itself
  • Ground answers in your own documents so they can be traced and checked
  • Build an evaluation set before the prompt, and re-run it after every change
  • Ship behind human review with logging and a kill switch
  • Fine-tuning is for consistent format or tone, not for a first version

Frequently asked questions

Do I need to fine-tune a foundation model?

Usually not at first. Retrieval over your own documents plus a clear prompt handles most support, search and drafting tasks. Fine-tuning helps when you need a consistent format or tone at scale, and it is easier to justify once you have an evaluation set.

How much data do I need to implement a foundation model?

You need a sample of real inputs with known good outputs, plus the documents the model will read. Twenty to fifty test cases are enough to start, and the source documents matter more than the volume: clean, current content beats a large stale archive.

Should I use an API model or host my own?

An API model is faster to start and easier to change, while hosting gives you control over where data lives and how the model runs. Choose hosting when data rules require it or when call volume makes the API cost too high at scale.

How do I stop the model from inventing facts?

Ground it in retrieved documents and require the answer to cite them. If the answer cannot be traced to a source, the model should say it does not know. Add an evaluation set with questions that have no answer in your data, and check that the model refuses them.

How long does implementation take?

A narrow proof of concept typically takes a few weeks when the data is ready. Moving to production adds integration, evaluation, logging and change management, which usually take longer than the model work itself.

What should I measure after launch?

Measure one outcome per workflow, such as answer accuracy on the evaluation set, time saved per task, or the share of drafts a human edits. Track it on the fixed evaluation set so that changes are comparable over time.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: AI and agent systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Planning to put a foundation model into your product? Talk to Hertiv.

A senior engineer replies within one business day. Or see our LLM Development service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to [email protected].

Prefer email? Write to [email protected]
Estimate costBook a call