Skip to main content

06 - Fine-tuning vs RAG: When to Use What

Fine-tuning changes the model's behavior, RAG brings it the facts: how to choose the right lever, with LoRA tried on a toy block and costs without figures.

What do you think about this article?

At a Glance

Fine-tuning changes the model's behavior, RAG brings it the facts: how to choose the right lever, with LoRA tried on a toy block and costs without figures.

You have an assistant that gets things wrong, and you have to decide how to fix it. If it errs because it does not know the facts (the circular published last month, the internal price list, your documentation), the remedy is to hand it those facts at the moment of the question: that is RAG. If it has the facts but answers in the wrong format, in a tone that changes from one request to the next, or by skipping a step it should always perform, the remedy is to change the way it behaves: that is fine-tuning. They are two levers for two different problems, and OpenAI's guide to optimizing accuracy calls them "context optimization" and "model optimization". Whoever picks one of the two out of habit is usually treating the defect they do not have.

There is a recent fact to know before writing any code: OpenAI's official page on supervised fine-tuning states, at the date of consultation (2026-11-12), that the platform is being wound down, that it is no longer accessible to new users, and that eligible existing customers can create jobs until January 6, 2027. For anyone starting today, "fine-tuning" almost always means training adapters on an open-weights model, and the rest of the article is built around that. The method is the series' method: no model was trained or called. The listings that were run are checks on files, selection rules, a cost model with made-up prices, and a toy block on which I really applied LoRA with the PEFT library. If you are arriving from scratch, the prerequisites are What is RAG and Integrating the OpenAI and Anthropic APIs.

Two problems, two levers

A concrete example helps to tell them apart. An accounting firm wants an assistant that answers questions about VAT. If, asked "how is this transaction treated under the October circular?", the assistant answers with an old rule, knowledge is missing: the model has not read the circular, and no training on your corpus will make it up to date the following week. If instead it receives the right circular in the prompt and still answers with a long digression instead of the four-field sheet the firm uses, behavior is missing: it is not a problem of facts, it is a format the model does not hold.

AspectRAGFine-tuning
What changesThe prompt, on every requestThe weights (or the adapters) of the model
Where the knowledge livesIn documents you can open and fixSpread through the weights, not inspectable
Updating a factYou edit the documentYou retrain
Citing the sourcePossible: the snippet is in the promptThere is no source to cite
What it is good forPrivate, recent, changing factsFormat, tone, consistency of behavior

The rows of the table all follow from the first: RAG works on the text the model reads, fine-tuning works on the model. That is why they are not alternatives in the strict sense, and why OpenAI's guide warns that the path is not a ladder to climb (prompt, then RAG, then fine-tuning): they are levers that solve different things, and you choose based on what went wrong in the cases you have measured.

The prompt and an evaluation first

Both levers cost work, and the same guide suggests starting from the prompt, which for tasks such as summarization, translation and code generation is often enough by itself. The prompt has an advantage that is underrated: it forces you to define what "right" means for your case, because without an expected output you cannot even say whether something has improved. The page on supervised fine-tuning says it in one sentence: invest in fine-tuning only after you have set up evaluations, that is, a reliable way to establish whether the new model is better than the starting one.

In practice a minimal evaluation is a list of real questions with the answer you would like, and a criterion for saying "same" or "different". The wrong answers, read one by one, tell you which side to take: if the right answer cannot be found in the prompt because the fact is missing, it is context; if the fact is there and the model uses it badly, it is behavior.

When you need RAG

OpenAI's guide indicates three situations in which it pays to optimize the context:

  • the model does not know the fact because it was not in the training data;
  • its knowledge is out of date;
  • you need proprietary knowledge, which was never public.

They are three ways of saying the same thing: the information exists outside the model and has to reach it in the request. RAG adds two properties that fine-tuning does not have. When the fact changes you fix a document, with no new training; and you can show the user which snippet the answer comes from. How the set of snippets is built is covered in RAG with TypeScript and LangChain.js and in Vector databases for web developers.

When you need fine-tuning

Here the same guide lists three other signals, which concern behavior:

  • inconsistent results, with a format that is sometimes wrong;
  • incorrect tone or style;
  • reasoning that is not followed consistently.

