1 of 30

Tamil LLMs

2 of 30

About Me

I am Malaikannan Sankarasubbu , VP of AI Research @Saama Technologies. Previously Founder & CTO of datalog.ai a San Francisco based startup.

�Connect with me

https://www.linkedin.com/in/malaikannan/

�Twitter: @malai_san

�Email: malaikannan.sankarasubbu@saama.com

TAMIL NLP

TAMIL NLP

3 of 30

AI is already here!

TAMIL NLP

TAMIL NLP

4 of 30

Whisper for Tamil

TAMIL NLP

TAMIL NLP

5 of 30

Generative AI and Software 2.0

GPT, LLAMA2, BARD and other LLMs

  • Works phenomenally well for English
  • Shows some signs of reasoning
  • Already powers production grade applications at Saama

TAMIL NLP

TAMIL NLP

6 of 30

Our work in�தமிழ்

Natural Language Processing

7 of 30

Generated by a tiny char RNN model in 2016 trained in Ponniyin Selvan text

"அம்மா! இந்தப் பிரயாணம் செய்து விட்டது. அதே சமயத்தில் இராஜ்யம் சின்னப் பழுவேட்டரையர் இந்தக் காட்சியாக இருக்கிறது. அதை நான் நம்பிக்கை என்று சொல்லவில்லை. தாங்கள் கேட்டது.

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

https://www.linkedin.com/pulse/can-machine-write-story-malaikannan-sankarasubbu/

TAMIL NLP

TAMIL NLP

8 of 30

Our work

  • Word vectors
    • Tamil Vaaku2Vec - Selvakumar M
    • Vaaku2Vec - Malayalam by Kamal Raj and Adam Shamsudeen
    • Bangla2Vec - Bengali by Soham Chatterjee
    • TamilSpellChecker - Malaikannan Sankarasubbu

  • Classification Models
    • Tamil news classification

  • Recognized in
    • உத்தமம் (INFITT)
    • PyCon India
    • ICFOSS

TAMIL NLP

TAMIL NLP

9 of 30

Research Paper in Tamil - சொல்லோடை: கற்கும்-கருவிகளுக்கு ஒரு சொற்றொடர் படையல்

TAMIL NLP

TAMIL NLP

10 of 30

Repos: https://github.com/vanangamudi/tamil-news-classification

சிறுத்தையை கூண்டு வைத்து பிடித்தாலும் பிரச்னை முடியாது ! == tamilnadu

உண்மை நிலை தெரியாமல் பதிலளிக்க முடியாது - நடிகர் ரஜினிகாந்த் == cinema

ஜான்சன் அன்ட் ஜான்சன் பவுடரை ஆய்வு செய்ய மத்திய அரசு அறிவுறுத்தல் == india

“பந்துவீச்சாளர்கள் ஐபிஎல் விளையாடலாமா?” - எதிரெதிர் கருத்தில் தோனி, கும்பளே == sports

“நேர்மையான கிரிக்கெட்டை விளையாட தென் இந்தியா என்னை தயார்ப்படுத்தியது” - தோனி == sports

TAMIL NLP

TAMIL NLP

11 of 30

LLMs: Revolutionizing Language Processing

TAMIL NLP

TAMIL NLP

12 of 30

High Performance : LLMs excel in understanding and processing English and European texts.

Token-Based Input Processing : LLMs analyze language by breaking down input into sequences of tokens.

Beyond Task-Specific Needs : Before LLMs, unique neural network designs were needed for different tasks.

Simplified Task Description : LLMs allow tasks to be described in simple text, streamlining execution.

TAMIL NLP

TAMIL NLP

13 of 30

How does an LLM work?

Tokenization

Encoding

Embedding

பழம் தின்கிறது

பழம் தின் #கிறது

0221 0500 #0012 0428

0.12

-0.2

0.44

0.23

0.56

0.87

0.76

0.28

0.24

0.76

0.87

0.02

குரங்கு

பழம் தின் #கிறது

பழம் தின்கிறது குரங்கு

TAMIL NLP

TAMIL NLP

14 of 30

Limitations of LLMs:

  • LLMs can act as stochastic parrot, அதாவது கிளிப்பிள்ளை .
  • Unpredictable and uncontrollable behavior at times. Hallucinations.

TAMIL NLP

TAMIL NLP

15 of 30

Building LLMs for Tamil Language

TAMIL NLP

TAMIL NLP

16 of 30

Foundational Model for Tamil

  • Foundation in Tamil Text: Develop a Large Language Model trained from scratch on rich Tamil datasets, embracing the depth and diversity of the language.

  • Curated Datasets for Authentic Learning: Carefully select and prepare datasets that capture the essence of Tamil culture, literature, and daily communication, ensuring a robust and culturally relevant model.

  • Preserving Linguistic Integrity: By focusing on native Tamil texts, the model learns directly from the source, maintaining the authenticity and nuance of the language, and avoiding the inaccuracies that can arise from reliance on machine-translated inputs.

TAMIL NLP

TAMIL NLP

17 of 30

The Crucial Role of Tokenization in

Language Processing

TAMIL NLP

TAMIL NLP

18 of 30

