Beginning AI Applications in Tamil – Keras Tutorial

Starting from my first AI application, tamil/english word classification to transitioning into a full-time AI compiler/performance engineer today I have made a career transformation of sorts; I am sharing some information from my learnings here at INFITT-2021 workshop on Keras and beginning AI apps in Tamil.

#infitt2021 தமிழ் கணிமை மாநாட்டிற்கு பயிற்சி பட்டறை அளிக்கிறேன்

  • Download Presentation below:

Key points:

  • தமிழ் இணைய மாநாடு தொடர்பான பட்டறைக்கு உருவாக்கிய iPython புத்தகங்களை பொதுவளியில் இங்கு வைக்கிறேன்; ஆர்வமுள்ளவர்கள் பயன்படுத்தியும், பின்னூட்டங்கள் தரலாம். Notebooks and exercises can be found here https://github.com/Ezhil-Language-Foundation/open-tamil/tree/main/examples/keras-payil-putthagangal
  • AI can be biased based on training algorithms, or data, or both:

“Coded Bias” – சமுகத்தில் உள்ள ஒடுக்குமுறைகளை செயற்கையறிவில் வரையறுப்பது சரியா? #aiethics #ai-side-effects;

குப்பம்மா – உளிவீரன் அப்படின்னு பெயர்வெச்சா கடன் அட்டை கிடைக்காமல் போகவும் ராகுல், ப்ரியா என்று பெயர் வைத்தால் கிடைப்பதற்கும் உள்ள வித்தியாசம் தான் “Coded Bias” – எனில் செயற்கைஅறிவு உங்களுக்கு இது கிடைக்குமா என்ற தீர்வை கணிக்கும் நிலையில் உள்ளோம்! யாரிடம்திறவுகோல் உள்ளது?

நன்றி

-முத்து

தமிழ் கணிமைக்கு செயற்கையறிவு சேவைகள்

இந்திய அழகியல் - விருந்தினர்கு வர்வேர்ப்ரை விளக்கு
இந்திய அழகியல் – விருந்தினர்கு வரவேர்ப்பறை விளக்கு. புதிய தொடக்கம்.

ஊருக்கு உபதேசம் இல்லாமல், தங்களது சேவைகளின் பயன்களை தாமே முதலில் பயன்படுத்துவதை ‘Eating your Dog Food‘ என்று கணினியாளர்கள் மத்தியில் பேசப்படுவதாவது.

இதன்படி தமிழ்கணிமைக்கு உதவும் வகையில் நேரடியாக தானியங்கி, செயற்கையறிவு சேவைகளை முதலில் தனது பயன்பாட்டிற்கு தமிழ் கணினியாளர்கள் கையாளவேண்டும்.