None of the three items is about facts: that is the difference that decides. The page on supervised fine-tuning adds which tasks it works well for: classification, translation with nuance, producing content in a specific format, and correcting errors in following instructions. It also concerns efficiency: the guide cites as a second reason getting the same accuracy with fewer tokens or with a smaller model. Fine-tuning is instead the wrong tool for making the model aware of something new, because in the weights facts get mixed together and cannot be corrected one by one.

How many examples are needed? For OpenAI's service the minimum is ten, improvements are usually seen between fifty and a hundred, and the recommendation is to start from about fifty curated demonstrations and evaluate, adding more only if needed. The number for an open-weights model depends on the task and has no universal threshold: the same principle of starting small and measuring applies. What is worth doing anyway is checking the file before uploading it, because malformed rows are discovered late and at your expense. The listing puts together the most basic checks for a file in chat format.

Listing 1: checking a JSONL training file (Node 24.11, run)
// Minimal checks on a training file in "chat" JSONL format (one conversation per line).
const ROLES = new Set(["system", "developer", "user", "assistant", "tool"]);
const MIN_ROWS = 10; // minimum stated by OpenAI's supervised fine-tuning guide

export function validate(text: string): { rows: number; valid: number; problems: string[] } {
  const rows = text.split("\n").filter((r) => r.trim() !== "");
  const problems: string[] = [];
  let valid = 0;
  rows.forEach((row, i) => {
    const n = i + 1;
    let obj: any;
    try { obj = JSON.parse(row); } catch { problems.push(`row ${n}: invalid JSON`); return; }
    const m = obj?.messages;
    if (!Array.isArray(m) || m.length === 0) { problems.push(`row ${n}: the "messages" list is missing`); return; }
    const wrongRole = m.find((x: any) => !ROLES.has(x?.role));
    if (wrongRole) { problems.push(`row ${n}: unknown role "${wrongRole.role}"`); return; }
    if (m[m.length - 1].role !== "assistant") { problems.push(`row ${n}: the last message is not from the assistant, there is nothing to learn`); return; }
    if (!m.some((x: any) => x.role === "user")) { problems.push(`row ${n}: no user message`); return; }
    valid++;
  });
  if (rows.length < MIN_ROWS) problems.push(`file: ${rows.length} rows, the minimum is ${MIN_ROWS}`);
  return { rows: rows.length, valid, problems };
}

const SYSTEM = "Answer as Acme support, concisely.";
const row = (u: string, a: string) => JSON.stringify({ messages: [{ role: "system", content: SYSTEM }, { role: "user", content: u }, { role: "assistant", content: a }] });

const sample = [
  row("I can't log in", "Use the password reset link on the sign-in page."),
  row("How do I change plan?", "From the Billing panel, under Plan."),
  '{"messages": [{"role": "user", "content": "question with no closing"',          // truncated JSON
  JSON.stringify({ messages: [{ role: "system", content: SYSTEM }, { role: "user", content: "Hello" }] }), // ends with the user
  JSON.stringify({ question: "Hello", answer: "Hi" }),                          // wrong format
].join("\n");

const result = validate(sample);
console.log(`rows: ${result.rows}, valid: ${result.valid}`);
result.problems.forEach((p) => console.log("-", p));

// Output:
// rows: 5, valid: 2
// - row 3: invalid JSON
// - row 4: the last message is not from the assistant, there is nothing to learn
// - row 5: the "messages" list is missing
// - file: 5 rows, the minimum is 10

The function validate reads one conversation per line and rejects three kinds: truncated JSON (row 3), a conversation that ends with a user message, without an answer to learn (row 4), and the wrong format (row 5, without the messages list). It adds a check on the whole file, the ten-row minimum from OpenAI's guide, which the sample deliberately does not reach. It does not check whether the answers are right: that is the human work the guide recommends doing first, because the quality of the data weighs more than the quantity.

What happened to the managed platform

The flow of OpenAI's managed service, for the customers who still use it, is the one in the documentation: you upload the file with purpose fine-tune, you create a job specifying the starting model (model), the file (training_file) and optionally the method (method, and the supervised one is the default), you wait for it to finish, and you use the identifier that starts with ft: in fine_tuned_model. The same page warns that trained models remain available until the base model shuts down, with shutdown dates for each (some already past at the date of consultation). The practical point is that an application built on a model trained that way has an expiry date, which the provider sets and you do not.

That is a good argument for keeping the process reproducible: the training file, the evaluation and the script are yours and move from one provider to another, while the trained model does not. With open weights the constraint changes nature: the model is a file you keep yourself, and you pay in machine, time and skills.

