Contents

LanguageModelSession.GenerationError.exceededContextWindowSize(_:)

An error that signals the session reached its context window size limit.

Declaration

case exceededContextWindowSize(LanguageModelSession.GenerationError.Context)

Mentioned in

Discussion

This error occurs when you use the available tokens for the context window of 4,096 tokens. The token count includes instructions, prompts, and outputs for a session instance. A single token corresponds to approximately three to four characters in languages like English, Spanish, or German, and one token per character in languages like Japanese, Chinese, and Korean.

Start a new session when you exceed the content window size, and try again using a shorter prompt or shorter output length.

For more information on managing the context window size, see TN3193: Managing the on-device foundation model’s context window.

See Also

Generation errors