எனது பார்வையில் முதல்படி தேவைப்படும் சேவைகளானது:

  1. தானியங்கி வழி, கணினி உதவி ஆவனங்கள், பயிற்சி நூல்களை (training, tutorial manuals) மொழிபெயர்ப்பது
    • இந்த நூல்கள் அனைத்தும் சில கலைச்சொற்கள் தவிர மற்ற்வை அனைத்தும் ஒரே கோனத்தில் இருப்பவையாகின்றன. தானியங்கி மொழிபொயர்ப்பு செயலிகள் சரியனவையாக அமையும்.
    • இதன் முக்கியத்துவத்தை அதிகப்படுத்தி சொல்லமுடியாது. ஒவ்வொரு கலைசொல் அடங்கிய புத்தகமும் வெளிக்கொண்டுவர பல மாதங்களில் இருந்து சில ஆண்டுகள் ஆகின்றன – இந்த கால தாமத்தை குறைக்க வேண்டும்.
    • முக்கியமாக எனது பார்வையில் இந்த நூல்கள் விரைவில் தமிழாக்கம் ஆகவேண்டும்
      • Python மொழி உதவி ஆவணங்கள்
      • TensorFlow செயற்கையறிவு மென்பொருள் கட்டமைப்பு உதவி ஆவணங்கள்
  2. வீடியோ வழி, ஒலி வழி – உரை, கட்டுரை, நூல்கள் உருவாக்க செயற்கையறிவு செயலிகள்
    • தமிழில் கணினி சார்ந்த தகவல்களை தமிழ் கணினியாளர்கள் நேர்வழி பங்களிப்பதும் பயன்படுத்துவதற்கும் ASR, OCR, Video close-captioning, போன்ற செயல்பாடுகள் பலரையும் தமிழ்கணிமைக்குள் வரவேர்க்க உதவும்.
    • புதிய கருத்துக்களையும், புதிய தகவல்களையும் தமிழிலேயே உருவாக்க இது உதவும்
  3. செயற்க்கையறிவு அணிமாதிரிகளை பொதுவாக “Model Zoo” என்று அருங்காட்சியகமாக பயன்படுத்துவது.
    • தமிழுக்காக பலரும் தங்களது செயற்கையறிவு கருவிகளை உருவாக்குகின்றனர். இவற்றில் பயிற்சி செய்வது ஆகக்கடினமானது, அதிக நேரம் கணிமை செலவெடுக்கும் வழியில் ஆனது. எனவே இவற்றை முடிந்த அளவில் பொதுவெளி (public domain) உரிமத்தில் வெளியிடல் சிறப்பானது
    • இதன் முதல் முயற்சி GitHub-இல் அருங்காட்சியகம்
  4. தமிழ் அகழாய்வு பற்றிய உதவி செயலிக்கள் (சற்று திசைமாரி மேல் சொன்னமாதிரி இந்த பயன்பாடு கணிமைக்கு நேர்வழி உதவாதது என்க்கு புலப்படுகின்றது)
    • ஒரு பானை ஓட்டில் எழுதப்பட்ட சொல் தமிழ், தமிழி (பிரமி), அல்லது எண்களா? அல்லது எழுத்துக்களா? என்பதனை கண்டறிய பொதுமக்கள் கைபேசியில் சொயலிகளின் வழி நிறுவி தொல்லியல் வல்லுநர்களுக்கு சிறந்த சரியான தகவல்கள் அளிக்கும் வகை இந்த செயலிகள் உதவும்.

மேலும் தமிழ் மொழி கல்வி, சிந்தனைக்களம், தகவல் பரிமாற்றம் போன்றவற்றைப்பற்றி நீங்களும் சிந்தியுங்கள் – கருத்துக்களை இந்த வலையில், அல்லது மின் அஞ்சலிலும் பதிவிடுங்கள்.

நன்றி.

 

Deep Learning – ஆழக்கற்றல்

ஆழக்கற்றல் பற்றிய சிறப்பான புத்தகம் ஒன்று இயன் குட்பெல்லோ, யொசுவா பென்ஜியோ மற்றும் ஆரன் கூவில் அவர்களால் 2016 நவம்பர்மாதத்தில் எழுதப்பட்டு MIT பல்கலைக்கழகத்தின் பதிப்பகத்தால் பரிசுரம் ஆனது. (இதனை இன்று என் கைகளில் நான் பெற்றதால் அதனை பற்றிய சிறிய பின் அட்டை விவரத்தை தமிழாக்கம் செய்வதில் ஒரு ஆர்வம், முயற்சி.) இந்த புத்தகம் அமேசானில் இங்கு அமெரிக்காவில் முப்பத்தாறு வெள்ளி மதிப்பில் வாங்கலாம்.

படம் 1: ஆழக்கற்றல் பற்றிய சிறப்பான புத்தகம் ஒன்று இயன் குட்பெல்லோ, யொசுவா பென்ஜியோ மற்றும் ஆரன் கூவில் அவர்களால் 2016 நவம்பர்மாதத்தில் எழுதப்பட்டு MIT பல்கலைக்கழகத்தின் பதிப்பகத்தால் பரிசுரம் ஆனது.