LoRA and QLoRA, with a toy model

Full fine-tuning updates all the parameters, and for a large model it takes memory and time that few people have. LoRA (Low-Rank Adaptation, Hu et al., 2021) freezes the original weights and, for each chosen matrix, adds two small matrices whose product has a low rank: only those are trained. The paper's abstract reports, for GPT-3 175B compared with fine-tuning with Adam, a 10,000-fold reduction in trainable parameters and a 3-fold reduction in GPU memory; it is a figure from that comparison, not a promise valid for every model. For a d-by-k matrix the arithmetic is done by hand: an adapter of rank r trains r·(d+k) numbers instead of d·k.

QLoRA (Dettmers et al., 2023) keeps the base model quantized to 4 bits, in a format called NF4, and trains the LoRA adapters on top of it: according to the abstract it makes it possible to train a 65-billion-parameter model on a single 48 GB GPU. The PEFT documentation writes that applying LoRA to all linear layers, as QLoRA does, can match the performance of full fine-tuning, and that you get it with target_modules="all-linear".

Listing 2: LoRA applied to a toy block with PEFT (Python 3.12, torch 2.12 on CPU, peft 0.21.2, run)
import copy
import torch
from torch import nn
from peft import LoraConfig, get_peft_model

torch.manual_seed(0)  # same weights on every run


class Block(nn.Module):
    """A toy block with the same module names as a transformer."""
    def __init__(self, d=64, h=128):
        super().__init__()
        self.q_proj, self.k_proj = nn.Linear(d, d), nn.Linear(d, d)
        self.v_proj, self.o_proj = nn.Linear(d, d), nn.Linear(d, d)
        self.gate_proj, self.up_proj = nn.Linear(d, h), nn.Linear(d, h)
        self.down_proj = nn.Linear(h, d)

    def forward(self, x):
        a = self.o_proj(torch.tanh(self.q_proj(x) * self.k_proj(x)) * self.v_proj(x))
        return self.down_proj(torch.relu(self.gate_proj(a)) * self.up_proj(a))


base = Block()
x = torch.randn(4, 64)
base_output = base(x).detach()

cfg = LoraConfig(r=8, lora_alpha=16, lora_dropout=0.0,
                 target_modules=["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"])
model = get_peft_model(copy.deepcopy(base), cfg)

trainable, total = model.get_nb_trainable_parameters()
print(f"trainable parameters: {trainable} out of {total} ({100 * trainable / total:.2f}%)")
print("output identical to the base model before training:", torch.allclose(model(x), base_output, atol=1e-6))

before = {n: p.detach().clone() for n, p in model.named_parameters()}
optimizer = torch.optim.SGD([p for p in model.parameters() if p.requires_grad], lr=0.1)
loss = (model(x) - torch.ones(4, 64)).pow(2).mean()
loss.backward()
optimizer.step()

changed = sorted({n.split(".")[-3] for n, p in model.named_parameters() if not torch.equal(p, before[n])})
print("matrix types changed after the first step:", changed)
base_weights_changed = [n for n, p in model.named_parameters() if "lora_" not in n and not torch.equal(p, before[n])]
print("base model weights changed:", len(base_weights_changed))

with_adapters = model(x).detach()
merged = model.merge_and_unload()  # adds B·A into the weights and removes the adapters
print("output after merging equal to before:", torch.allclose(merged(x), with_adapters, atol=1e-5))
print("parameters after merging:", sum(p.numel() for p in merged.parameters()), "(same as the base model)")

# The trainable share depends on the width: for a d x k layer with rank r you train r*(d+k) numbers instead of d*k.
for d in (64, 1024, 4096):
    print(f"d=k={d:>4}, r=8: {8 * (d + d):>7} out of {d * d:>9} ({100 * 8 * (d + d) / (d * d):.2f}%)")

# QLoRA adds 4-bit quantization of the base model; here only the configuration is built
# (actually loading a model with this configuration requires bitsandbytes and a GPU: not run).
from transformers import BitsAndBytesConfig
q = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_quant_type="nf4", bnb_4bit_use_double_quant=True)
print("QLoRA configuration:", q.load_in_4bit, q.bnb_4bit_quant_type, q.bnb_4bit_use_double_quant)

