Epitomsoft Academy · Module 3 of 6

Building with frontier models

Hands-on with today’s leading AI models – OpenAI, Anthropic Claude, Google Gemini and open models like Llama: prompting, RAG, fine-tuning basics, evaluation and cost control.

What you will learn

From prompt to production-quality AI feature

Frontier models are powerful but need careful engineering to be reliable. You will learn the techniques professional AI engineers use every day – and practise them with free, open-source tools.

  • Write clear, structured prompts that produce consistent results
  • Build retrieval-augmented generation (RAG) over your own documents
  • Decide when to prompt, retrieve or fine-tune
  • Run open models locally and compare them with hosted APIs
  • Evaluate quality and control cost and latency

Module at a glance

  • Format: live online sessions + hands-on lab
  • Level: Intermediate
  • Prerequisites: Modules 1–2; Python
  • You will build: A document Q&A assistant with citations and an evaluation suite

Topics

Key concepts, explained with examples

Prompt engineering that works

Give the model a role, clear instructions, the needed context, examples (few-shot) and an exact output format.

Example: Instead of “summarise this”, ask for “three bullet points for a busy executive, each under 20 words, in JSON with fields point and impact”.

Structured outputs

Ask for JSON that matches a schema so your application can use results reliably, and validate it in code.

Example: Extracting {“invoice_no”: “INV-221”, “total”: 1240.50, “due”: “2026-11-30”} from a scanned invoice.

Retrieval-augmented generation (RAG)

Store documents as embeddings, retrieve the most relevant passages for each question, and ask the model to answer only from them – with citations.

Example: An HR assistant answers “How many leave days do I get?” by quoting section 4.2 of the employee handbook.

Choosing a model

Balance quality, speed, cost, context length, privacy and licence. Use larger models for hard reasoning and smaller ones for simple, high-volume tasks.

Example: Route simple FAQ questions to a small, cheap model; send complex contract analysis to a frontier model.

Open models and local inference

Open-weight models such as Llama, Mistral and Gemma can run on your own hardware for privacy and cost control.

Example: A clinic prototypes a note-summariser that runs entirely on a local machine, so patient data never leaves the building.

Fine-tuning basics

Fine-tuning adapts a model’s style or format with your examples. It rarely adds reliable new knowledge – use RAG for that.

Example: Fine-tune a small model on 1,000 examples of your support team’s tone, while facts still come from the knowledge base.

Evaluation (evals)

Create a test set of real questions with expected answers and score every change automatically, like unit tests for AI.

Example: After changing the prompt, 46 of 50 test questions pass instead of 41 – a measurable improvement.

Cost and latency

Costs scale with tokens. Caching, shorter prompts, smaller models and streaming responses keep apps fast and affordable.

Example: 10,000 questions a day × 2,000 tokens each = 20 million tokens/day – trimming the prompt by 30% cuts the bill by about 30%.

Worked example

A local open model and a mini RAG pipeline

Run an open-source model on your own computer and ground its answers in your documents.

Example 1 – Run an open model locally with Ollama

# 1. Install Ollama (open source, https://ollama.com) and download an open model
ollama pull llama3.2

# 2. Ask it a question through the local REST API
curl http://localhost:11434/api/generate -d '{
  "model": "llama3.2",
  "prompt": "Explain retrieval-augmented generation in two sentences.",
  "stream": false
}'

Example 2 – Retrieval: find the right passage before asking the model

# pip install sentence-transformers
from sentence_transformers import SentenceTransformer, util

model = SentenceTransformer("all-MiniLM-L6-v2")      # small open-source embedding model
docs = [
    "Employees receive 15 days of paid leave per year.",
    "Remote work is allowed up to 3 days a week.",
    "Expense claims must be submitted within 30 days.",
]
doc_vecs = model.encode(docs, convert_to_tensor=True)

question = "How many vacation days do I get?"
scores = util.cos_sim(model.encode(question, convert_to_tensor=True), doc_vecs)[0]
context = docs[int(scores.argmax())]                  # retrieve the best match

prompt = f"Answer ONLY from this context and cite it.\nContext: {context}\nQuestion: {question}"
print(prompt)   # send this prompt to any model - local or hosted

Hands-on lab

Build “Ask the Handbook”

You build a question-answering assistant over a real public document set (for example, your college’s student handbook) and prove its quality with evals.

  • Chunk and embed the documents into a vector database (e.g. pgvector)
  • Build retrieval + answer generation with citations
  • Compare an open local model with a hosted frontier model
  • Write 30 evaluation questions and score accuracy with an open-source eval tool
  • Report quality, cost per 1,000 questions and latency

Key terms

Vocabulary to master

  • Prompt
  • System prompt
  • Few-shot
  • Structured output
  • JSON Schema
  • RAG
  • Chunking
  • Vector database
  • Cosine similarity
  • Open-weight model
  • Fine-tuning
  • LoRA
  • Evals
  • Latency
  • Token cost

Check your understanding

Module 3 quiz

Score 70% or more to pass. Pass all six module quizzes to unlock your Frontier AI certificate on My progress.

Further learning

Free & open-source references

Original research, open-source projects and free courses – all free to access.

Ready to master frontier AI?

Join the Epitomsoft Academy advanced programme – tell us about yourself and we will be in touch.