Cert EspressoLearn. Practise. Find your flow.

A LITTLE FOCUS.
A BIG NEXT STEP.

Your pace. Your space.
Oracle · OCI AI Foundations

Customizing an LLM

OCI AI Foundations · Lesson 9 of 16 · 56:59

YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗

Learning with these videos? Subscribe for new courses and exam-style questions.

In this lesson

Prepare for the Oracle Cloud Infrastructure AI Foundations Associate exam (1Z0-1122-26). In this lesson: three ways to customize an LLM (prompt engineering, RAG, and fine-tuning) and how to choose between them, fine-tuning on OCI (JSONL training data in Object Storage, a fine-tuning dedicated AI cluster, a hosting cluster and endpoint, T-Few, Vanilla, and LoRA), and training settings and results (epochs, learning rate, batch size, early stopping, loss, accuracy, and overfitting). Includes three original practice questions, with Willowmere Motors, a fictional network of car dealerships and repair shops, as the example.

Study notes

The text of this lesson, to read at your own pace. Information as of November 2026.

Two needs

Willowmere has two new requests for its assistant. First, answer questions about the cars in stock, whose list and prices change every day. Second, write every repair summary in Willowmere's exact house format, which even the best prompts have not managed to get right.

Three ways to customize

There are three main ways to adapt a language model to your needs. Prompt engineering is the quickest: you change only the prompt, with no training, and it works when the model already knows enough about the topic. Retrieval-augmented generation, or RAG, looks up relevant data in your own sources at request time, and adds it to the prompt, so answers stay current and grounded, which also reduces hallucinations, but you need a data source that the service can search. Fine-tuning trains a pretrained model further on your own labeled examples, which changes its weights: it teaches a style, a tone, a format, or a task that the model does poorly, but it needs a labeled data set, and it costs time and compute.

Choosing a method

Think of two directions. If the model lacks knowledge, or the data changes often, optimize the context: that's RAG. If the model does not behave the way you need, in style, format, or skill, optimize the model itself: that's fine-tuning. A good path starts with prompt engineering, adds RAG for knowledge, and fine-tunes only when good prompts are not enough, and the methods can be combined. Fine-tuning has two extra benefits: better results on the task, and more efficiency, because shorter prompts, or even a smaller model, can do the job.

Fine-tuning on OCI

On OCI Generative AI, fine-tuning follows a few steps. You prepare the training data as a JSONL file, with one example per line, each made of a prompt and the completion that you expect, and you upload it into Object Storage. A dedicated AI cluster for fine-tuning runs the training, and the result is a custom model, which you then host on a hosting cluster, behind an endpoint. The course describes three methods: T-Few and Vanilla for Cohere models, where T-Few changes only a small fraction of the weights and Vanilla changes more layers, and LoRA, which adds small new matrices while the original weights stay frozen. The current documentation lists only one base model for fine-tuning: a Meta Llama 3.3 model with seventy billion parameters, tuned with LoRA.

Training settings and results

A few hyperparameters control the training. An epoch is one full pass through the training data, the learning rate sets how big each change to the weights is, and the batch size is the number of examples per update. Early stopping ends the training when the results stop improving. To judge the custom model, look at its loss, which measures how wrong its outputs are, lower is better, and its accuracy, measured on validation data that it did not train on. If the training loss keeps falling while the validation results get worse, the model is overfitting: fewer epochs or early stopping help.

Recap

Let's recap. Prompt engineering is the quickest way to customize, with no training. RAG adds current data from your sources at request time, which grounds the answers. Fine-tuning trains the model on labeled examples, for a style, a format, or a task that it does poorly. On OCI, the training data is a JSONL file in Object Storage, a dedicated AI cluster trains a custom model with T-Few, Vanilla, or LoRA, and a hosting cluster serves it. And epochs, learning rate, batch size, and early stopping shape the training, judged by loss and accuracy on validation data.

Quick checks for this lesson

The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.

  1. Willowmere’s assistant must answer questions about car prices and stock, which change every day. Which method fits best?

    • Fine-tune a model on the stock each week
    • Retrieval-augmented generation
    • Few-shot examples with yesterday’s prices
    • A larger base model
    Show the answer

    Retrieval-augmented generation

    RAG looks up the current prices and stock at request time, so every answer reflects today's data. “Fine-tune a model on the stock each week” would bake the data into the model's weights, and it would be out of date by the next day. “Few-shot examples with yesterday’s prices” would show yesterday's prices, which are already out of date. And “A larger base model” would not know today's prices either, because a model only knows its training data.

  2. Willowmere has two thousand repair notes, each paired with the summary that it should produce, to fine-tune a model on OCI. How should it provide this training data?

    • As a spreadsheet in the playground
    • As one long prompt in the chat
    • As a PDF of the service manual
    • As a JSONL file in Object Storage
    Show the answer

    As a JSONL file in Object Storage

    Fine-tuning on OCI reads a JSONL file from Object Storage, with one prompt and completion pair per line. “As a spreadsheet in the playground” is wrong, because the playground is for trying models, not for training them. “As one long prompt in the chat” would be in-context learning, and two thousand examples would not fit in one prompt. And “As a PDF of the service manual” has no pairs of inputs and expected outputs, so the training would have nothing to learn from.

  3. Willowmere’s custom model reaches a very low loss on its training examples, but writes poor summaries of new repair notes. What is the most likely cause, and what helps?

    • Overfitting: fewer epochs or early stopping
    • A hallucination: add a reranker
    • Too few tokens: raise the output limit
    • Underfitting: train for many more epochs
    Show the answer

    Overfitting: fewer epochs or early stopping

    Excellent results on the training data but poor results on new data are the sign of overfitting, and fewer epochs or early stopping help. “A hallucination: add a reranker” is not the issue, because the summaries are poor in format and quality, not full of invented facts. “Too few tokens: raise the output limit” would only allow longer outputs, not better ones. And “Underfitting: train for many more epochs” would make the overfitting worse, because the model would memorize its examples even more.