# Output:
# trainable parameters: 8704 out of 50240 (17.32%)
# output identical to the base model before training: True
# matrix types changed after the first step: ['lora_B']
# base model weights changed: 0
# output after merging equal to before: True
# parameters after merging: 41536 (same as the base model)
# d=k=  64, r=8:    1024 out of      4096 (25.00%)
# d=k=1024, r=8:   16384 out of   1048576 (1.56%)
# d=k=4096, r=8:   65536 out of  16777216 (0.39%)
# QLoRA configuration: True nf4 True

The toy block has seven matrices with the module names of a transformer (q_proj, gate_proj and the others), and get_peft_model wraps them with the adapters (the total of 50,240 also counts the adapters: subtracting 8,704 leaves the 41,536 of the starting block). Three facts emerge from the output. The trainable share depends on the width: 17.32% in this tiny block, while the arithmetic at the end shows 25% for d=64, 1.56% for d=1024 and 0.39% for d=4096 at rank 8, so the percentages of large models cannot be read off a small example. Before training the output is identical to that of the base model: one of the two matrices in each pair starts at zero, so the adapted model begins exactly where the base was. And after one optimization step only lora_B changes, not lora_A: with B at zero the gradient of A is null at the first step (A receives one from the second step, when B is no longer zero: I did not measure it).

The last two lines of PEFT are the ones that matter for publishing. merge_and_unload() adds the product of the adapters into the weights and removes the adapters, and the output stays the same (within 1e-5), with the same number of parameters as the starting model: a single model, with no additional cost at inference. The last line builds the QLoRA configuration, which was not used to load anything: doing so requires the bitsandbytes library and a GPU, so a real training on a real model, with the training loop of the TRL library, is a schema to adapt that I did not run. To use the merged model locally, Ollama's Modelfile can start from a folder of Safetensors weights of a supported architecture or from a GGUF file (Modelfile page); I did not try the step. The Ollama side is in Local LLMs with Ollama.

The training format must be the production format

The most frequent mistake when combining the two levers is training on one format and querying on another. OpenAI's guide puts it among the main traps: training examples that differ in format from what the model will see in production. And for an application with RAG it indicates training with examples that already contain the retrieved snippets, so that the model does not learn to answer cold. The remedy is a single function, used both to write the training file and to build the real request.

Listing 3: a single message builder for training and production (Node 24.11, run)
// A single place builds the messages: it is used both by whoever prepares the training file
// and by whoever calls the model in production. If the two formats diverge, the training is useless.
export interface Snippet { title: string; text: string }
type Message = { role: "system" | "user" | "assistant"; content: string };

const INSTRUCTIONS = "Answer in English, concisely, and cite the title of the source in square brackets.";

export function buildMessages(question: string, snippets: Snippet[]): Message[] {
  const context = snippets.map((f, i) => `[${i + 1}] ${f.title}\n${f.text}`).join("\n\n");
  return [
    { role: "system", content: INSTRUCTIONS },
    { role: "user", content: `Sources:\n${context}\n\nQuestion: ${question}` },
  ];
}

const snippets: Snippet[] = [
  { title: "Webhook guide", text: "The webhook is configured from the Developers panel." },
  { title: "Changelog 3.2", text: "Since 3.2 webhooks sign the body with HMAC." },
];

// Training example: the same messages that will arrive in production, plus the desired answer.
const example = {
  messages: [
    ...buildMessages("How do I configure the webhook?", snippets),
    { role: "assistant", content: "From the Developers panel [Webhook guide]." },
  ],
};
console.log("training:", JSON.stringify(example));

// In production: same function, another question and other snippets (retrieved by hand here).
const inProduction = buildMessages("Are webhooks signed?", snippets.slice(1));
const same = JSON.stringify(inProduction[0]) === JSON.stringify(example.messages[0]);
console.log("system message identical between training and production:", same);
console.log(inProduction[1].content);

// Output:
// training: {"messages":[{"role":"system","content":"Answer in English, concisely, and cite the title of the source in square brackets."},{"role":"user","content":"Sources:\n[1] Webhook guide\nThe webhook is configured from the Developers panel.\n\n[2] Changelog 3.2\nSince 3.2 webhooks sign the body with HMAC.\n\nQuestion: How do I configure the webhook?"},{"role":"assistant","content":"From the Developers panel [Webhook guide]."}]}
// system message identical between training and production: true
// Sources:
// [1] Changelog 3.2
// Since 3.2 webhooks sign the body with HMAC.
//
// Question: Are webhooks signed?