ஆழக்கற்றல் என்பது ஒருவகையான இயந்திர கற்றல் தொழில் நுட்பம். இதன் வழி கணினி அனுபம் மூலம், தினசரி பழக்கங்கள், பயன்பாட்டின் வாயிலான உதாரணங்களின் வழி, உலக வழக்குகளையும், அதன் படிநிலைகளையும், அதன் தொடர்புகளையும் தன்னைத்தானே உணரும் குனம் /தன்மை கொண்ட ஒரு தொழில்நுடபமாக அமைவதன் சிறப்பைக் கொண்டது ஆழக்கற்றல். கணினி தன்னாலேயே விதிகளை உதாரணத்தின் வாயிலாக உணர்வதால், ஒரு தனி கணினி இயக்குனர் / அல்லது நிரலாளர் தேவையில்லை; இதன் வழி அடிப்படை விதிகளை பட்டியலிட்டும் நிரல்படுத்தும் நிபந்தனைகளின் கட்டுப்பாட்டில் இருந்து நிரலாளர் விடுவிக்கப்படுகின்றார். கற்கும் செயலின் படிநிலை மனஉருக்களை கணினி ஒவ்வொரு கட்டமாக எளிதான நிலையில் இருந்து படிப்படியாக முனை-ஓர (கிராப்) எண்ணிம வடிவங்களின் படி இவற்றை ஆழமான நிலைவரை அடுக்கடுக்காக நிலைப்படுத்தி ஒரு செயலை கற்றுகுகொள்கிறது. (எனவே இதனை ‘ஆழக்கற்றல்’ என்று கூறுகிரோம்.) இந்தப் புத்தகத்தில் பலவிதமான ஆழக்கற்றல் தலைப்புகளை முன்வைக்கிறோம்.

இந்த பாடப்புத்தகம் ஆழக்கற்றல் கூறுகளை கற்றுக்கொள்ளத் தேவையான கணிமை, தகவல் தொழில்நுட்ப கணிமை, யுகிப்புக் கணிமை, எண்சார் கணிமை, மற்றும் இயந்திர கற்றல் அடிப்படை விஷயங்களையும் வழங்குகிறது. இதில பன்னாட்டு உலக்ப்புகழ்பெற்ற நிறுவனங்களில் இன்றைக்கும் பயன்படுத்தும் தொழில்நுடபங்கள் பற்றியும், ஆழக்கற்றல் பினைப்புகள், கற்றல் செயல்முறைகள், தேர்வுமுறை/சிறப்பிக்கும் செயல்முறைகள், கான்வலூஷன் பினைப்புகள், டோக்கன் தொடர் மாதிரி உருவாக்குதல்கள் அனைத்தையும் ஒரு நடைமுறை கோனத்தில் இந்த பாடப்புத்தகம் வழங்குகிறது; மேலும் இந்த புத்தகத்தில் இயல்மொழி பகுப்பாய்வு, பேச்சு உணர்தல், கணினி பார்வை, இணையம் வழி பரிந்துரைக்கும் செயலிகள், உயிரியல் கணிமை / மரபணு கணிமை, மற்றும் விடியோ விளையட்டுக்கள் பற்றியும் ஆழக்கற்றலின் பாய்ச்சல்/உபயோகங்களையும் பற்றி அலசுகிறது. கடைசியாக ஆராய்ச்சி நோக்கில், கோட்பாடுகளின் அளவில் linear factor மாதிரிகள், தான்குறிப்பிகள் [autoencoders], முன்மாதிரி கற்றல் [representative learning], structured probabilistic மாதிரிகள், மன்டே கார்லோ மாதிரிகள், partition சார்புகள், தோராயமான யுகித்தல், ஆழ உருவாக்கும் பினைப்புகள் [deep generative models] போன்ற தலைப்புகளிலும் தற்சமயம் உள்ள அறிவியல் முன்னேற்றங்களை பற்றி அறிமுகப்படுத்துகிறது.

இந்தப் புத்தகம், இளங்கலை மாணவர்களினாலும், முதுகலை மாணவர்களலாலும், அல்லது கணினிதுறையில் முழுநேர ஊழியர்கழினாலும் ஆழக்கற்றலை பற்றி கற்கவும், செயல்படுத்தவும், உதவிகரமாக பயன்படுத்தும்படி இருக்கும். இதனுடன் இணைத்த வலைதளத்தில் மாணவர்களும், ஆசிரியர்களும் பாடம் கற்க கூடுதல் அம்சங்களை பெறலாம்.

