liveBook · Manning

End of text token

As explained in Server-Side WebAssembly

An end-of-sequence token is a special model token indicating that generated text should terminate.

An end-of-sequence (EOS) token marks the conclusion of generated text. During story generation, the model samples tokens until it produces EOS or another stopping condition intervenes. section 5.4.2

Use EOS as one part of a bounded generation loop:

  • Retrieve the EOS token ID from the tokenizer, falling back to 0 when the marker is unavailable. section 5.4.2
  • Generate tokens inside a loop capped at 100 iterations, preventing unbounded output. section 5.4.2
  • Stop when the sampled token equals the EOS ID, or when decoded text contains a paragraph break. section 5.4.2
if generated_text.ends_with("\n\n") {
    break;
}

if next_token as u32 == eos_token_id {
    break;
}

Inspect the Rust stopping checks that combine paragraph-break detection with EOS-token comparison. section 5.4.2

How Server-Side WebAssembly covers it

How deep it goes
Explains lookup, fallback behavior, bounded looping, and alternative stopping checks without detailing token-model internals.
Examples
Uses the prompt “Once upon a time” and a Rust loop that samples tokens until EOS or a paragraph break.
What it assumes
Assumes tokenization and model inference, while showing how to obtain token IDs and decode generated text.
What you can do after
Apply it via Rust token-generation code with EOS lookup and explicit safeguards against runaway output.
How it connects
Connects tokenizers, text generation, model inference, sampling, and stopping criteria.

Also explained in

Compare how 5 books explain end of text token →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Server-Side WebAssembly. The section links point to the parts of the book it draws on.