Ibnovate Course 3 · The Future Builders
⏱ 75 minLive session

Session 7 — Build with Pre-trained Models

Duration: 75 min · Format: live online

What you'll learn: by the end, you can load a pre-trained transformer in a few lines with Hugging Face, run four different language tasks on your own text, and explain the idea of standing on giants' shoulders — plus you'll get a first taste of fine-tuning a model to your own needs.

Soft skill focus — Problem-solving

Today you'll also grow Problem-solving. A pro doesn't build everything from scratch — they ask "has someone already solved most of this?" and assemble the answer. Today you'll solve real language problems by picking the right pre-built tool and wiring it up — the single most valuable habit in applied AI.

What you'll need

Hook

It took a company millions of dollars and billions of words to train a good language model. Here's the wonderful part: they gave it away. On Hugging Face there are hundreds of thousands of pre-trained models you can download and use for free, in three lines of code.

That means you don't start from zero. You start from a model that has already read more text than you could in a thousand lifetimes — and you point it at your problem. This is standing on the shoulders of giants, and it's how almost all real-world AI gets built today. Let's build.

Teach — What a pipeline is

A Hugging Face pipeline is a ready-made wrapper that hides all the messy steps — tokenising your text, running the transformer, decoding the numbers back into an answer. You just name the task, and it fetches a suitable model and runs it.

Using a pre-trained model: feed in text, a downloaded model processes it, and you get an answer

The pattern is always the same three moves:

  1. Feed in your text.
  2. A downloaded model processes it (the transformer from Session 6, already trained).
  3. You get an answer back — a label, a summary, an extracted phrase.

Because the model is pre-trained, you write no training code and need no dataset to get started. First run downloads the model (slow, once); after that it's instant.

Teach — Four tasks, one pattern

The same pipeline gives you many superpowers just by changing the task name:

Notice the theme: you're not teaching a model anything yet. You're reusing models others trained, choosing the one whose job matches yours.

⚠ Watch out: a pre-trained model reflects the data it was trained on — usually general web and news text, mostly English. On slang, other languages, medical or legal text, or your niche topic, it can be confidently wrong. Always eyeball the output before you trust it, and never ship a model into something important without testing it on your real data.

Activity — Solve four problems with pre-trained models

Open a new Colab notebook. First, install the library.

Type and run this once (the install):

!pip install -q transformers

Task 1 — Sentiment. Feed in text, get a label:

from transformers import pipeline

sentiment = pipeline("sentiment-analysis")
for text in ["I absolutely loved this movie!", "The food was cold and slow."]:
    r = sentiment(text)[0]
    print(f"{r['label']:8s} ({r['score']:.2f})  <-  {text}")

Task 2 — Summarization. Shrink a long passage. Replace article with your own:

summariser = pipeline("summarization")
article = """Honeybees communicate the location of food using a waggle dance.
The angle of the dance shows the direction relative to the sun, and the length
of the waggle shows the distance. Other bees watch, then fly straight to the food."""
print(summariser(article, max_length=30, min_length=10)[0]["summary_text"])

Task 3 — Question-answering. Give it a context and ask:

qa = pipeline("question-answering")
context = "The Eiffel Tower is 330 metres tall and was completed in Paris in 1889."
print(qa(question="How tall is the Eiffel Tower?", context=context)["answer"])
print(qa(question="When was it completed?", context=context)["answer"])

Task 4 — Zero-shot (the magic one). Invent your own labels:

classifier = pipeline("zero-shot-classification")
result = classifier(
    "My laptop won't turn on and the screen stays black.",
    candidate_labels=["billing", "hardware problem", "compliment"]
)
print(result["labels"][0], "->", round(result["scores"][0], 2))

Now experiment:

  1. Paste your own paragraph into the summariser. Is the summary fair?
  2. In Task 4, add a label the text clearly isn't about. Does the model still rank the right one first?
  3. Try to break the sentiment model — write a sarcastic sentence ("Oh, brilliant, another delay"). Does it get fooled?

You just solved four different language problems without training a single thing.

Teach — A taste of fine-tuning

Pre-trained models are generalists. Sometimes you need a specialist — a model that knows your domain (your product reviews, your school's subjects, your language). That's fine-tuning: take a pre-trained model and continue training it a little on your labelled examples, so it adapts without forgetting everything it learned.

The beauty is you need far less data than training from scratch — the model already understands language; you're just nudging it toward your task. You won't full fine-tune today, but keep the mental model: pre-trained = a smart generalist; fine-tuned = that generalist, specialised to you. It's the natural next step when a stock pipeline is close but not quite right.

Check yourself

  1. What are the three moves of using a pipeline?Feed in text → a pre-trained model processes it → you get an answer.
  2. Why is using a pre-trained model called "standing on giants' shoulders"? → You reuse a model that already learned from billions of words, instead of training from zero.
  3. What is fine-tuning? → Continuing to train a pre-trained model on your own examples so it specialises to your task, using far less data.

Wrap-up

You've gone from understanding transformers to wielding them. Four lines of code now buy you sentiment, summaries, answers and custom classification — because someone else did the expensive part and shared it. Real AI engineering is mostly this: pick the right pre-trained model, test it on your data, and only train when you truly must.

Tips & extra challenges

Vocabulary

Term Meaning
Pre-trained model A model already trained on huge data, ready to reuse
Pipeline A Hugging Face wrapper that runs a task end-to-end in a few lines
Task The job you want (sentiment, summarization, QA, zero-shot…)
Zero-shot Classifying into labels you invent, with no task-specific training
Fine-tuning Further training a pre-trained model on your own data to specialise it

Resources

Practice set

Practise on your own — work these easy → hard. Answers follow each arrow.

1. Name the flow. What are the three stages of using a pre-trained model? → Feed in text → model processes it → get an answer.

2. Pick the task. You want to sort support emails into "refund", "bug", "praise" with no training data. Which pipeline? → zero-shot-classification — you supply your own candidate labels.

3. Spot the cost. Why is the first pipeline call slow but later ones fast? → The first call downloads the model; after that it's cached locally and runs instantly.

4. Reason about fit. A general sentiment model does badly on medical notes. What's a fix, and why does it need little data? → Fine-tune it on labelled medical text; it already understands language, so you only nudge it toward the new domain.

5. Write the code (harder). Write the two lines that build a summarization pipeline and print a summary of a string text. → summariser = pipeline("summarization") then print(summariser(text)[0]["summary_text"]). (Any correct equivalent earns it.)

Going deeper (optional)

Optional — for when you wonder how one library serves a hundred thousand models.

Why does the same pipeline call work for so many models? Hugging Face standardised the interface. Every model on the hub ships with a matching tokenizer (turns your text into the exact tokens that model expects) and a config (its shape and task type). When you name a task, the pipeline looks up a default model, downloads its weights, tokenizer and config together, and wires them into the feed-in → process → answer flow. That standardisation is the real breakthrough of the ecosystem: because everyone follows the same format, swapping one model for a better one is often a single string change — which is exactly what lets you experiment fast and stand on ever-taller shoulders.

Common mistakes & fixes

What's next

Session 8 — Building with LLMs: pipelines run on your machine and do one task each. Next you'll call a full large language model through an API — keeping your key private — learn pro prompt-engineering patterns, and use RAG to ground the model's answers in real documents so it stops making things up. You'll build a small, responsible AI assistant of your own.

Ibnovate · Build · Innovate
Type to search · Esc to close
Welcome back
Sign in to continue building.
Accounts are created by Ibnovate — ask your instructor for your login.
🔒