Downloads · 30 days
0
Xenova/claude-tokenizer
claude-tokenizer is a machine learning model from Xenova. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as mit.
A 🤗-compatible version of the Claude tokenizer (adapted from anthropics/anthropic-sdk-python). This means it can be used with Hugging Face libraries including Transformers, Tokenizers, and Transformers.js.
Downloads · 30 days
0
Access
Public
Updated Apr 30, 2024
Repo size
—
Likes
24
Public
Click a slice to open those files.
.json1.8 MB · 100%
From the Hugging Face model README
A 🤗-compatible version of the Claude tokenizer (adapted from anthropics/anthropic-sdk-python). This means it can be used with Hugging Face libraries including Transformers, Tokenizers, and Transformers.js.
from transformers import GPT2TokenizerFast
tokenizer = GPT2TokenizerFast.from_pretrained('Xenova/claude-tokenizer')
assert tokenizer.encode('hello world') == [9381, 2253]
import { AutoTokenizer } from '@xenova/transformers';
const tokenizer = await AutoTokenizer.from_pretrained('Xenova/claude-tokenizer');
const tokens = tokenizer.encode('hello world'); // [9381, 2253]