What is an AI model

Parameters, training and inference, tokens, and how a language model turns a prompt into the next piece of text.

Updated CompTech Team

An AI model, in the sense these labs use the term, is a file of numbers plus the program that does arithmetic with them. The numbers are the parameters, also called weights. Training is how the numbers got their values. Inference is using those frozen numbers to produce an output. Nothing in inference edits the file.

A language model produces text one token at a time. The rest of this series — types, families, sizes, how to choose, how to adapt, how to run one — sits on that fact. Retrieval over your own documents is the RAG overview. This page is the model itself.

Parameters

A parameter is a single number the training run was allowed to change. A model described as "7 billion parameters" stores on the order of seven billion such numbers. More parameters can represent more patterns, and they cost more memory, more time per token, and more data to train well. The count is a size, like the number of rows in a table. It is not a quality score.

Those numbers are organised in layers. A modern language model is a stack of transformer blocks. Each block can look at the tokens already in the prompt (attention) and then pass the result through a small feed-forward network. You do not set those numbers by hand. You also do not need to read them. You do need to know how many there are, because that decides which GPU can hold the file. The arithmetic is in Model sizes and specs.

Training and inference

Training shows the network a huge number of examples and nudges every parameter so the next prediction is a little less wrong. For a language model the example is text, and the task is: given the tokens so far, predict the next one. That pretraining is why the model can continue a sentence it has never seen. It is also why the model has no private knowledge of your bank, your ministry, or your unit. Your documents were not in the pile, unless someone put them there.

After pretraining, further training often adjusts the same file so the model follows instructions, refuses some requests, or prefers a style. That is instruction tuning or preference tuning. It changes behaviour. It does not upload your policies.

Inference loads the parameters and runs them forward. The file is read-only. Asking a question does not teach the model the answer. The next user does not see your question inside the weights. (The API vendor may still log the question. That is a contract question, covered in Open-weight vs closed and Risks.)

Fine-tuning, which does edit a copy of the weights, is one of the three adaptation methods in Prompting, RAG and fine-tuning.

Tokens

Models do not read words or characters. They read tokens, small pieces from a fixed vocabulary. A common English word may be one token. A rare name, a number, or a word in Bangla is often several. The same sentence can cost more tokens in Bangla than in English on a vocabulary built mostly from English text. That shows up as a higher bill on an API, and as less room in the context window.

The context window is the maximum number of tokens the model will consider at once: the instructions, the documents you pasted, the conversation so far, and the answer it is still writing. Past that limit, tokens have to be dropped or the request fails. A larger window is useful and it is not free: memory grows with the length of the prompt and with how many requests you run together.

You are billed, and you are slowed, per token. Output tokens usually cost more than input tokens, because generating them is the heavy step.

How the next token is chosen

The forward pass does not emit a word. It emits a score for every token in the vocabulary. A softmax turns those scores into probabilities. One token is then chosen and appended, and the whole prompt plus that new token is scored again.

prompt:  "The capital of Bangladesh is"
scores:  Dhaka high, other cities low, many tokens near zero
choose:  "Dhaka"
prompt:  "The capital of Bangladesh is Dhaka"
choose:  the next piece, often a full stop or a newline

Temperature reshapes the probabilities before the choice. Near zero, the model almost always takes the top token: stable, dull, good for extracting a field. Higher, it sometimes takes a less likely token: more variety, more drift. Top-p and top-k cut the long tail so a near-zero token is never drawn. None of these settings add knowledge. They only change which likely continuation you get.

A reasoning model spends tokens on intermediate steps before the answer you see. Those tokens still occupy the window and still cost money and time. The pattern is described in The current landscape.

Two limits follow from the mechanism:

  • The model can produce a fluent token sequence that is false. Fluency is what training rewarded. Truth has to be checked, or grounded in text you supply.
  • The model stops because a stopping rule fired: an end token, a maximum length, or a tool-call marker. A stopped answer is not a finished piece of work unless you asked for something that fits in that length.

Streaming, and the bill

Servers send tokens as they are chosen, which is why a chat window fills in. The first token's delay is how long the user waits before anything appears. The rate after that is how fast the rest arrives. A reasoning model spends the first delay on tokens you may not display. Budget both numbers. A timeout that kills the call at the first-token mark will cut off a reasoning model that would have answered a second later, and it will hide a model that is simply stuck.

The same arithmetic is the invoice. Input tokens are the prompt, the retrieved passages and the history. Output tokens are the answer plus any hidden reasoning. A RAG call with five long chunks is mostly input. Shortening the chunks, which is a retrieval decision, often saves more than swapping the model.

You can see the split on any server that returns usage:

curl -s "$OPENAI_BASE_URL/v1/chat/completions" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"llama","messages":[{"role":"user","content":"Say ready"}],"max_tokens":16}' \
  | python -c 'import json,sys; u=json.load(sys.stdin).get("usage",{}); print(u)'

prompt_tokens and completion_tokens are the numbers to write next to a test. If the endpoint is not up yet, skip the call. The field names are the same on vLLM and on NIM. Running models is where that URL starts pointing at your own cluster.

Structured output

When the next step is a program, ask for a shape and parse it. A JSON schema, or a tool call with typed fields, beats "reply in JSON" as a sentence in the prompt. The model can still emit invalid JSON. Your code checks, and on failure you either retry once or route the same prompt to a person. A regex that "usually" extracts the amount will be wrong on the day the model adds a sentence before the number.

Stopping at the closing brace, with max_tokens large enough for the object and small enough to bound a runaway, is part of the call. The same curl as above, with a response format your server supports, is how you see whether this checkpoint honours the schema. Record that next to the revision. A checkpoint that ignores the schema is a different operational problem from a checkpoint that fills the fields incorrectly. Both show up as a failed parse. Log which one it was. A retry that does not record the raw completion will hide a model that never closes the brace.

What this is not

A model file is not an application. Around it you still need a way to serve it, a way to send prompts, a place for documents if the answers must come from them, a log of what was asked, and a person responsible when the answer affects a customer or a citizen. Those are the later labs in this series and the AI applications series.

Classic machine learning — a fraud score, a gradient-boosted tree, a forecast — is also "a model", and it is usually the right one when the question is a number from rows you already store. Types of models separates that from a language model so the two do not get bought as if they were the same product.

A parameter count, a token count and a temperature are the three numbers worth writing down after this page. Everything later in the series is about which file you load and what you are allowed to send it.

What's next

Types of models covers language, embedding, reranking, vision, speech, image generation and classic ML. Model sizes and specs is how to read the parameter count, the context window and the GPU memory from a model card.