wAIpoint
Italiano

Language models

Level: Beginner

What it is

A language model is a program that, given some text, estimates how likely each possible next piece of text is. Repeat that step and it can continue a sentence, answer a question or write code. Older models counted word sequences; modern ones are neural networks with billions of parameters.

What it is for

Autocomplete, translation, summaries, chat assistants, search, writing help. A language model is the engine inside a chatbot: the same basic skill, predicting what comes next, covers a surprising number of tasks.

How to do it

The process, step by step. Libraries and tools change; these steps stay.

  1. Understand the loop: the text is cut into tokens (word pieces), the model scores every possible next token, one is chosen, added to the text, and the loop repeats.
  2. Use an existing model through a chat app or an API instead of training your own: training from scratch needs huge data and computing power.
  3. Write a clear prompt: say the task, give the context it needs and, if useful, an example of the answer you want.
  4. Control the output with settings such as temperature (low = predictable, high = more varied) and a maximum length.
  5. Check the result: a language model can produce fluent text that is wrong, so verify facts that matter.
  6. If the model is not good enough for your task, move up to better prompts, retrieval of your own documents, or fine-tuning, in that order.

Timeline

  1. 2020GPT-3: scaling up language models for few-shot learning (Brown et al.). source

Sources