எனது மொழி பெயர்ப்பு மூல உரை ஆங்கிலத்தில் கீழே: MIT பதிப்பகத்தில் இருந்து எடுத்த உரை

Deep learning is a form of machine learning that enables computers to learn from experience and understand the world in terms of a hierarchy of concepts. Because the computer gathers knowledge from experience, there is no need for a human computer operator to formally specify all the knowledge that the computer needs. The hierarchy of concepts allows the computer to learn complicated concepts by building them out of simpler ones; a graph of these hierarchies would be many layers deep. This book introduces a broad range of topics in deep learning. 

The text offers mathematical and conceptual background, covering relevant concepts in linear algebra, probability theory and information theory, numerical computation, and machine learning. It describes deep learning techniques used by practitioners in industry, including deep feedforward networks, regularization, optimization algorithms, convolutional networks, sequence modeling, and practical methodology; and it surveys such applications as natural language processing, speech recognition, computer vision, online recommendation systems, bioinformatics, and videogames. Finally, the book offers research perspectives, covering such theoretical topics as linear factor models, autoencoders, representation learning, structured probabilistic models, Monte Carlo methods, the partition function, approximate inference, and deep generative models. 

Deep Learning can be used by undergraduate or graduate students planning careers in either industry or research, and by software engineers who want to begin using deep learning in their products or platforms. A website offers supplementary material for both readers and instructors.


சொல்திருத்தி – தெறிந்தவை 3

இந்த தொடரில் இதுவரை ஆய்வுகளைப்பற்றி மட்டுமே இதுவரை பார்த்தோம். இப்போது சில செயல்முரை அல்கொரிதங்களை பார்க்கலாம்.

1 மேலோட்டமான சில குறிப்புகள்

சொல்திருத்தியில் பிழையான சொல் ஒன்றை முதலில் கண்டரிந்தபின், அதற்கு எப்படி ஒரு மாற்றை [என்ற ஒரு தோராயமான சொற்பிழை நீக்கப்பட்ட பொருத்தத்தை எப்படி] உருவாக்குவது ? இதற்கு தேவை திருத்தத் தொலைவு d.

இயற்ப்பியலில், புள்ளியியலில் இவ்வாரான் கேள்வியை ஒரு optimization வடிவத்தில் மாற்றி இதனை தீர்வுகாணலாம். இதனைப்போல் சொல்திருத்தியில்,

மாற்றுச் சொல் = arg-min [ d[ச,த] ]   

இதன் பொருள் என்ன என்றால் கொடுக்கப்பட்ட தவரான் சொல் த என்பதற்கு நமது செயலி அதன் அகராதியில் உள்ள ஒவ்வொரு சொல்லில்லும் அதன் தொலைவை கண்டறிந்து அவற்றில் எந்தெந்த சொற்கள் மிகக் குறைவான தொலைவில் உள்ளனவோ அவற்றையே சரியான சொல் என்ற பட்டியலில் பரிந்துரைக்கும். இதற்கு உதாரணமாக கட்டுரையின் மூன்றாவது பகுதியில் நிரல் துண்டு பார்க்கலாம்.

2 தொலைவு

தொலைவு – இரு சொற்களுக்கும் உள்ள நெறுக்கத்தை நாம் சொல்திருத்தியில் கணக்கிட வேண்டிய தேவை இருக்கிரது. ஏனெனில், ஒரு தவரான் சொல் உரையில் உள்ளீடு செய்யப்பட்டிருந்த்தால் அதற்கு மாற்றை தானியங்கி வழியில் கண்டறிய [அதவது இதன் மாற்றுச்ச்சொல்] இதற்கு பொருத்தமாகவும், நேருக்கமாகவும் இருக்கும் என்பது கணினியாளர்களும், மொழியியலாளர்களும் ஒப்புக்கொண்ட ஒரு கோட்பாடு. இதனை செயல்படுத்த கணினியாளர்கள் கொண்ட ஒரு மதிப்பீடு தொலைவு. இதனை திருத்தத் தொலைவு என்று சொல்வார்கள் [edit-distance].

