Ask a language model to finish the sentence "She opened the door and" and it will. It might say "stepped inside". Ask again and it might say "froze". It did not think of a woman or a door. It did something stranger and, once you see it, easier to work with.

One word at a time

A language model is a system for answering a single question: given the text so far, what comes next?

It does not answer with one word. It produces a probability for every word it knows. After "She opened the door and", the word "stepped" might get eight per cent, "saw" seven, "froze" two, "sang" a tiny fraction of one. Then one word is chosen, added to the text, and the whole question is asked again with the longer text. A paragraph is that loop run a few hundred times.

(The units are strictly "tokens", which are pieces of words, but "words" is close enough to reason with.)

Where do the probabilities come from? From training. The model was shown a very large amount of written text with the next word hidden, and adjusted, billions of times, to make better guesses. Nobody wrote down rules of grammar or plot for it. Whatever it knows about how a detective story goes, it absorbed as patterns in which words follow which.

Why it does not always pick the likeliest word

If the model always chose the top-ranked word, every answer to the same prompt would be identical, and the prose would be oddly lifeless. So there is a setting, usually called temperature, that controls how adventurous the choice is.

At a low temperature it nearly always takes the favourite. The result is safe, coherent and dull. At a high temperature it reaches further down the list, and you get surprise, then strangeness, then nonsense.

For a writer this is the most useful dial there is, and it explains an experience many people have had. The model's first suggestion for a metaphor is the one everyone would think of, because that is precisely what "most probable" means. It is the average of everything already written.

What follows from that

A few things that puzzle people stop being puzzling.

It is fluent before it is right. The model is optimised to produce text that reads as plausible. A confident sentence with a made-up fact in it is plausible. When it invents a quotation or a book that does not exist, it is not lying; it is continuing the pattern of what such a sentence usually looks like. Anything factual needs checking somewhere else.

It gravitates to the expected. Ask for a story about a lighthouse keeper and you will get loneliness, a storm and a secret, because that is what lighthouse stories contain. The cliché is not a malfunction. It is the centre of the distribution.

It only knows what is on the page. The model has no memory of your novel beyond the text you give it in this conversation. If you want it to respect that your narrator never uses contractions, that fact has to be in front of it.

It imitates readily. Give it three paragraphs in a distinct voice and ask it to continue, and it will do better than if you describe the voice in adjectives. Examples carry more information than instructions.

Using it without losing your own work

This is a matter of taste, and writers disagree strongly. What follows is one practical approach, not a rule.

Ask for twenty, not one. The first answer is the most probable one. The seventeenth may be the interesting one. "Give me twenty things that could be in this character's coat pocket" is a better use than "what is in her pocket?", and you will probably use none of the twenty but think of a twenty-first.

Use it as a reader. Paste a scene and ask what a reader would assume about the characters' relationship. If the answer is not what you intended, you have learnt something about your draft, whatever you think of the model's taste.

Give it the dull jobs. A summary of what happened in chapters one to nine. A list of every time a character's eye colour is mentioned. A timeline. These are tasks where "plausible and complete" is exactly what you want, though spot-check them.

Keep the turns. The moment where a story goes somewhere the reader did not expect is, almost by definition, a low-probability continuation. That is the part a predictor of likely text is worst at, and the part that is most yours.

Rewrite everything you keep. Prose generated by a model tends towards an even, well-behaved rhythm. Readers have started to recognise it. Running it through your own sentences is the difference between using a tool and being replaced by one.

Questions worth settling for yourself

There are real disagreements here, and it would be wrong to pretend otherwise.

Some writers hold that any use of generated text makes the work not theirs. Others use these tools as they would a thesaurus. Publishers, competitions and magazines have their own rules, and many now ask you to declare use; check before you submit.

There are also unresolved arguments about the texts these systems were trained on, and whether the authors of those texts should have been asked or paid. Courts and legislatures in several countries are still working through them.

None of that changes the mechanics. The model predicts the next word from the words so far. It is very good at the probable, and the probable is what a story mostly has to avoid.

A small exercise makes the point better than any explanation. Take the opening line of something you are writing and ask a model for the next sentence, five times. Read the five. Then write a sixth that none of them would have produced. That one is the reason to keep writing.