Show code
from pathlib import Path
import sentencepiece as spm
import pandas as pdApril 14, 2020
“In this notebook I try to build sentencepiece tokenizers for தமிழ் language with data extracted from wiki dump”
You can find the blog post regarding extraction here and kaggle notebook with output here
| id | url | title | text | |
|---|---|---|---|---|
| 0 | 48482 | https://ta.wikipedia.org/wiki?curid=48482 | தென் துருவம் | தென் துருவம் தென் முனை தென் துருவம் என்பது புவ... |
| 1 | 48485 | https://ta.wikipedia.org/wiki?curid=48485 | ஆர்க்டிக் வட்டம் | ஆர்க்டிக் வட்டம் ஆர்க்டிக் வட்டம் என்பது ஐந்து... |
| 2 | 48486 | https://ta.wikipedia.org/wiki?curid=48486 | நாஞ்சில் நாடன் | நாஞ்சில் நாடன் நாஞ்சில் நாடன் பிறப்பு திசம்பர்... |
| 3 | 48492 | https://ta.wikipedia.org/wiki?curid=48492 | டிக்கோயா | டிக்கோயா டிக்கோயா இலங்கையின் மத்திய மாகாணத்தின... |
| 4 | 48493 | https://ta.wikipedia.org/wiki?curid=48493 | நள்ளிரவுச் சூரியன் | நள்ளிரவுச் சூரியன் நள்ளிரவுச் சூரியன் அல்லது த... |
We can pass a list of files as a comma seperated string according to documentation, So we can store each article in a text file and pass the names in a comma seperated string.
(133412, 133412)
All the files have been converted to texts
Let’s make a comma seperated string of filenames
'/kaggle/working/texts/text_40902.txt,/kaggle/working/texts/text_44212.txt,/kaggle/working/texts/text'
We must find the right vocab_size for the tokenizer, that can be done only by testing the tokenizer after building onw
Training with vocab set as: 8000
Training with vocab set as: 16000
Training with vocab set as: 20000
Training with vocab set as: 30000
Let’s test the models in another notebook, you can find the outputs in this kaggle notebook