# TypeError: Text input must be of type `str` (single example), `List[str]` (batch) or `List[List[str]]` (batch of sequences). Received type: <class 'int'>

- **ID:** `huggingface/tokenizer-typeerror-nonstring`
- **Domain:** huggingface
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 92%

## Root Cause

The tokenizer received a non-text input type (e.g., integer, float) instead of expected string types.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| transformers>=4.20.0 | active | — | — |

## Workarounds

1. **Convert integer inputs to strings before tokenization: `tokenizer(str(123))` for single ints, or `tokenizer([str(x) for x in [1, 2, 3]])` for lists of ints.** (90% success)
   ```
   Convert integer inputs to strings before tokenization: `tokenizer(str(123))` for single ints, or `tokenizer([str(x) for x in [1, 2, 3]])` for lists of ints.
   ```
2. **Ensure your data pipeline outputs string types. If using a dataset, map with `dataset = dataset.map(lambda x: {'text': str(x['label'])})` to convert columns.** (85% success)
   ```
   Ensure your data pipeline outputs string types. If using a dataset, map with `dataset = dataset.map(lambda x: {'text': str(x['label'])})` to convert columns.
   ```

## Dead Ends

- **** — While `str(123)` works for a single int, if the input is a list of ints like `[1, 2, 3]`, `str([1,2,3])` produces a single string '[1, 2, 3]' which the tokenizer will tokenize incorrectly as a single sequence of characters, not as three separate tokens. (70% fail)
- **** — `tokenizer.encode` also performs type checking and will raise the same error for non-string inputs. It is not a bypass. (95% fail)