buildMessages composes the system instructions and the question with the numbered snippets; the training example reuses those two messages and adds the desired answer, which cites the title of the source in square brackets. In production the same function receives a different question and different snippets. The output shows that the system message is identical in the two cases, and that the format of the snippets coincides. If one day you change the way sources are numbered, you change it in one place, and you know the training file has to be regenerated: the same tool that protects you from misalignment tells you when to retrain.

Costs: a structure, not a figure

The prices of services change and depend on the model, so you will not find a table of dollars here. What lasts is the structure of the bill, and it shows up with a simple model. A long prompt with instructions and examples is paid for on every request; a trained model has a short prompt, but it costs a one-off training and, for a managed service, may have a different price list from the base model; RAG pays on every request for the tokens of the retrieved snippets, plus the search.

Listing 4: comparing three strategies with made-up prices (Node 24.11, run)
// Cost model with MADE-UP PRICES: they show the structure, they do not predict an invoice.
// Replace the values with the price list you consulted today for the models you will actually use.
interface Prices { inputPerMillion: number; outputPerMillion: number }

const MADE_UP: Prices = { inputPerMillion: 1, outputPerMillion: 4 }; // arbitrary currency units

function requestCost(p: Prices, inputTokens: number, outputTokens: number): number {
  return (inputTokens * p.inputPerMillion + outputTokens * p.outputPerMillion) / 1_000_000;
}

// Strategy A: long prompt with instructions and examples in every request (no training).
const longPrompt = requestCost(MADE_UP, 1500 + 100, 150);
// Strategy B: trained model, short prompt; you pay for the training once (made up) and the price list
// of the trained model may differ: here we assume double, to be fair.
const training = 50;
const trainedPrices: Prices = { inputPerMillion: 2, outputPerMillion: 8 };
const shortPrompt = requestCost(trainedPrices, 100, 150);
// Strategy C: RAG, short prompt plus 4 retrieved snippets of 250 tokens.
const withRag = requestCost(MADE_UP, 100 + 4 * 250, 150);

console.log("per request (made-up units):");
console.log("  long prompt       ", longPrompt.toFixed(6));
console.log("  trained, short    ", shortPrompt.toFixed(6));
console.log("  with RAG          ", withRag.toFixed(6));

// After how many requests does the training pay for itself against the long prompt?
const saving = longPrompt - shortPrompt;
if (saving <= 0) console.log("the training never pays for itself at these prices");
else console.log(`break-even after ${Math.ceil(training / saving)} requests`);

// With different prices the conclusion changes: the same model with a price list equal to the base.
const saving2 = longPrompt - requestCost(MADE_UP, 100, 150);
console.log(`with a price list equal to the base: break-even after ${Math.ceil(training / saving2)} requests`);

// Output:
// per request (made-up units):
//   long prompt        0.002200
//   trained, short     0.001400
//   with RAG           0.001700
// break-even after 62500 requests
// with a price list equal to the base: break-even after 33334 requests

The prices are made up for the listing, and the code says so: the ratios are what counts. With those values the short prompt of the trained model costs less per request, but the 50 of the training pay for themselves only after 62,500 requests, and after 33,334 if the trained model had the same price list as the base. The direction of the conclusion depends on your volumes: with a few hundred requests a day and ratios like these the training does not pay for itself in a reasonable time, and the saving on the prompt is not the right reason to train. The right reason is consistency of behavior, and the cost should be compared with that of correcting wrong answers by hand. Replace the values with the price list you consulted today and with the lengths measured on your own prompts.

A decision rule, to be verified

Summing everything up in a flowchart is tempting and misleading, because the right choice depends on an evaluation that only you can make. I can, however, write the rules of this article as a function, which has the merit of being executable and open to argument. Every branch is a hypothesis to check with your test questions.

Listing 5: the decision rule applied to five hypothetical scenarios (Node 24.11, run)
type Choice = "prompt" | "rag" | "fine-tuning" | "rag + fine-tuning";

interface Case {
  name: string;
  missingKnowledge: boolean;    // the model does not know the facts (private, recent, changing)
  missingBehavior: boolean;     // the facts are there, but format, tone or reasoning are inconsistent
  needCitations: boolean;
  examplesAvailable: number;    // correct input/output pairs already in hand
}

