File size: 923 Bytes
e455a4b 10f6b37 e455a4b 10f6b37 e455a4b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
---
license: mit
library_name: transformers
tags:
- transformers.js
- tokenizers
---
# GPT-4o Tokenizer
A 🤗-compatible version of the **GPT-4o tokenizer** (adapted from [openai/tiktoken](https://github.com/openai/tiktoken)). This means it can be used with Hugging Face libraries including [Transformers](https://github.com/huggingface/transformers), [Tokenizers](https://github.com/huggingface/tokenizers), and [Transformers.js](https://github.com/xenova/transformers.js).
## Example usage:
### Transformers/Tokenizers
```py
from transformers import GPT2TokenizerFast
tokenizer = GPT2TokenizerFast.from_pretrained('Xenova/gpt-4o')
assert tokenizer.encode('hello world') == [24912, 2375]
```
### Transformers.js
```js
import { AutoTokenizer } from '@xenova/transformers';
const tokenizer = await AutoTokenizer.from_pretrained('Xenova/gpt-4o');
const tokens = tokenizer.encode('hello world'); // [24912, 2375]
``` |