ஒரு சொல்லினை அதன் உருப்பு எழுத்துக்களை இடம் மாற்றியோ, எழுத்துக்கள் கூட்டியே, அல்லது எழுத்துக்கள் நீக்கியோ மற்றொரு சொல்லாக மாற்ற எத்தனை படிகள் உள்ளன என்று கணக்கிட்டு சொல்வதானது இத்தகைய திருத்தத் தொலைவு சார்பு. இதனை கண்டுபிடித்த பலருள் திரு லெவின்ஷ்டீன் அவரது பெயரை இணைத்து லெவின்ஷ்டீன் திருத்தத் தொலைவு என்று கூறுகின்றார்கள் அறிவியலாளர்கள்.

இதன் பொருள் என்ன ? இதன் அமைப்பு எப்படிபட்டது ? கணிதவியலில், தினசரி வாழ்வில் எப்படி தொலைவு நிர்னயிக்கப்படுகிரது என்து போல், ஒரே இடத்தில் உள்ள பொருளுக்கும் அதே பொருளுக்கும் தொலைவு எதுவும் இல்லை – 0. அதே மாதிரி ஒரே சொல்லிர்கும் அதே சொல்லின் நகலுக்கும் தொலைவு 0. பிரகு, உங்கள் வீட்டிற்கும் உங்கள் பக்கத்துவீட்டிற்கும் தொலைவு என்ன ? தொலைவு 1 அல்லது கூடுதலாகவே இருக்கவேண்டும் இல்லையா ? பக்கத்து வீட்டார்க்கும் உங்கள் வீட்டிற்கும் உள்ள தொலைவு, உங்கள் வீட்டிற்கும் அவர்களது வீட்டிற்கும் உள்ள தொலைவும் ஒரேபடியானதாக இருக்கும். d[a,b] = d[b,a] என்பது ‘commutativity‘ என்ற சார்பின் குணத்தை இந்த திருத்த தொலைவு சார்பும் கொண்டது. [அதையும் – ‘போத்திக்குனு படுத்துக்கலாம், படுத்துக்குனு போத்திக்கலாம்‘ என்று பல முதிய தமிழ் மைக்கில் ஜாக்சன்கள் சொல்லியதை நினைவு கொள்ளலாம்]. அதுவே பொது அறிதல். இதைப்பொல குணங்களைக்கொண்ட சார்புகளை கணிதவியலில் ‘metric‘ என்றும் சொல்வார்கள் – அதாவது அளக்கும் சார்பு.

3 சிரிய எடுத்துக்காட்டு

ஒப்பன் தமிழ் நிரல் தொகுப்பில் ஒரு சில் உத்திகள் உள்ளது அவற்றில் திருத்தத் தொலைவு சார்பும் ஒன்று. இதனைக் கொண்டு ஒரு சிரிய உதாரனத்தை பார்க்கலாம்.

அகராதியில் உதாரனத்திற்கு 5 சொற்கள் இருக்கு என்று மட்டும் கொள்ளல்லாம்.

அகராதி A என்பதில் [‘அவிழ்’,’அவல்’,’அவள்’,’தவில்’,’தவள்’] என்ற் சொற்கள் இருக்கு என்றும் உள்ளிட்டு சொற்கள் ‘ஏவள்’, ‘இவல்’ என்று கொடுக்கபட்டது என்றும் கொள்வோம். இதற்கு என்ன மாற்றுக்கள் ?

பகுதி ஒன்றின் படி இந்த புள்ளியியல் குரைந்த பட்ச தெடலை பைத்தான் மொழியில் இப்படி எழுதலாம்:

இதனை இயக்கினால் நாம் பார்கக்கூடிய வெளியீடு இப்படி; அதாவது நமது சிரிய சொல்திருத்தி அல்கொரிதம் ‘ஏவள்’ என்பதை ‘அவள்’ என்றும், ‘இவல்’ என்பதை ‘அவல்’ என்றும் மாற்றாக பரிந்துரைக்கிரது. மேலும் கவனித்து பார்த்தால் ‘ஏவள்’ என்பது ‘தவள்’ என்பதற்கும் நெருக்கமான தொலைவில் உள்ளது ‘distance’ என்ற தொலைவு பட்டியலில் தெறியும்.

