Giter VIP home page Giter VIP logo

tokenizers's Introduction

tokenizers

This repository contains several unsupervised text tokenizers for the Turkish language trained on two large datasets:

  1. Turkish part of the OSCAR corpus that contains ~30GB of raw text
  2. +4000 books (~5GB)

The repository has two folders: (1) cased contains models trained on the cased version of the corpus, (2) lowercased, on the other hand, contains models trained on the lowercased version of the corpus. We also provide models trained with different frameworks.

Files with the sp prefix are trained with the sentencepiece framework. This framework also provides an additional file for each model that ends with vocab and contains all the tokens in raw text format.

Files have the following naming convention

sp_bpe_(lower)<vocab_size>_<sentence_size>

where sentence size represents the number of sentences used to train the model and lower only exists when the model is lowercased.

Hands On

In order to install the sentencepiece module, issue the following command
pip install sentencepiece.

import sentencepiece as spm
sp = spm.SentencePieceProcessor(model_file='lowercased/sp_bpe_lower40k_50M.model')
print(sp.encode_as_pieces("Gelecekte, konuşma sentezleyiciler ve konuşma anlama alanındaki gelişmeler ve makine-insan iletişiminin gelişmesi, insanın makineden beklentilerini yükseltecektir.".lower()))
# => ['▁gelecekte', ',', '▁konuşma', '▁sentez', 'leyiciler', '▁ve', '▁konuşma', '▁anlama', '▁alanındaki', '▁gelişmeler', '▁ve', '▁makine', '-', 'insan', '▁iletişim', 'inin', '▁gelişmesi', ',', '▁insanın', '▁makin', 'eden', '▁beklentilerini', '▁yüksel', 'tecek', 'tir', '.']
print(sp.encode("Gelecekte, konuşma sentezleyiciler ve konuşma anlama alanındaki gelişmeler ve makine-insan iletişiminin gelişmesi, insanın makineden beklentilerini yükseltecektir.".lower()))
# => [9334, 39762, 3935, 17962, 37042, 38, 3935, 4222, 13612, 5668, 38, 6612, 39776, 10661, 2627, 149, 11346, 39762, 2489, 2371, 290, 23596, 1591, 13135, 177, 39758]
sp.piece_to_id("gelecek")
# => 34536

Models that have the yttm prefix are trained with the YouTokenToMe framework. YTTM models, as opposed to sentencepiece models, are trained on the whole corpus (187M sentences) without sampling.

Hands On

Install the module by running pip install youtokentome in order to use the tokenizer.

import youtokentome as yttm
model = yttm.BPE('lowercased/yttm_lower50K.model')
print(model.encode("Gelecekte, konuşma sentezleyiciler ve konuşma anlama alanındaki gelişmeler ve makine-insan iletişiminin gelişmesi, insanın makineden beklentilerini yükseltecektir.".lower(), output_type=yttm.OutputType.SUBWORD))
# => ['▁gelecek', 'te,', '▁konuşma', '▁sentez', 'leyiciler', '▁ve', '▁konuşma', '▁anlama', '▁alanındaki', '▁gelişmeler', '▁ve', '▁makine', '-', 'insan', '▁iletişim', 'inin', '▁geliş', 'mesi,', '▁insanın', '▁makin', 'eden', '▁beklentilerini', '▁yüksel', 'tecek', 'tir.']
print(model.encode("Gelecekte, konuşma sentezleyiciler ve konuşma anlama alanındaki gelişmeler ve makine-insan iletişiminin gelişmesi, insanın makineden beklentilerini yükseltecektir.".lower(), output_type=yttm.OutputType.ID))
# => [2358, 3930, 3982, 18637, 45797, 385, 3982, 4576, 14738, 5470, 385, 7622, 42, 12117, 3732, 498, 1066, 4156, 3070, 2774, 643, 25767, 2023, 14498, 795]

Appendix

For more information regarding the frameworks refer to the following repositories:

and for the BPE and subwords:

tokenizers's People

Contributors

azadyasar avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.