Downloads · 30 days
0
gsar78/tokenizer_BPE_en_el
tokenizer_BPE_en_el is a machine learning model from gsar78. 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.
English & Greek Tokenizer trained from scratch
Downloads · 30 days
0
Access
Public
Updated Jul 4, 2024
Repo size
—
Likes
0
Public
Click a slice to open those files.
.json1.3 MB · 100%
From the Hugging Face model README
English & Greek Tokenizer trained from scratch
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("gsar78/tokenizer_BPE_en_el")
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("gsar78/tokenizer_BPE_en_el")
# Tokenize input text
input_text = "This is a game"
inputs = tokenizer(input_text, return_tensors="pt")
# Print the tokenized input (IDs and tokens)
print("Token IDs:", inputs["input_ids"].tolist())
# Convert token IDs to tokens
tokens = tokenizer.convert_ids_to_tokens(inputs["input_ids"][0])
print("Tokens:", tokens)
# Manually join tokens to form the tokenized string
tokenized_string = ' '.join(tokens)
print("Tokenized String:", tokenized_string)
# Output:
Token IDs: [[2967, 317, 220, 1325]]
Tokens: ['This', 'Ġis', 'Ġa', 'Ġgame']
Tokenized String: This Ġis Ġa Ġgame
When tokenizing Greek, Greek tokens may appear as gibberish, but actually this does not impact the downstream model pretraining.
(An improved version of this tokenizer, without the gibberish Greek tokens can be found here: gsar78/Greek_Tokenizer)
Can be used a good start for pretraining a GPT-based model or any other model using BPE.