ஒப்பன் தமிழ் நிரல் மற்றும் இயக்கிய வெளிப்பாடு இங்கு.

மேலும் மற்ற அல்கோரிதங்களைப் பற்றி அடுத்த பதிவுகளில் மேலோட்டமாக பாற்கலாம்.

Namashkaar!

A.I./ML for Hindi Language Processing

Sometimes its good to look around and learn from what’s happening in other realms of Indian language processing. In my limited experience language efforts in computing for Indian language revolve around the Dravidian languages, Bengali, Marathi or Hindi. சில நேரங்களில் குண்டு சட்டியில் குதிரை ஓட்டுரமாதிரி கணினி மொழியியல் ஆயிடக்கூடாது – தனிபட்டபடியும் சரி – மொழிகளுக்கிடையிலும் சரி.

Some good project efforts in Hindi Language processing (open-source) are reviewed in this blog; [there are  projects like open-tamil API for Hindi, e.g. a get_letters like function, provided by tokenizer project here (with caveat that it is a small function only compared to expansive open-tamil), but we talk about the ML/A.I. focused projects here].

  1. Hindi word embedding called Hindi2vec (along lines of word2vec project). The idea is to associate similar words (e.g. ‘பல்’,’நாக்கு’,’வாய்’) with similar vectors within a neighborhood of each other using concepts of linear-algebra – vector spaces and matrices. So when you search or mistype or want to classify there is a neighborhood of known words closer to the potentially unknown word input from the user; such known neighborhood identification can help decision making and drive various learning, classification or dialogue systems.
  2. Hindi Transliteration Model project and the DeepTrans project– this is a really cool where they developed a reference data set of English to Hindi and trained a model for transliteration from English to Hindi of user input.
    1. We can do this in Tamil with the as we have many transliteration schemes as set out in open-tamil, but the even a same user is not strictly going to follow the scheme strictly, nor do different users follow the same scheme – in all these cases a machine learning A.I. model maybe more robust by virtue of learning the underlying rules. Very interesting project, and fairly simple to implement for Tamil from open-tamil transliterate module and SciKit Learn or other frameworks with high 95% correct prediction rate.
  3. Hindi-English parallel dictionary with 8MB size (probably 500,000 words or so I imagine) here – this can be a good jump starting point for translation projects if such existed for Tamil. e.g. Can we have a parallel dictionary English – Tamil for the simple TVU word list/dictionary ?
  4. Hindi Sentiment Analysis project does a ternary [good, bad, neutral] classification of text. They do this by using a CDAC-model which is super curious to me; maybe CDAC-India (Pune) has a Tamil POS-Tagger too ? Probably they do.
    1. Tamil POS-Taggers widely reported; AU-KBC Chennai has a POS-Tagger, probably the best for Tamil; Dr. Vasu Renganathan has a POS-Tagger, but both these works are not available currently for open-source use, however their techniques are openly shared via their papers in INFITT conferences.
    2. Sorkandu project can also be revived for making an open-source POS-Tagger
  5. Emotion Recognition in Hindi Speech project – this work from IIT KGP students builds a reference audio data set with known emotion labels and build some kind of a machine learning model, and then they get 5x better than random coin-toss/guess for the audio emotion recognition from speech.
    1. We probably don’t have any work on this direction in the open, but interestingly NIST in USA sponsored a Tamil Key Word Search (KWS), reports of which were published by a Singapore team in academic journals. More interestingly the KWS challenge released 2 hrs of speech data with tagged information. In USA, government released data usually qualifies for public-domain – e.g. pictures from NASA etc. so maybe there is a way to get this data. கடவுளுக்கு தான் வெளிச்சம்!

While we know, Google ASR, Youtube online translation of English videos into Tamil closed-captioning, foreign languages to Tamil Translation, Transliteration inputs all use perhaps the most advanced models in Tensorflow on cloud hardware, none of this technology is directly usable for free – maybe for a price via their Google cloud API offerings – and we probably don’t know all the details of how they achieved these magical software applications for Tamil language – anyones guess like mine is using the massive data sets they have from our Tamil news groups, emails, websites, and user input + Tensorflow A.I / ML magic. At least, we have to be grateful for Google-aandavar like some friends commented on freetamilcomputing group. 🙂