// A heuristic written out in prose and encoded, not a law: every branch is a hypothesis to check with an evaluation.
export function decide(c: Case): { choice: Choice; why: string } {
  const rag = c.missingKnowledge || c.needCitations;
  const ft = c.missingBehavior;
  if (!rag && !ft) return { choice: "prompt", why: "neither gap: first measure the simple prompt" };
  if (ft && c.examplesAvailable < 50)
    return { choice: rag ? "rag" : "prompt", why: `with ${c.examplesAvailable} examples fine-tuning is premature: collect at least 50 and meanwhile use examples in the prompt` };
  if (rag && ft) return { choice: "rag + fine-tuning", why: "both the facts and the behavior are missing: two levers, two separate evaluations" };
  return rag ? { choice: "rag", why: "the facts are missing, not the behavior" }
             : { choice: "fine-tuning", why: "the facts are there, consistency of format or tone is missing" };
}

const cases: Case[] = [
  { name: "Documentation FAQ, updated with every release", missingKnowledge: true, missingBehavior: false, needCitations: true, examplesAvailable: 0 },
  { name: "Classify tickets into fixed categories", missingKnowledge: false, missingBehavior: true, needCitations: false, examplesAvailable: 400 },
  { name: "Tax answers in a technical tone with cited rules", missingKnowledge: true, missingBehavior: true, needCitations: true, examplesAvailable: 120 },
  { name: "Same case, but only 20 examples", missingKnowledge: true, missingBehavior: true, needCitations: true, examplesAvailable: 20 },
  { name: "Summarize meeting minutes", missingKnowledge: false, missingBehavior: false, needCitations: false, examplesAvailable: 0 },
];
for (const c of cases) {
  const r = decide(c);
  console.log(`${c.name}\n  -> ${r.choice}: ${r.why}`);
}

// Output:
// Documentation FAQ, updated with every release
//   -> rag: the facts are missing, not the behavior
// Classify tickets into fixed categories
//   -> fine-tuning: the facts are there, consistency of format or tone is missing
// Tax answers in a technical tone with cited rules
//   -> rag + fine-tuning: both the facts and the behavior are missing: two levers, two separate evaluations
// Same case, but only 20 examples
//   -> rag: with 20 examples fine-tuning is premature: collect at least 50 and meanwhile use examples in the prompt
// Summarize meeting minutes
//   -> prompt: neither gap: first measure the simple prompt

The five scenarios are made up to illustrate the branches, not case studies with measured results. The third and the fourth are the same problem with a different number of examples: with 120 pairs the rule proposes both levers, with 20 it defers fine-tuning and advises keeping RAG and collecting data, using a few examples in the prompt in the meantime. The last scenario shows the most underrated branch, "neither": when the simple prompt works, the right lever is to pull none.

What you can do now

You can separate a knowledge problem from a behavior problem and choose the right lever starting from measured cases. You can check a training file before using it, tell what LoRA changes (the small matrices, not the base model) and see why the trainable share drops as the model gets wider. You can keep the format identical between training and production, and read a cost bill as a structure. What I could not try here is a real training on a real model: it requires a GPU. The next step is to give the model tools to use, in AI Agents.

Frequently asked questions

Does fine-tuning teach the model new facts?

It is the use for which it works worst. OpenAI's guide places facts in context optimization and fine-tuning in behavior optimization. For a fact that changes use RAG: you fix a document instead of retraining.

Can I use RAG and fine-tuning together?

Yes, and it is the flow the guide describes as typical: first prompt and examples, then a retrieval of snippets, then a model trained on examples that already contain the snippets. The two evaluations should be kept separate, to know which of the two levers improved the result.

How many examples do I start with?

OpenAI's service requires at least ten rows and recommends starting from about fifty curated examples. For an open-weights model there is no universal threshold: start small, measure on held-out examples and add data only if the residual defect is one of behavior.

Sources

Listings 1, 3, 4 and 5 were run with Node 24.11 and listing 2 with Python 3.12, torch 2.12.0 on CPU and peft 0.21.2 (transformers 5.10.2), each twice with identical output. The prices in listing 4 and the scenarios in listing 5 are made up. No model was trained or called: loading in 4 bits and the training loop on a real model are schemas to adapt, not run.

Try These Tools

Free developer tools related to this topic.

Commenti

Caricamento commenti...

Sign in to comment

New articles and tools on Telegram too

The Telegram channel flags the site's new articles and tools.

Did you like this article?

Explore other content on the blog or discover my projects