Tokenization: What is a word?

  • Not a simple question to answer!
  • Most LLM models use a variation of Byte Pair Encoding
    • Tokens are built up from characters based on how frequently they occur together.
  • This causes lot of problems mainly,
    • Under-segmenting frequent words
      • Interdisciplinary instead of Inter-disciplin-ary
    • Over-segmenting rare words
      • Hy-pot-het-i-cal-ly instead of Hypo-thetical-ly
    • Improper segmentation (suffixes and prefixes are treated indifferently)
      • Ed-ward, 'ed' in names are not suffixes

TAMIL NLP

TAMIL NLP

19 of 30

Tokenization

  • Spelling mistakes are unavoidable in the wild, so cannot rely on purely rule based methods.
  • There is a necessity for a tradeoff. The following is the spectrum of how words can be studies and treated.
  • Most heuristical methods are automatic and required little to no manual curation, though principle methods can also be aided with automatic methods.

Etymology

Morphology

Regex

Whitespace

Byte Pair Encoding

Principled

Heuristical

Strategies of Tokenization

TAMIL NLP

TAMIL NLP

20 of 30

Tokenization (cont.)

Tamil lends itself to different forms of tokenization in a very principled fashion.

The tokenization boundaries can be determined in terms of

    • Whitespace delimiters (the worst way)
    • புணர்ச்சி விதிப்படி பகுத்தல் (Punarchi rules i.e reverse engineering roots, stems, affixes based on rules)
    • யாப்புச்சீர்களாக பகுத்தல் (syllabification நேர் நேர் -> தேமா)
    • Phonetic segmentation - which can transcend languages for standard dialects

TAMIL NLP

TAMIL NLP

21 of 30

Tokenization - Mixing Multiple Tokenizers

  • Tokenizing the whole document using single tokenizer is also suboptimal.
  • Automatically detecting different types of text and using appropriate tokenization should be an important part of any NLP pipeline.
  • Tokenization methods must embody linguistic structures that is specific to particular language.

TAMIL NLP

TAMIL NLP

22 of 30

Applications

  • Sky is the limit.
  • Speech to Text systems encourage use of மிழ் instead of Tanglish
  • Tamil Chatbots for banks, government.
  • Translation system with human in the loop
  • Marketing - Copywriting
  • Authoring educational material especially formulae in poetry format

TAMIL NLP

TAMIL NLP

23 of 30

Cautionary note

  • Language Understanding needs hybrid approach
  • Neither pure linguistics nor pure compute is not going to work.
  • Tamil language intricacies have to be taken into account.

TAMIL NLP

TAMIL NLP

24 of 30

What do we need to train an LLM in Tamil?

Data

Preprocess

Training

(Language Modelling)

Reinforce

(RLHF/DPO)

Output

Original Corpora

  • Books in the Public Domain
  • News Websites
  • Wikipedia
  • Social Blogging Platforms
  • Govt. Orders for Parallel corpus

Punarchi Splitter

  • Document analysis
  • Native Tokenization
  • Spelling fix
  • Phonetic Segmentation
  • Code-mix handling

GPU clusters

  • 7B/13B variants
  • Mask LM
  • Task fine-tuning

Tamil Chatbot

  • Supervised Fine-Tuning
  • Preference Learning

Human in the loop

TAMIL NLP

TAMIL NLP

25 of 30

What do we need to train an LLM in Tamil?

  • Avoid treating everything as a sequences of some-same thing
  • Analyse document structure and apply appropriate models
  • Tamil Native Tokenizer Suite

TAMIL NLP

TAMIL NLP

26 of 30

What do we need to train an LLM in Tamil?

  • LLM Pre-training and RLHF Fine-tuning
    • Hardware infrastructure
      • Need 100s of GPU accelerators for training one single LLM
      • Training 7B model on 1 Trillion tokens cost close 100k dollars
      • For 13B close to 200k dollars

    • Data Annotation Drives or hackathons
      • Expert can train students in ML and in return,
      • Students help improve annotation

TAMIL NLP

TAMIL NLP

27 of 30

What do we need to train an LLM in Tamil?

  • Special Interest Group of AI/ML experts and Tamil language experts to guide the overall process
  • Incorporate techniques employed from other agglutinative languages like Finnish, Hungarian Korean, Thai, Turkish, etc.

TAMIL NLP

TAMIL NLP

28 of 30

Beyond LLMs

  • LLMs introduces a new paradigm for processing language with unprecedented ease.
  • Yet novel methods for understanding and perform reasoning in Tamil.

Areas still untouched

  • There is a Tamil WordNet
    • If everyone has access to it, that would be great.
  • No attempt has been made to build
    • Knowledge Graphs
    • Ontologies

TAMIL NLP

TAMIL NLP

29 of 30

How do LLM works?

நான் சென்னைக்கு பேருந்தில் போனேன்

நான் சென்னை #க்கு பேருந்த் #இல் போ #னேன்

குரங்கு பழத்தை தின்கிறது

குரங்கு பழ #த்தை தின் #கிறது

மழை பொழிகிறது

மழை பொழி #கிறது

பூவில் தேன் வழிகிறது

பூ #இல் தேன் வழி #கிறது

இந்த வண்டி எந்த வழி போகிறது

#ந்த வண்டி எ #ந்த வழி போ #கிறது

பூவில் தேன் வழிகிறது

பூ #இல் தேன் வழி #கிறது

இந்த வண்டி எந்த வழி போகிறது

#ந்த வண்டி எ #ந்த வழி போ #கிறது

TAMIL NLP

TAMIL NLP

30 of 30

Thank you!