Surprisingly, to my knowledge, there are no planned efforts, ongoing or completed open-source projects like these in Tamil. Maybe another avenue for growth, and in this case Hindi projects (at least in open-source domain) seem to have forged ahead!

Shukriya.

-Muthu

 

 

Famous Indian Computer Science / Math scientists [WIP]

Who are the famous Indian men and women in computers/math ? Help me make a list!
My list ofcourse (is incomplete I’m sure) and currently includes Ramanujan, (Honorary Indian) Alan Turing (born in India), Aryabhatta, Narendra Karmarkar, Agrawal–Kayal–Saxena of AKS primality test, email inventor Shiva Ayyadurai, Raj Reddy (CMU), late Rajeev Motwani, Madhu Sudan, Arokiasamy Paulraj, P Vaidyanathan, Venkatesan Guruswami, Ravi Sethi, Jitendra Malik, …
This is work-in-progress. Please leave comments, critiques below.

Classifying Tamil words – part 2

Recap

Continuing from previous post (see part-1) I am sharing my results on classifying a Tamil alphabet sequence as a valid Tamil-like word or English-like word using a binary classifier.

Pre-requisities

You need to get scikit-learn API installed by following directions on website here.

pip install -U scikit-learn

This will also get dependencies like Numpy and other Python libraries supporting the SciKit learn.

Next ensure your installation is okay by typing,

python -m sklearn

which should run without any output if all your settings are okay.

Training the AI Classifier

