SlideShare une entreprise Scribd logo
1  sur  45
Télécharger pour lire hors ligne
Practical NLP with Lisp

   Vsevolod Dyomkin
       Grammarly
Topics

*   Overview of NLP practice
*   Getting Data
*   Using Lisp: pros & cons
*   A couple of examples
A bit about Grammarly




        (c) xkcd
An example of what
   we deal with
NLP practice
R - research work:
set a goal →
devise an algorithm →
train the algorithm →
test its accuracy
NLP practice
R - research work:
set a goal →
devise an algorithm →
train the algorithm →
test its accuracy

D - development work:
implement the algorithm as an API with
sufficient performance and scaling
characteristics
Research
1. Set a goal
Business goal:

* Develop best/good enough/better than
Word/etc spellchecker

* Develop a set of grammar rules, that will
catch errors according to MLA Style

* Develop a thesaurus, that will produce
synonyms relevant to context
Translate it to measurable goal
* On a test corpus of 10000 sentences with
common errors achieve smaller number of FNs
(and FPs), that other spellcheckers/Word
spellchecker/etc

* On a corpus of examples of sentences with
each kind of error (and similar sentences
without this kind of error) find all
sentences with errors and do not find
errors in correct sentences

* On a test corpus of 1000 sentences
suggest synonyms for all meaningful words
that will be considered relevant by human
linguists in 90% of the cases
A Note on
       Terminology
FN and FP instead of
precision (P), recall (R)

FN = 1-R
FP = 1-P or ???
f1 = P*R/(P+R) =
(1-FN-FP+FN*FP)/(2-(FN+FP))
Research contd.
2. Devise an algorithm
3. Train & improve the
algorithm
Research contd.
2. Devise an algorithm
3. Train & improve the
algorithm

http://nlp-class.org
4. Test its performance
ML: one corpus, divided into
training,development,test
4. Test its performance
ML: one corpus, divided into
training,development,test

Often — different corpora:
* for training some part (not
whole) of the algorithm
* for testing the whole
system
Theoretical maxima
Theoretical maxima are rarely
achievable. Why?
Theoretical maxima
Theoretical maxima are rarely
achievable. Why?

* Because you need their
data. (And data is key)
Theoretical maxima
Theoretical maxima are rarely
achievable. Why?

* Because you need their
data. (And data is key)

* Domains might differ
Pre/post-processing
What ultimately matters is
not crude performance, but...
Pre/post-processing
What ultimately matters is
not crude performance, but...

Acceptance to users (much
harder to measure & depends
on domain).
Pre/post-processing
What ultimately matters is
not crude performance, but...

Acceptance to users (much
harder to measure & depends
on domain).

Real-world is messier, than
any lab set-up.
Examples of
    pre-processing
For spellcheck:

* some people tend to use
words, separated by slashes,
like: spell/grammar check

