Views
No views yet
Byte-Pair Encoding (BPE) approach to create a vocabulary of 50,000 tokens, catering specifically to the intricacies of the Arabic language.PyTorch.
In adherence to the configurations outlined in the official BART paper, which specifies the use of BPE tokenization, I sought a BPE tokenizer specifically tailored for Arabic.
While there are Arabic-only tokenizers and multilingual BPE tokenizers, a dedicated Arabic BPE tokenizer was not available. This gap inspired the creation of a BPE tokenizer focused solely on Arabic, ensuring alignment with BART's recommended configurations and enhancing the effectiveness of Arabic NLP tasks.IsmaelMousa/arabic-bpe-tokenizer50,000tokenizers library for seamless tokenization.tokenizers library. If you haven’t installed it yet, you can do so using pip:pip install tokenizerstokenizers library.1from tokenizers import Tokenizer
2
3tokenizer = Tokenizer.from_pretrained("IsmaelMousa/arabic-bpe-tokenizer")
4
5text = "لاشيء يعجبني, أريد أن أبكي"
6
7encoded = tokenizer.encode(text)
8decoded = tokenizer.decode(encoded.ids)
9
10print("Encoded Tokens:", encoded.tokens)
11print("Token IDs:", encoded.ids)
12print("Decoded Text:", decoded)
131Encoded Tokens: ['<s>', 'ÙĦا', 'ĠØ´ÙĬØ¡', 'ĠÙĬع', 'جب', 'ÙĨÙĬ', ',', 'ĠأرÙĬد', 'ĠØ£ÙĨ', 'Ġأب', 'ÙĥÙĬ', '</s>']
2
3Token IDs: [0, 419, 1773, 667, 2281, 489, 16, 7578, 331, 985, 1344, 2]
4
5Decoded Text: لا شيء يعجبني, أريد أن أبكي MIT License.