To train the classifier based on multi-layer perceptron (in other words – an AI neural network)

  1. we need to represent our input as a CSV file, with each sampled encoded as a feature of rows.
    • for this case the data are in the form of CSV files representing features of Jaffna, Azhagi, Combinational transliterated output of input words
    • See: files ‘english_dictionary_words.azhagi’ and ‘tamilvu_dictionary_words.txt’ at repo open-tamil/examples/classifier
  2. each word (represented as features) will also be given training label usually as integer, forming a column data on CSV file (across all samples); typical features encoded for the data file are defined in class Field under file ‘classifier/preprocess.py’;
    • Typically the information for each word like number of letters, juries, medics, ayutha letters, vallinams, mellinams, idayinams, first, last and vowels are stored in feature record within CSV.
    • We can generate various feature records of the data files by running the code of preprocessor.py
  3. next we may train the neural network using the Scikit learn API,
    • this is key code in ‘classifier/modelprocess2.py’
    • first we load the CSV feature vectors into Python as Numpy array for both class-0 (English words) and class-‘1’ (Tamil)
    • next we setup scaling of data sets for both classes
    • we pick test set, and training set which are key information to getting a good model network and generalized fit
    • We import various tools out of scikit learn like input scaler ‘StandardScalar’, ‘train_test_split’ etc for keeping up with good training conventions
    • Since we are doing classification both test and training inputs need to be scaled but not the label data
  4. Next step we setup a 3-layer neural network with ‘lbfgs’ activation function. We can fit this data with X_train data  and corresponding Y_train labels
    • nn = MLPClassifier(hidden_layer_sizes=(8,8,7),solver=lbfgs)
      nn.fit(X_train,Y_train)

      Y_pred = nn.pred( X_test )

      print(” accuracy => “,accuracy_score(Y_pred.ravel(),Y_test)

  5. The fitted neural network is capable of generating a score (goodness of fit), and immediately serialized into disk for future references; we also output diagnostic informations like,
    • confusion matrix
    • classification report
  6. Next we use the training neural network to show the results of  a few known inputs.

screen-shot-2017-12-20-at-2-24-21-am.png
Fig. 2: 89% accuracy trained classifier with correct identification of word “Hello”; while both are acceptable in native script form it is a English origin word!

  1. Key points for this prediction with ANN are to keep the input transformed as a feature vector before applying it to the classifier input
  2. Once the training is complete we see results like in item [6].

Finally we can automatically tell (via a neural network) if computer is a Tamil or English origin word; there is some sensitivity in this decision due to the 10% error. I have a screenshot of the predictions for various words (feature vectors are written as output as well)

Screen Shot 2017-12-20 at 2.28.35 AM.png
Fig. 3: Neural Network prediction of Tamil words and English (transliterated into Tamil) words

Finally we would like to conclude saying various types of Artificial Neural Network topologies and hidden-layer sizes were used but we chose to stick with simplest. At this time this trained neural network seems like a quite satisfying, and even ready to use for practical purposes.

Conclusion

Scikit-learn provides powerful framework to train and build classification neural networks.

This work has shown easy classification with 10% false-alarm rate (or ~90% classification rate) of various Tamil/English vocabularies and out of training vocabulary sets. The source codes are provided at open-tamil site including the various CSV data etc.

Goodluck, to exploring Neural Networks. Getting beyond 90% in this task seemed hard, and long way to go.

Classifying Tamil words – part 1

Problem

One of problems faced when building a Tamil spell checker, albeit somewhat marginal, can be phrased as follows:

Given a series of Tamil alphabets, how do you decide if the letters are true Tamil word (even out of dictionary) or if it is a transliterated English word ?

e.g. Between the words, ‘உகந்த’ vs ‘கம்புயுடர்’ can you decide which is true Tamil word and which is transliterated ?

Tools

This is somewhat simple with help of a neural network; given sufficient “features” and “training data” we can train some of these neural networks easily. With current interest in this area, tools are available to make this task quite easy – any of Pandas, Keras, PyTorch and Tensorflow may suffice.

Generally, the only thing you need to know about Artificial Intelligence (AI) is that machines can be trained to do tasks based on two distinctive learning processes:

  1. Regression,
  2. Classification

Read more at the Wikipedia – the current “problem” is a classification task.

Features

Naturally for task of classifying a word, we may take features as following:

  1. Word length
  2. Are all characters unique ?
  3. Number of repeated characters ?
  4. Vowels count, Consonant count
    1. In Tamil this information is stored as (Kuril, Nedil, Ayudham) and (Vallinam, Mellinam and Idayinam)
  5. Is word palindrome ?
  6. We can add bigram data as features as next step

Basically this task can be achieved with new code checked into Open-Tamil 0.7 (dev version) called ‘tamil.utf8.classify_letter

Screen Shot 2017-12-17 at 1.03.03 PM.png

Data sets

To make data sets we can use Tamil VU dictionary as a list of valid Tamil words (label 1); next we can use a transliterated list of words from English into Tamil as list of invalid Tamil words (label 0).

Using a 1, 0 labeled data, we may use part of this combined data for training the neural network with gradient descent algorithm or any other method for building a supervised learning model.

Building Transliterated Data

Using the Python code below and the data file from open-tamil repository you can build the code and run it,

def jaffna_transliterate(eng_string):
  tamil_tx = algorithm.Iterative.transliterate(jaffna.Transliteration.table,eng_string)
  return tamil_tx

def azhagi_transliterate(eng_string):
  tamil_tx = algorithm.Iterative.transliterate(azhagi.Transliteration.table,eng_string)
  return tamil_tx

def combinational_transliterate(eng_string):
  tamil_tx = algorithm.Iterative.transliterate(combinational.Transliteration.table,eng_string)
  return tamil_tx

# 3 forms of Tamil transliteration for English word
jfile = codecs.open('english_dictionary_words.jaffna','w','utf-8')
cfile = codecs.open('english_dictionary_words.combinational','w','utf-8')
afile = codecs.open('english_dictionary_words.azhagi','w','utf-8')
with codecs.open('english_dictionary_words.txt','r') as engf:
for idx,w in enumerate(engf.readlines()):
  w = w.strip()
  if len(w) < 1:
    continue
  print(idx)
  jfile.write(u"%s\n"%jaffna_transliterate(w))
  cfile.write(u"%s\n"%combinational_transliterate(w))
  afile.write(u"%s\n"%azhagi_transliterate(w))
  jfile.close()
  cfile.close()
  afile.close()

to get the following data files (left pane shows ‘Jaffna’ transliteration standard, while the right pane shows the source English word list); full gist on GitHub at this link

Screen Shot 2017-12-17 at 1.47.42 PM.png

In the next blog post I will share the details of training the neural network and building this classifier. Stay tuned!