Syntax is the set of structural rules that makes an expression or program valid. A nearly correct answer still fails when brackets, special characters, or language rules are wrong. section 5.1.3
Generated text can violate syntax in several practical ways:
- A JSON response fails when opening and closing brackets do not match or special characters are encoded incorrectly. section 5.1.3
- Code fails to compile when it borrows valid-looking syntax from another language, such as Python syntax in Modula-3. section 5.1.3
- Programming languages can share patterns such as indentation, variables, function names, return statements, and operators without sharing identical syntax. section 6.1
Figure 6.2 Two similar samples of code written in the programming languages Python (left) and Java (right). These show how byte-pair encoding can identify similar tokens across different languages. The boxes show individual tokens. Standard tokenization methods for human languages do a reasonable job on code since it has many similarities to natural language.
Compare Python and Java code samples to see shared tokens and coding patterns alongside language-specific syntax. section 6.1


