# tinker_cookbook.utils.format_colorized ### [**tinker_cookbook.utils.format_colorized**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/utils/format_colorized.py#L6)(*tokens*, *weights*, *tokenizer*, *draw_newline_arrow*) Colour-code text according to per-token weights. Tokens are coloured green (weight > 0), yellow (weight == 0), or red (weight < 0). The function minimises ANSI escape sequences by wrapping *runs* of like-coloured tokens, and decodes each run in a single call so that multi-byte characters (e.g. CJK) render correctly. **Parameters:** - [**tokens**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/utils/format_colorized.py#L7) (*list[int]*) – Token IDs to decode and display. - [**weights**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/utils/format_colorized.py#L7) (*list[float]*) – Per-token weight values (same length as *tokens*). - [**tokenizer**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/utils/format_colorized.py#L7) (*Tokenizer*) – Tokenizer used to decode token IDs to text. - [**draw_newline_arrow**](https://github.com/thinking-machines-lab/tinker-cookbook/blob/main/tinker_cookbook/utils/format_colorized.py#L7) (*bool*) – If `True`, render newlines as a visible arrow (`↵`) followed by an actual newline. **Returns:** *str* – ANSI-coloured string suitable for terminal display. **Raises:** - ValueError: If *tokens* and *weights* have different lengths. ```python text = format_colorized(token_ids, loss_weights, tokenizer) print(text) ```