* handling of abbreviations
Where to get data?
Well-known sources:
* Penn Tree Bank
* Wordnet
* Web1T Google N-gram Corpus
* Linguistic Data Consortium
  (http://www.ldc.upenn.edu/)
More data
Also well-known sources, but
with a twist:
* Wikipedia & Wiktionary,
DBPedia
* OpenWeb Common Crawl
(updated: 2010)
* Public APIs of some
services: Twitter, Wordnik
Obscure corpora
Academic resources:
* Stanford
* CoNLL
* Oxford (http://www.ota.ox.ac.uk/)
* CMU, MIT,...
* LingPipe, OpenNLP, NLTK,...
Human-powered?


http://goo.gl/hs4qB
Beyond corpora?

* Bootstrapping
* Seeding
And remember...
“Data is ten times more
powerful than algorithms.”
-- Peter Norvig, “The Unreasonable
Effectiveness of Data.”
http://youtu.be/yvDCzhbjYWs
Using Lisp for NLP




      (c) xkcd
Why Lisp?
Lisp is a carefully crafted
tool for:

*   Engineers
*   Practical researchers
*   Artists
*   Entrepreneurs
Some examples
*   Piano.aero
*   ITA Software
*   Secure Outcomes
*   Impromptu

* Land of Lisp
http://youtu.be/HM1Zb3xmvMc
Research
       requirements
*   Interactivity
*   Mathematical basis
*   Expressiveness
*   Agility Malleability
*   Advanced tools
Specific NLP
     requirements
* Good support for statistics
& number-crunching (matrices)
– Statistical AI

* Good support for working
with trees & symbols
– Symbolic AI
Production
       requirements
*   Scalability
*   Maintainability
*   Integrability
*   ...
...eventually

* Speed
...eventually

* Speed
* Speed
...eventually

* Speed
* Speed
* Speed
Heterogeneous
        systems
You have to split the system
and communicate:

“Java” way vs. “Unix” way

* Sockets, Redis, ZeroMQ, etc
for communication
* JSON, SEXPs, etc for data
Lisp drawbacks
There's no OpenNLP or SciPy &
generally there's fewer
libraries.
Lisp drawbacks
There's no OpenNLP or SciPy &
generally there's fewer
libraries.

But...
*   github: eslick/cl-langutils
*   github: mathematical-systems/clml
*   github: tpapp/lla
*   github: blindglobe/common-lisp-stat
*   … and http://quicklisp.org
But #2
Porter stemmer:
http://tartarus.org/~martin/PorterStemmer
& http://www.cliki.net/PorterStemmer

or Soundex:
http://www.cs.cmu.edu/afs/cs/project/ai-
repository/ai/lang/lisp/code/0.html

are irrelevant with good data
More drawbacks

Lisp is a fringe language

   Not special language
  (like R, J or Octave)
Example #1


API interaction
Example #2
Lisp FTW
* truly interactive
environment
* very flexible => DSLs
* native tree support
* fast and solid
Take-aways
* Take nlp-class

* Data is key, collect it, build tools
to work with it easily and efficiently

* A good language for R&D should be
first of all interactive & malleable,
with as few barriers as possible

* ... it also helps if you don't need to
port your code for production

* Lisp is one of the good examples
Thanks!

Vsevolod Dyomkin
    @vseloved

Contenu connexe

Tendances

Introduction à ElasticSearch
Introduction à ElasticSearchIntroduction à ElasticSearch
Introduction à ElasticSearch
Fadel Chafai
 
Data Lake
Data LakeData Lake
Data Lake
Soft Computing
 
Habash: Arabic Natural Language Processing
Habash: Arabic Natural Language ProcessingHabash: Arabic Natural Language Processing
Habash: Arabic Natural Language Processing
Mustafa Jarrar
 
Machine Learning Tutorial Part - 1 | Machine Learning Tutorial For Beginners ...
Machine Learning Tutorial Part - 1 | Machine Learning Tutorial For Beginners ...Machine Learning Tutorial Part - 1 | Machine Learning Tutorial For Beginners ...
Machine Learning Tutorial Part - 1 | Machine Learning Tutorial For Beginners ...
Simplilearn
 

Tendances (20)

Elasticsearch ve Udemy Kullanım Pratikleri
Elasticsearch ve Udemy Kullanım PratikleriElasticsearch ve Udemy Kullanım Pratikleri
Elasticsearch ve Udemy Kullanım Pratikleri
 
NLP tutorial at AIME 2020
NLP tutorial at AIME 2020NLP tutorial at AIME 2020
NLP tutorial at AIME 2020
 
Introduction à ElasticSearch
Introduction à ElasticSearchIntroduction à ElasticSearch
Introduction à ElasticSearch
 
Introduction to AI & ML
Introduction to AI & MLIntroduction to AI & ML
Introduction to AI & ML
 
Multi-model database
Multi-model databaseMulti-model database
Multi-model database
 
1시간만에 만드는 음성인식 인공지능 챗봇
1시간만에 만드는 음성인식 인공지능 챗봇1시간만에 만드는 음성인식 인공지능 챗봇
1시간만에 만드는 음성인식 인공지능 챗봇
 
New Approaches for Fraud Detection on Apache Kafka and KSQL
New Approaches for Fraud Detection on Apache Kafka and KSQLNew Approaches for Fraud Detection on Apache Kafka and KSQL
New Approaches for Fraud Detection on Apache Kafka and KSQL
 
Données liées et Web sémantique : quand le lien fait sens.
Données liées et Web sémantique : quand le lien fait sens. Données liées et Web sémantique : quand le lien fait sens.
Données liées et Web sémantique : quand le lien fait sens.
 
Data Lake
Data LakeData Lake
Data Lake
 
Data ingestion and distribution with apache NiFi
Data ingestion and distribution with apache NiFiData ingestion and distribution with apache NiFi
Data ingestion and distribution with apache NiFi
 
Big Data and Natural Language Processing
Big Data and Natural Language ProcessingBig Data and Natural Language Processing
Big Data and Natural Language Processing
 
Choosing an HDFS data storage format- Avro vs. Parquet and more - StampedeCon...
Choosing an HDFS data storage format- Avro vs. Parquet and more - StampedeCon...Choosing an HDFS data storage format- Avro vs. Parquet and more - StampedeCon...
Choosing an HDFS data storage format- Avro vs. Parquet and more - StampedeCon...
 
Habash: Arabic Natural Language Processing
Habash: Arabic Natural Language ProcessingHabash: Arabic Natural Language Processing
Habash: Arabic Natural Language Processing
 
Machine Learning Tutorial Part - 1 | Machine Learning Tutorial For Beginners ...
Machine Learning Tutorial Part - 1 | Machine Learning Tutorial For Beginners ...Machine Learning Tutorial Part - 1 | Machine Learning Tutorial For Beginners ...
Machine Learning Tutorial Part - 1 | Machine Learning Tutorial For Beginners ...
 
Processing Arabic Text
Processing Arabic TextProcessing Arabic Text
Processing Arabic Text
 
Rate limiters in big data systems
Rate limiters in big data systemsRate limiters in big data systems
Rate limiters in big data systems
 
Tech Talk - Overview of Dash framework for building dashboards
Tech Talk - Overview of Dash framework for building dashboardsTech Talk - Overview of Dash framework for building dashboards
Tech Talk - Overview of Dash framework for building dashboards
 
Time-Series Apache HBase
Time-Series Apache HBaseTime-Series Apache HBase
Time-Series Apache HBase
 
Solr vs. Elasticsearch - Case by Case
Solr vs. Elasticsearch - Case by CaseSolr vs. Elasticsearch - Case by Case
Solr vs. Elasticsearch - Case by Case
 
Transitioning Compute Models: Hadoop MapReduce to Spark
Transitioning Compute Models: Hadoop MapReduce to SparkTransitioning Compute Models: Hadoop MapReduce to Spark
Transitioning Compute Models: Hadoop MapReduce to Spark
 

En vedette

Lisp for Python Programmers
Lisp for Python ProgrammersLisp for Python Programmers
Lisp for Python Programmers
Vsevolod Dyomkin
 
Чему мы можем научиться у Lisp'а?
Чему мы можем научиться у Lisp'а?Чему мы можем научиться у Lisp'а?
Чему мы можем научиться у Lisp'а?
Vsevolod Dyomkin
 
Новые нереляционные системы хранения данных
Новые нереляционные системы хранения данныхНовые нереляционные системы хранения данных
Новые нереляционные системы хранения данных
Vsevolod Dyomkin
 
Lisp как универсальная обертка
Lisp как универсальная оберткаLisp как универсальная обертка
Lisp как универсальная обертка
Vsevolod Dyomkin
 
Tedxkyiv communication guidelines
Tedxkyiv communication guidelinesTedxkyiv communication guidelines
Tedxkyiv communication guidelines
Vsevolod Dyomkin
 
Natural Language Processing in Practice
Natural Language Processing in PracticeNatural Language Processing in Practice
Natural Language Processing in Practice
Vsevolod Dyomkin
 

En vedette (19)

lisp (vs ruby) metaprogramming
lisp (vs ruby) metaprogramminglisp (vs ruby) metaprogramming
lisp (vs ruby) metaprogramming
 
NLP in the WILD or Building a System for Text Language Identification
NLP in the WILD or Building a System for Text Language IdentificationNLP in the WILD or Building a System for Text Language Identification
NLP in the WILD or Building a System for Text Language Identification
 
LISP: How I Learned To Stop Worrying And Love Parantheses
LISP: How I Learned To Stop Worrying And Love ParanthesesLISP: How I Learned To Stop Worrying And Love Parantheses
LISP: How I Learned To Stop Worrying And Love Parantheses
 
Aspects of NLP Practice
Aspects of NLP PracticeAspects of NLP Practice
Aspects of NLP Practice
 
Lisp for Python Programmers
Lisp for Python ProgrammersLisp for Python Programmers
Lisp for Python Programmers
 
Sugaring Lisp for the 21st Century
Sugaring Lisp for the 21st CenturySugaring Lisp for the 21st Century
Sugaring Lisp for the 21st Century
 
NLP Project Full Cycle
NLP Project Full CycleNLP Project Full Cycle
NLP Project Full Cycle
 
Crash-course in Natural Language Processing
Crash-course in Natural Language ProcessingCrash-course in Natural Language Processing
Crash-course in Natural Language Processing
 
Metaprogramming and Reflection in Common Lisp
Metaprogramming and Reflection in Common LispMetaprogramming and Reflection in Common Lisp
Metaprogramming and Reflection in Common Lisp
 
Lisp Machine Prunciples
Lisp Machine PrunciplesLisp Machine Prunciples
Lisp Machine Prunciples
 
Чему мы можем научиться у Lisp'а?
Чему мы можем научиться у Lisp'а?Чему мы можем научиться у Lisp'а?
Чему мы можем научиться у Lisp'а?
 
Новые нереляционные системы хранения данных
Новые нереляционные системы хранения данныхНовые нереляционные системы хранения данных
Новые нереляционные системы хранения данных
 
Lisp как универсальная обертка
Lisp как универсальная оберткаLisp как универсальная обертка
Lisp как универсальная обертка
 
Tedxkyiv communication guidelines
Tedxkyiv communication guidelinesTedxkyiv communication guidelines
Tedxkyiv communication guidelines
 
CL-NLP
CL-NLPCL-NLP
CL-NLP
 
Can functional programming be liberated from static typing?
Can functional programming be liberated from static typing?Can functional programming be liberated from static typing?
Can functional programming be liberated from static typing?
 
Экосистема Common Lisp
Экосистема Common LispЭкосистема Common Lisp
Экосистема Common Lisp
 
Crash Course in Natural Language Processing (2016)
Crash Course in Natural Language Processing (2016)Crash Course in Natural Language Processing (2016)
Crash Course in Natural Language Processing (2016)
 
Natural Language Processing in Practice
Natural Language Processing in PracticeNatural Language Processing in Practice
Natural Language Processing in Practice
 

Similaire à Practical NLP with Lisp

Web data from R
Web data from RWeb data from R
Web data from R
schamber
 
Big Data Spain 2017 - Deriving Actionable Insights from High Volume Media St...
Big Data Spain 2017  - Deriving Actionable Insights from High Volume Media St...Big Data Spain 2017  - Deriving Actionable Insights from High Volume Media St...
Big Data Spain 2017 - Deriving Actionable Insights from High Volume Media St...
Apache OpenNLP
 
Sparklis exploration et interrogation de points d'accès sparql par interactio...
Sparklis exploration et interrogation de points d'accès sparql par interactio...Sparklis exploration et interrogation de points d'accès sparql par interactio...
Sparklis exploration et interrogation de points d'accès sparql par interactio...
SemWebPro
 

Similaire à Practical NLP with Lisp (20)

Всеволод Демкин "Natural language processing на практике"
Всеволод Демкин "Natural language processing на практике"Всеволод Демкин "Natural language processing на практике"
Всеволод Демкин "Natural language processing на практике"
 
The State of #NLProc
The State of #NLProcThe State of #NLProc
The State of #NLProc
 
Web data from R
Web data from RWeb data from R
Web data from R
 
Survey of Program Transformation Technologies
Survey of Program Transformation TechnologiesSurvey of Program Transformation Technologies
Survey of Program Transformation Technologies
 
Nautral Langauge Processing - Basics / Non Technical
Nautral Langauge Processing - Basics / Non Technical Nautral Langauge Processing - Basics / Non Technical
Nautral Langauge Processing - Basics / Non Technical
 
Perl::Lint - Yet Another Perl Source Code Linter
Perl::Lint - Yet Another Perl Source Code LinterPerl::Lint - Yet Another Perl Source Code Linter
Perl::Lint - Yet Another Perl Source Code Linter
 
Perl Myths 200909
Perl Myths 200909Perl Myths 200909
Perl Myths 200909
 
What we can learn from Rebol?
What we can learn from Rebol?What we can learn from Rebol?
What we can learn from Rebol?
 
Python: The Programmer's Lingua Franca
Python: The Programmer's Lingua FrancaPython: The Programmer's Lingua Franca
Python: The Programmer's Lingua Franca
 
Php extensions
Php extensionsPhp extensions
Php extensions
 
An Introduction to NLP4L
An Introduction to NLP4LAn Introduction to NLP4L
An Introduction to NLP4L
 
Chris Brew - TR Discover: A Natural Language Interface for Exploring Linked D...
Chris Brew - TR Discover: A Natural Language Interface for Exploring Linked D...Chris Brew - TR Discover: A Natural Language Interface for Exploring Linked D...
Chris Brew - TR Discover: A Natural Language Interface for Exploring Linked D...
 
Docopt, beautiful command-line options for R, user2014
Docopt, beautiful command-line options for R,  user2014Docopt, beautiful command-line options for R,  user2014
Docopt, beautiful command-line options for R, user2014
 
Devfest kyoto2018 Lisp-Koans
Devfest kyoto2018 Lisp-KoansDevfest kyoto2018 Lisp-Koans
Devfest kyoto2018 Lisp-Koans
 
Big Data Spain 2017 - Deriving Actionable Insights from High Volume Media St...
Big Data Spain 2017  - Deriving Actionable Insights from High Volume Media St...Big Data Spain 2017  - Deriving Actionable Insights from High Volume Media St...
Big Data Spain 2017 - Deriving Actionable Insights from High Volume Media St...
 
Mastering Python lesson3b_for_loops
Mastering Python lesson3b_for_loopsMastering Python lesson3b_for_loops
Mastering Python lesson3b_for_loops
 
Natural Language Processing using Java
Natural Language Processing using JavaNatural Language Processing using Java
Natural Language Processing using Java
 
NLP Data Cleansing Based on Linguistic Ontology Constraints
NLP Data Cleansing Based on Linguistic Ontology ConstraintsNLP Data Cleansing Based on Linguistic Ontology Constraints
NLP Data Cleansing Based on Linguistic Ontology Constraints
 
Sparklis exploration et interrogation de points d'accès sparql par interactio...
Sparklis exploration et interrogation de points d'accès sparql par interactio...Sparklis exploration et interrogation de points d'accès sparql par interactio...
Sparklis exploration et interrogation de points d'accès sparql par interactio...
 
Elasticsearch Basics
Elasticsearch BasicsElasticsearch Basics
Elasticsearch Basics
 

Dernier

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Dernier (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

Practical NLP with Lisp

  • 1. Practical NLP with Lisp Vsevolod Dyomkin Grammarly
  • 2. Topics * Overview of NLP practice * Getting Data * Using Lisp: pros & cons * A couple of examples
  • 3. A bit about Grammarly (c) xkcd
  • 4. An example of what we deal with
  • 5. NLP practice R - research work: set a goal → devise an algorithm → train the algorithm → test its accuracy
  • 6. NLP practice R - research work: set a goal → devise an algorithm → train the algorithm → test its accuracy D - development work: implement the algorithm as an API with sufficient performance and scaling characteristics
  • 7. Research 1. Set a goal Business goal: * Develop best/good enough/better than Word/etc spellchecker * Develop a set of grammar rules, that will catch errors according to MLA Style * Develop a thesaurus, that will produce synonyms relevant to context
  • 8. Translate it to measurable goal * On a test corpus of 10000 sentences with common errors achieve smaller number of FNs (and FPs), that other spellcheckers/Word spellchecker/etc * On a corpus of examples of sentences with each kind of error (and similar sentences without this kind of error) find all sentences with errors and do not find errors in correct sentences * On a test corpus of 1000 sentences suggest synonyms for all meaningful words that will be considered relevant by human linguists in 90% of the cases
  • 9. A Note on Terminology FN and FP instead of precision (P), recall (R) FN = 1-R FP = 1-P or ??? f1 = P*R/(P+R) = (1-FN-FP+FN*FP)/(2-(FN+FP))
  • 10. Research contd. 2. Devise an algorithm 3. Train & improve the algorithm
  • 11. Research contd. 2. Devise an algorithm 3. Train & improve the algorithm http://nlp-class.org
  • 12. 4. Test its performance ML: one corpus, divided into training,development,test
  • 13. 4. Test its performance ML: one corpus, divided into training,development,test Often — different corpora: * for training some part (not whole) of the algorithm * for testing the whole system
  • 14. Theoretical maxima Theoretical maxima are rarely achievable. Why?
  • 15. Theoretical maxima Theoretical maxima are rarely achievable. Why? * Because you need their data. (And data is key)
  • 16. Theoretical maxima Theoretical maxima are rarely achievable. Why? * Because you need their data. (And data is key) * Domains might differ
  • 17. Pre/post-processing What ultimately matters is not crude performance, but...
  • 18. Pre/post-processing What ultimately matters is not crude performance, but... Acceptance to users (much harder to measure & depends on domain).
  • 19. Pre/post-processing What ultimately matters is not crude performance, but... Acceptance to users (much harder to measure & depends on domain). Real-world is messier, than any lab set-up.
  • 20. Examples of pre-processing For spellcheck: * some people tend to use words, separated by slashes, like: spell/grammar check * handling of abbreviations
  • 21. Where to get data? Well-known sources: * Penn Tree Bank * Wordnet * Web1T Google N-gram Corpus * Linguistic Data Consortium (http://www.ldc.upenn.edu/)
  • 22. More data Also well-known sources, but with a twist: * Wikipedia & Wiktionary, DBPedia * OpenWeb Common Crawl (updated: 2010) * Public APIs of some services: Twitter, Wordnik
  • 23. Obscure corpora Academic resources: * Stanford * CoNLL * Oxford (http://www.ota.ox.ac.uk/) * CMU, MIT,... * LingPipe, OpenNLP, NLTK,...
  • 26. And remember... “Data is ten times more powerful than algorithms.” -- Peter Norvig, “The Unreasonable Effectiveness of Data.” http://youtu.be/yvDCzhbjYWs
  • 27. Using Lisp for NLP (c) xkcd
  • 28. Why Lisp? Lisp is a carefully crafted tool for: * Engineers * Practical researchers * Artists * Entrepreneurs
  • 29. Some examples * Piano.aero * ITA Software * Secure Outcomes * Impromptu * Land of Lisp http://youtu.be/HM1Zb3xmvMc
  • 30. Research requirements * Interactivity * Mathematical basis * Expressiveness * Agility Malleability * Advanced tools
  • 31. Specific NLP requirements * Good support for statistics & number-crunching (matrices) – Statistical AI * Good support for working with trees & symbols – Symbolic AI
  • 32. Production requirements * Scalability * Maintainability * Integrability * ...
  • 36. Heterogeneous systems You have to split the system and communicate: “Java” way vs. “Unix” way * Sockets, Redis, ZeroMQ, etc for communication * JSON, SEXPs, etc for data
  • 37. Lisp drawbacks There's no OpenNLP or SciPy & generally there's fewer libraries.
  • 38. Lisp drawbacks There's no OpenNLP or SciPy & generally there's fewer libraries. But... * github: eslick/cl-langutils * github: mathematical-systems/clml * github: tpapp/lla * github: blindglobe/common-lisp-stat * … and http://quicklisp.org
  • 39. But #2 Porter stemmer: http://tartarus.org/~martin/PorterStemmer & http://www.cliki.net/PorterStemmer or Soundex: http://www.cs.cmu.edu/afs/cs/project/ai- repository/ai/lang/lisp/code/0.html are irrelevant with good data
  • 40. More drawbacks Lisp is a fringe language Not special language (like R, J or Octave)
  • 43. Lisp FTW * truly interactive environment * very flexible => DSLs * native tree support * fast and solid
  • 44. Take-aways * Take nlp-class * Data is key, collect it, build tools to work with it easily and efficiently * A good language for R&D should be first of all interactive & malleable, with as few barriers as possible * ... it also helps if you don't need to port your code for production * Lisp is one of the good examples