AI Run Lab

All chapters

Reading the AI landscape

A model, a framework and a complete assistant have different jobs. Trace a single request to see which components you actually need.

Open this chapter with experiments and audio

What did you download?

An open-weight language model typically comes with numerical tensors, a configuration and tokenizer files. The configuration describes the shape of the model. The tensors contain its fitted values. The tokenizer provides a consistent mapping between text and IDs. Loading a checkpoint means placing those values into the matching computation. The weights would be unusable if the implementation expected a different layer layout.

Open weights describe access to the parameter files. To learn whether you may redistribute, modify or host a particular model, read its licence. A model card can also describe the training data, intended uses, limitations and evaluation setup. Those details help you assess what the published results actually measured.

Which software does the computation?

ComponentConcrete job
PyTorch or TensorFlowExecute tensor operations and compute gradients during training.
JAXTransform numerical functions, for example to obtain gradients or compiled code.
KerasCompose trainable models through a higher-level interface.
Hugging Face TransformersLoad compatible configurations, model implementations and tokenizers.
A serving runtimeKeep a model available and handle generation requests.

You can instantiate an architecture in PyTorch with initial weights, or load trained weights into it. The framework can execute both. It is the checkpoint and its training history that determine whether the resulting model has learned useful text patterns. Even a technically valid forward pass can yield meaningless predictions.

Select retrieval, then model and weights. Changing one handbook paragraph affects the first component when the index is updated. Loading a different checkpoint affects the second. Following both links shows why these two changes need different tests.

Follow a question about a handbook

1. Application

Receives “How many days can I carry over?” and identifies the relevant handbook.

2. Retrieval

Finds a passage about leave and sends the passage with the question.

3. Model runtime

Processes the supplied context and generates candidate answer tokens.

4. Interface

Displays the answer with the passage the application actually retrieved.

If the wrong handbook was retrieved, changing the language model may leave the error untouched. Inspect the retrieved passage first. If the right passage was supplied but the answer contradicts it, inspect the prompt, model output and evaluation examples. Naming each component makes fault-finding more precise.

To test this setup, write a handbook with one deliberately unusual fact, such as a carry-over allowance of thirteen days. Ask the same question once with section retrieval disabled and once with the correct paragraph supplied. Keep the model and decoding settings fixed. A change toward thirteen in the second run supports the idea that context steered this answer. Repeat across multiple questions to determine how reliably it happens.

Which pieces must you build?

For a local experiment, a model runner and compatible checkpoint may be enough to generate text. To teach a model from scratch, you also need an architecture, training material, a learning objective and an optimizer. For an application using an external API, authentication, message formatting and handling returned results become your responsibilities. These are different boundaries around the same general type of computation.

Can one application use a database, an API and PyTorch at the same time?

Yes. The database may supply passages, the API connects components, and a service behind it can use PyTorch to execute a model.

Hugging Face · Transformers

Keras

Which part of a prediction is software?

You open a file containing the three numbers 2, −1 and 1. Can you run it? Suppose the author meant the first two numbers as weights for two measurements and the last as an offset. Someone still has to specify an operation and the order of the inputs. Here is a complete prediction written in plain Python. It needs neither a trained service nor special hardware.

def score(first, second):
    weights = [2, -1]
    bias = 1
    return weights[0] * first + weights[1] * second + bias

print(score(4, 3))

With inputs 4 and 3 the intermediate products are 8 and −3, so the output is 6. A framework can express the same work as a tensor operation. An interchange format such as ONNX can store a graph of operations together with constants. A runtime loads the graph and selects implementations that the available processor can execute. An application might turn the resulting score into an alert. The alert threshold belongs to whoever wrote that part of the application.

The application swaps the input fields. Where does the result change?

The runtime correctly computes 2 × 3 − 4 + 1 = 3. If the data contract only checked that both fields were numbers, it would accept the swap. A documented field order and a reference input paired with its expected output expose this error.

Trace the file and the runtime through the architecture explorer →

Further reading · ONNX · Concepts