# Rules, Machine Learning and Gen AI: What Changes in a Data Pipeline?

> Compare exact transformations, fitted predictions and Gen AI mapping proposals in one ingestion job. Run a TypeScript example and choose the right checks for each.

- Drafted by AI, signed off by: [Muhammed Shakir](https://www.linkedin.com/in/muhammed-shakir-gen-ai-trainings-and-consulting): Creator, Projekts.ai | Enterprise AI Builder & Architect | Helping Businesses Build AI-Agent-Driven Operations | Agentic AI, RAG & AI-Native Systems | Forward Deployed Engineer | Corporate Trainer
- Published: 2026-11-19
- Last updated: 2026-11-19
- Topic: AI fundamentals for developers
- Written for: developers and architects
- Web page: https://workshopps.com/blog/genai-rules-machine-learning-data-pipelines
- Related Course Offering: [GenAI Coach Program for Data Engineering — Build, Operationalize, and Teach Practical GenAI Solutions](https://workshopps.com/courses/genai-coach-program-for-data-engineering)

**At a glance:** Rules apply logic an engineer has specified; predictive machine learning estimates values using patterns learnt from data; generative AI proposes content such as a mapping or transformation. Automation can run any of these steps. In a data pipeline, choose the approach by what the output means and what evidence you need before accepting it.

![Rule, predictive model or Gen AI: one ingestion job splits by what each step's output means, and each output gets its own check](https://infomover-public-content.s3.ap-south-1.amazonaws.com/prod/workshopps/genai-rules-machine-learning-data-pipelines/ad6cad25720e-rules-ml-genai-pipeline.svg "Choose each step by what its output means, and put the matching check beside it.")

## The short answer

Rules apply logic an engineer has specified; predictive machine learning estimates values using patterns learnt from data; generative AI proposes content such as a mapping or transformation. Automation can run any of these steps. In a data pipeline, choose the approach by what the output means and what evidence you need before accepting it.

---

## Follow one ingestion job

Suppose a job loads file metadata into a reporting table. It must convert file sizes, estimate processing time and accommodate an unfamiliar source column. These are three different tasks inside the same workflow.

| Task | Where the behaviour comes from | Output | Evidence before use |
|---|---|---|---|
| Convert a documented size in decimal megabytes to gigabytes | An engineer writes `MB / 1000` | A converted measurement | Unit contract and exact-case tests |
| Estimate processing time from earlier file sizes and measured durations | A regression model learns coefficients from examples | An estimated duration | Error on separate observations and a defined operating range |
| Suggest how an unfamiliar `volume` column maps to `size_gb` | A generative model uses instructions, source descriptions and learnt patterns | A candidate mapping | Confirmed field meaning, units and transformation tests |

The scheduler can execute all three. Scheduling, retries and dependency ordering are **automation**: they describe how work runs. Rules and models describe how a particular step determines its result.

Generative AI is a kind of machine learning. Here, “predictive ML” means a conventional model built for a specific prediction, such as regression; “Gen AI” means a model producing content, such as text or code. [Google's introduction to machine learning](https://developers.google.com/machine-learning/intro-to-ml/what-is-ml) covers both within ML. Their capabilities can overlap: a language model can also classify or estimate. The table separates responsibilities in this job rather than declaring exclusive abilities.

For the wider terminology map, see [AI, machine learning, deep learning and generative AI](/blog/ai-vs-machine-learning-vs-deep-learning-vs-generative-ai). Here, we will follow what changes at the boundary between an output and the next pipeline step.

---

## Rules encode a decision you already know

If the source contract says a field is in decimal megabytes, the conversion to decimal gigabytes is agreed arithmetic. You do not need examples to learn it. Specify what happens for missing, negative or invalid input, then test those cases.

A rule can be correct code built on a wrong assumption. If the source actually uses binary mebibytes, or `volume` means a count of objects, dividing by 1000 is the wrong transformation. Repeatable execution does not establish that the source interpretation is correct.

Use rules for agreed mappings, required fields, ranges and reconciliation identities. A collection of increasingly fragile text-matching rules may be a poor fit for varied language; that is a reason to evaluate another approach for that step. It is not a reason to hand agreed arithmetic to a model.

---

## Predictive ML learns a relationship you must measure

For a processing-time estimate, you may have historical pairs of file size and observed duration. Linear regression fits a relationship of the form:

```text
estimated minutes = intercept + slope × size in GB
```

The engineer chooses the inputs and model family. Training determines the slope and intercept from the examples. [Google's linear-regression lesson](https://developers.google.com/machine-learning/crash-course/linear-regression) explains these learnt parameters; ordinary least squares fits them by minimising squared prediction errors, as described in the [scikit-learn reference](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html).

Once fitted, this small model returns the same estimate for the same numeric input. Its uncertainty comes from whether that estimate matches reality. A result can be perfectly repeatable and consistently wrong.

Keep observed and estimated durations in different fields. Measure error on observations excluded from fitting. The [scikit-learn evaluation guide](https://scikit-learn.org/stable/modules/cross_validation.html) explains why training-set performance cannot establish performance on unseen data. For a job whose behaviour changes over time, evaluate on later observations using a suitable time-aware split.

Do not fit a model to rediscover a contractual unit conversion. Do not use the tiny example below to allocate real capacity: hardware, contention, compression and file contents can all affect processing time. This one-feature model does not account for those differences.

---

## Gen AI proposes a transformation whose meaning needs checking

A large language model can use descriptions and examples to propose a mapping for a new source. Give it the target schema, the available source documentation and explicit instructions for unresolved fields. For this ingestion job, a useful request would be:

```text
Target: size_gb, a file size in decimal gigabytes.
Source column: volume. No unit or field description is supplied.
Propose a mapping only if the documentation establishes its meaning
and units. Otherwise return an unresolved field and the question
we need to ask the source owner. Do not infer units from the name.
```

The missing information matters more than how fluent the answer sounds. `volume` could mean bytes, gigabytes, a count or something else. A confident explanation cannot settle that ambiguity. [NIST's Generative AI Profile](https://nvlpubs.nist.gov/nistpubs/ai/NIST.AI.600-1.pdf), section 2.2, describes generated false content and unsupported explanations that can encourage misplaced trust.

Your surrounding code should enforce the decision to wait for documented units. The instruction to the model helps communicate the task; it does not enforce that decision. Even a well-formed mapping with an allowed operation may be wrong about the source.

When Gen AI drafts transformation code during development, review and test it before deployment. The running job can then execute that approved code without a model call. If the job generates mappings during execution, review each new mapping before the job uses it.

---

## Run a small comparison in TypeScript

This exercise computes a conversion, fits a real one-feature regression and checks an ambiguous mapping proposal. **All observations are invented teaching values.** The proposal is a hand-written fixture representing a possible candidate; there is no generative-model call and no claim about how often a model would produce it.

Use Node.js 22 or later. In an empty directory, install the TypeScript runner:

```bash
npm init -y
npm install --save-dev tsx typescript
```

Save this as `compare.ts`:

```typescript
// Synthetic teaching data: size in decimal GB, duration in minutes.
type Observation = { gb: number; minutes: number };
const train: Observation[] = [
  { gb: 1, minutes: 3 }, { gb: 2, minutes: 5 },
  { gb: 3, minutes: 7 }, { gb: 4, minutes: 9 }
];
const test: Observation[] = [
  { gb: 2.5, minutes: 6.5 }, { gb: 5, minutes: 13 }
];

// 1. A rule: the conversion is specified, not learnt.
function mbToGb(mb: number): number {
  if (!Number.isFinite(mb) || mb < 0) throw new Error("Invalid MB");
  return mb / 1000;
}
console.log("rule GB:", mbToGb(2500).toFixed(2));

// 2. Ordinary least squares for one numeric feature.
const meanGb = train.reduce((sum, row) => sum + row.gb, 0) / train.length;
const meanMinutes = train.reduce((sum, row) => sum + row.minutes, 0)
  / train.length;
const denominator = train.reduce((sum, row) => sum + (row.gb - meanGb) ** 2, 0);
if (denominator === 0) throw new Error("Training sizes need variation");
const slope = train.reduce((sum, row) =>
  sum + (row.gb - meanGb) * (row.minutes - meanMinutes), 0) / denominator;
const intercept = meanMinutes - slope * meanGb;
const predict = (gb: number) => intercept + slope * gb;
const mae = test.reduce((sum, row) =>
  sum + Math.abs(predict(row.gb) - row.minutes), 0) / test.length;
console.log("learnt slope:", slope.toFixed(2));
console.log("estimated minutes:", predict(2.5).toFixed(2));
console.log("test MAE minutes:", mae.toFixed(2));

// 3. A candidate mapping fixture, NOT an actual model response.
const proposal = {
  from: "volume", to: "size_gb", operation: "divideBy1000"
};
type SourceContract = { field: string; unit?: string };
function routeMapping(contract: SourceContract): "review" | "eligible-for-tests" {
  return contract.field === proposal.from &&
    contract.unit === "decimal MB" &&
    proposal.to === "size_gb" && proposal.operation === "divideBy1000"
      ? "eligible-for-tests" : "review";
}
console.log("without units:", routeMapping({ field: "volume" }));
console.log("with documented units:", routeMapping({
  field: "volume", unit: "decimal MB"
}));
```

Run it:

```bash
npx tsx compare.ts
```

Expected output:

```text
rule GB: 2.50
learnt slope: 2.00
estimated minutes: 6.00
test MAE minutes: 1.25
without units: review
with documented units: eligible-for-tests
```

The regression learnt a slope of 2 and an intercept of 1 from the four training rows. It predicts 6 minutes for 2.5 GB. The separate teaching observation says 6.5 minutes, so that estimate is wrong by 0.5 minutes. At 5 GB it predicts 11 instead of the observed 13, an error of 2 minutes. The mean absolute error, or MAE, is the average of those two absolute errors: 1.25 minutes.

The 5 GB case is beyond the training range of 1–4 GB. It illustrates extrapolation: applying a fitted relationship outside the examples it saw. Two invented test rows cannot establish reliability, but they make the difference between a computed estimate and an observation visible.

The fixture has a plausible field name and operation. Without units, it stays in review. Supplying documented units makes it eligible for transformation tests; it does not automatically approve a mapping or execute generated code. The example assumes the contract was supplied by a trusted source catalogue, not copied from the model's answer.

### Try three changes

1. Change the last training duration from `9` to `12`. The fitted coefficients and predictions change; the unit conversion does not. The data supplied part of the model's behaviour.
2. Change the source contract's unit to `decimal GB`. The proposed division stays in review because it would apply the wrong conversion.
3. Call `mbToGb(-1)`. It throws an error. Decide how your actual ingestion job records and routes such failures before adding automatic retries.

This deliberately small fit omits missing-value handling, model storage and operational monitoring. A real model needs validated training data, representative evaluation cases and a monitored range of use. An external mapping response also needs runtime parsing and shape checks before a semantic check like this one.

---

## Match the check to the failure

Put the acceptance evidence beside each pipeline step. A successful run only tells you the workflow completed.

| Component | A useful check | What that check cannot establish |
|---|---|---|
| Unit-conversion rule | Known inputs, boundaries and invalid values | Whether the source documentation describes the field correctly |
| Fitted duration model | Error on held-out observations, including important subgroups and ranges | Accuracy after the workload or operating environment changes |
| Generated mapping | Output shape, documented meaning and units, reviewed input/output cases | Correctness from fluent reasoning or valid syntax alone |
| Workflow automation | Visible failures, bounded retries and safe replay | Whether a completed transformation means what the business intended |

For the mapping, write examples that distinguish the competing interpretations: `2500` decimal MB must become `2.5` decimal GB, while `2500` already in decimal GB must remain `2500`. Include missing units as an unresolved case. These are semantic tests: they check meaning, beyond whether the output has the expected fields.

Keep original measurements, estimates and proposals distinguishable in storage. That makes it possible to compare a new model or transformation against the old result without treating an estimate as an observed fact.

---

## What this means for you

Take a job your team already operates and label each step with its output: an exact transformation, an estimate or proposed content. Then name the source of truth and the acceptance evidence for each output. This is a concrete way to practise Day 1's workflow-mapping exercise in the [GenAI Coach Program for Data Engineering](/courses/genai-coach-program-for-data-engineering).

For developers, begin with the existing conversion and validation code. Add a fitted prediction or generated proposal only where the task benefits from it and you can evaluate the result. For architects, make the boundary explicit: where does a proposal stop, who approves it, and which component can write the authoritative table?

If the transformation is already documented and stable, ordinary code may be sufficient. If the prediction has too few useful examples, collect evidence before trusting a fit. If a mapping depends on facts nobody has supplied, ask for those facts. More elaborate generation cannot make missing documentation authoritative.

---

## Questions data engineers ask

### Does using Gen AI mean we no longer need rules?

No. Required fields, documented conversions and permission checks remain explicit responsibilities. A generative model may help draft them, while reviewed code enforces them in the pipeline.

### Is predictive ML always deterministic, and Gen AI always variable?

That is too broad a distinction. The fitted regression here is deterministic. Other systems can introduce randomness, and generative systems may repeat an answer. Measure correctness against the task; repeatability alone does not establish it.

### Why not ask a language model to estimate the duration too?

You can evaluate that alternative against a fitted baseline using the same held-out observations. The baseline makes its inputs and numeric error easy to inspect. Choose based on measured error, operating cost, latency and the consequences of failure rather than the model's ability to produce a number.

### How can our team practise this together?

Day 1 of the [GenAI Coach Program for Data Engineering](/courses/genai-coach-program-for-data-engineering), “Establish the GenAI Foundation and Discover Use Cases”, covers this comparison and maps a familiar workflow to suitable capabilities. Enquire about a Live Instructor Led Workshop or an Onsite Workshop for your Teams.
