SlideShare ist ein Scribd-Unternehmen logo
1 von 23
Intent Classifier with
Facebook fastText
Facebook Developer Circle, Malang
22 February 2017
Bayu Aldi Yansyah
Data Scientist at Sale Stock
OUR GOALS
1. Understand how Machine Learning is applied in Messenger bot
development.
2. Understand what is fastText and why it is important.
3. Able to create intent classifier model with fastText.
Aku mau pesan tiket
surabaya-jakarta buat
minggu pagi ya
Untuk 2 org
Ada yang bisa Aska
bantu?
Aska
Bayu
Aska is our Messenger bot
HUMAN
Understand the context and extract the available information easily.
Intent : Book Flight Ticket
Departure Location : Surabaya
Departure Time : Minggu pagi
Arrival Location : Jakarta
Quantity : 2
Aku pesan tiket
surabaya-jakarta buat
minggu pagi ya
Untuk 2 org
OUR BOT
1. What is the intent?
Book Flight Ticket
Book Hotel
Ask a Question
Buy a Product
…
Aku pesan tiket
surabaya-jakarta buat
minggu pagi ya
Untuk 2 org
2. Extract information
DepLoc : Surabaya
DepTime : Minggu pagi
ArrLoc : Jakarta
Quantity : 2
He need to know the intent of the chat first and extract the available
information.
INTENT CLASSIFIER
INPUT CLASSIFIER OUTPUT
User’s chat User’s intent
Example of user’s intent: Book a flight ticket, book a hotel, buy a product
and asking a specific questions.
INTENT CLASSIFIER
- Intent Classifier can be seen as Document Classification/Text
Classification task
- Text categorization (a.k.a. text classification) is the task of assigning
predefined categories to free-text documents.
- We can use Machine Learning approach to solve this task.
- Popular method is Supervised learning.
SUPERVISED LEARNING
DATA
INPUT OUTPUT
MODELALGORITHM
TRAINING EVALUATE DEPLOY
- Example data: chat message as an input and the label of intent as the
output.
- Popular algorithms for text classification:
- Linear classifiers: Support Vector Machine (Joachims, 1998)
- Convolutional Neural Networks based: Kim 2014 & Zhang and
LeCun 2015
- Example of the metrics to evaluate: Precision & Recall
SUPERVISED LEARNING
- Neural Network based models achieve very good performance in
practice, but it is time consuming to train and test. It need large
resources for large datasets.
- Linear classifiers are simple and often obtain state-of-the-art performance
if the right features is used. It doesn’t need large resources resource.
However, linear classifiers do not share parameters among features
and classes.
- fastText is trying to solve these problems.
FASTTEXT
- fastText is a C++ library for efficient learning of word representations and
sentence classification.
- Word Representation learning:
- Continuous Bag-Of-Words (CBOW)
- Continuous Skip-gram
- Text Classification: A simple linear model where using averaged word
representation as text representation.
- Word representation learning or word embedding is a technique to
represent a word as a vector.
- The result of word embedding frequently referred as “word vector” or
“distributed representation of words”.
- There are 3 main approaches to word embedding:
1. Neural Networks model based
2. Dimensionality reduction based
3. Probabilistic model based
- The idea of these approaches are to learn vector representations of
words in an unsupervised manner.
WORD REPRESENTATION LEARNING
CONTINOUS BAG-OF-WORDS
- A simple neural networks model.
- The training data is a sequence of words 𝑤1, 𝑤2, … , 𝑤 𝑇 for 𝑤𝑡 ∈ 𝑉
- The model is trying predict the word 𝑤𝑡 based on the surrounding context (𝑛
words from left: 𝑤𝑡−1, 𝑤𝑡−2 and 𝑛 words from the right: 𝑤𝑡−1, 𝑤𝑡−2).
- There are no hidden layer in this model.
- Projection layer is averaged across input words.
𝑤𝑡+2
Keren Sale bisa bayar dirumah... ...
𝑤𝑡+1𝑤𝑡𝑤𝑡−1𝑤𝑡−2
CONTINOUS BAG-OF-WORDS
𝑥 𝑡+2𝑥 𝑡+1𝑥 𝑡−1𝑥 𝑡−2
𝑥′ 𝑡
𝑣
Visualization of CBOW model
CONTINOUS SKIP-GRAM
- The training data is a sequence of words 𝑤1, 𝑤2, … , 𝑤 𝑇 for 𝑤𝑡 ∈ 𝑉
- The model is trying predict the surrounding context (𝑛 words from left:
𝑤𝑡−1, 𝑤𝑡−2 and 𝑛 words from the right: 𝑤𝑡−1, 𝑤𝑡−2) based on the word
𝑤𝑡.
𝑤𝑡+2
Keren bisa... ...
𝑤𝑡+1𝑤𝑡𝑤𝑡−1𝑤𝑡−2
CONTINOUS SKIP-GRAM
𝑥 𝑡+2𝑥 𝑡+1𝑥 𝑡−1𝑥 𝑡−2
𝑥 𝑡
𝑣
Visualization of Skip-gram model
More detailed information about word embedding available at “Clustering
semantically similar words”
https://github.com/pyk/talks
WORD REPRESENTATION LEARNING
LINEAR CLASSIFIER
- The architecture is similar with Continuous Bag-of-Words model, where
the middle of words is replaced by the label.
- The word representations are averaged into text representation, which is
in turn fed to a linear classifier.
FASTTEXT
Step by step to create intent classifier model with fastText.
It’s super easy.
Install the fasttext(1) first https://github.com/facebookresearch/fasttext
(Only support Linux and OSX)
FASTTEXT
Prepare the training data:
1. Convert the intent as numeric.
For example: Booking flight = 0, Buy product = 1
2. Preprocess the data: Tokenization, remove symbols etc
3. Create the training data with the following format:
prefix_labelnum token1 token2 token3 …
FASTTEXT
Create the model:
1. Run:
./fasttext supervised -input train.dat 
-output intent_classifier -dim 100 -lr 0.1 
-wordNgrams 2 -minCount 1 -bucket 2000000 
-epoch 5 -thread 4
- train.dat is the training data
- output model: intent_classifier.bin
DEPLOY
If you are Python programmer, you can use fastText.py
https://github.com/salestock/fastText.py to deploy the model.
- Create a API service with Flask
- Load & serve the model
- Create new endpoint for the inference step
- Enriching Word Vectors with Subword Information by
Bojanowski et al (2016)
https://arxiv.org/abs/1607.04606
- Bag of Tricks for Efficient Text Classification by Joulin et al (2016)
https://arxiv.org/abs/1607.01759
REFERENCES
THANKS
Questions? bay@artificialintelligence.id
Slide: https://github.com/pyk/talks
Sale Stock: https://careers.salestock.io

Weitere ähnliche Inhalte

Was ist angesagt?

MySQL Architecture and Engine
MySQL Architecture and EngineMySQL Architecture and Engine
MySQL Architecture and Engine
Abdul Manaf
 
Amazon Redshift 아키텍처 및 모범사례::김민성::AWS Summit Seoul 2018
Amazon Redshift 아키텍처 및 모범사례::김민성::AWS Summit Seoul 2018Amazon Redshift 아키텍처 및 모범사례::김민성::AWS Summit Seoul 2018
Amazon Redshift 아키텍처 및 모범사례::김민성::AWS Summit Seoul 2018
Amazon Web Services Korea
 
30분만에 만드는 AWS 기반 빅데이터 분석 애플리케이션::안효빈::AWS Summit Seoul 2018
30분만에 만드는 AWS 기반 빅데이터 분석 애플리케이션::안효빈::AWS Summit Seoul 201830분만에 만드는 AWS 기반 빅데이터 분석 애플리케이션::안효빈::AWS Summit Seoul 2018
30분만에 만드는 AWS 기반 빅데이터 분석 애플리케이션::안효빈::AWS Summit Seoul 2018
Amazon Web Services Korea
 
Amazon ECS를 통한 도커 기반 콘테이너 서비스 구축하기 - AWS Summit Seoul 2017
Amazon ECS를 통한 도커 기반 콘테이너 서비스 구축하기 - AWS Summit Seoul 2017Amazon ECS를 통한 도커 기반 콘테이너 서비스 구축하기 - AWS Summit Seoul 2017
Amazon ECS를 통한 도커 기반 콘테이너 서비스 구축하기 - AWS Summit Seoul 2017
Amazon Web Services Korea
 

Was ist angesagt? (20)

An introduction to AWS CloudFormation - Pop-up Loft Tel Aviv
An introduction to AWS CloudFormation - Pop-up Loft Tel AvivAn introduction to AWS CloudFormation - Pop-up Loft Tel Aviv
An introduction to AWS CloudFormation - Pop-up Loft Tel Aviv
 
MySQL Architecture and Engine
MySQL Architecture and EngineMySQL Architecture and Engine
MySQL Architecture and Engine
 
Amazon Redshift의 이해와 활용 (김용우) - AWS DB Day
Amazon Redshift의 이해와 활용 (김용우) - AWS DB DayAmazon Redshift의 이해와 활용 (김용우) - AWS DB Day
Amazon Redshift의 이해와 활용 (김용우) - AWS DB Day
 
AWS re:Invent 특집(3) – Amazon 인공 지능(AI) 서비스 및 AWS 딥러닝 프레임웍 활용 (윤석찬)
AWS re:Invent 특집(3) – Amazon 인공 지능(AI) 서비스 및 AWS 딥러닝 프레임웍 활용 (윤석찬)AWS re:Invent 특집(3) – Amazon 인공 지능(AI) 서비스 및 AWS 딥러닝 프레임웍 활용 (윤석찬)
AWS re:Invent 특집(3) – Amazon 인공 지능(AI) 서비스 및 AWS 딥러닝 프레임웍 활용 (윤석찬)
 
Fasttext 20170720 yjy
Fasttext 20170720 yjyFasttext 20170720 yjy
Fasttext 20170720 yjy
 
[AWS Innovate 온라인 컨퍼런스] Amazon Personalize를 통한 개인화 추천 기능 실전 구현하기 - 최원근, AWS 솔...
[AWS Innovate 온라인 컨퍼런스] Amazon Personalize를 통한 개인화 추천 기능 실전 구현하기 - 최원근, AWS 솔...[AWS Innovate 온라인 컨퍼런스] Amazon Personalize를 통한 개인화 추천 기능 실전 구현하기 - 최원근, AWS 솔...
[AWS Innovate 온라인 컨퍼런스] Amazon Personalize를 통한 개인화 추천 기능 실전 구현하기 - 최원근, AWS 솔...
 
PostgreSQL'i öğrenmek ve yönetmek
PostgreSQL'i öğrenmek ve yönetmekPostgreSQL'i öğrenmek ve yönetmek
PostgreSQL'i öğrenmek ve yönetmek
 
SAP on AWS 사례로 알아보는 핵심 업무 이전 : SAP Competency 파트너사의 경험과 비젼 - 이상규 솔루션즈 아키텍트, A...
SAP on AWS 사례로 알아보는 핵심 업무 이전 : SAP Competency 파트너사의 경험과 비젼 - 이상규 솔루션즈 아키텍트, A...SAP on AWS 사례로 알아보는 핵심 업무 이전 : SAP Competency 파트너사의 경험과 비젼 - 이상규 솔루션즈 아키텍트, A...
SAP on AWS 사례로 알아보는 핵심 업무 이전 : SAP Competency 파트너사의 경험과 비젼 - 이상규 솔루션즈 아키텍트, A...
 
Amazon Redshift 아키텍처 및 모범사례::김민성::AWS Summit Seoul 2018
Amazon Redshift 아키텍처 및 모범사례::김민성::AWS Summit Seoul 2018Amazon Redshift 아키텍처 및 모범사례::김민성::AWS Summit Seoul 2018
Amazon Redshift 아키텍처 및 모범사례::김민성::AWS Summit Seoul 2018
 
Introduction to Amazon Relational Database Service
Introduction to Amazon Relational Database ServiceIntroduction to Amazon Relational Database Service
Introduction to Amazon Relational Database Service
 
30분만에 만드는 AWS 기반 빅데이터 분석 애플리케이션::안효빈::AWS Summit Seoul 2018
30분만에 만드는 AWS 기반 빅데이터 분석 애플리케이션::안효빈::AWS Summit Seoul 201830분만에 만드는 AWS 기반 빅데이터 분석 애플리케이션::안효빈::AWS Summit Seoul 2018
30분만에 만드는 AWS 기반 빅데이터 분석 애플리케이션::안효빈::AWS Summit Seoul 2018
 
AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021
AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021
AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021
 
Aurora MySQL Backtrack을 이용한 빠른 복구 방법 - 진교선 :: AWS Database Modernization Day 온라인
Aurora MySQL Backtrack을 이용한 빠른 복구 방법 - 진교선 :: AWS Database Modernization Day 온라인Aurora MySQL Backtrack을 이용한 빠른 복구 방법 - 진교선 :: AWS Database Modernization Day 온라인
Aurora MySQL Backtrack을 이용한 빠른 복구 방법 - 진교선 :: AWS Database Modernization Day 온라인
 
Encores
EncoresEncores
Encores
 
Natural language processing techniques transition from machine learning to de...
Natural language processing techniques transition from machine learning to de...Natural language processing techniques transition from machine learning to de...
Natural language processing techniques transition from machine learning to de...
 
컴퓨팅 분야 신규 서비스 - 조상만, AWS 솔루션즈 아키텍트 :: AWS re:Invent re:Cap 2021
컴퓨팅 분야 신규 서비스 - 조상만, AWS 솔루션즈 아키텍트 :: AWS re:Invent re:Cap 2021컴퓨팅 분야 신규 서비스 - 조상만, AWS 솔루션즈 아키텍트 :: AWS re:Invent re:Cap 2021
컴퓨팅 분야 신규 서비스 - 조상만, AWS 솔루션즈 아키텍트 :: AWS re:Invent re:Cap 2021
 
Introduction to Amazon Elasticsearch Service
Introduction to  Amazon Elasticsearch ServiceIntroduction to  Amazon Elasticsearch Service
Introduction to Amazon Elasticsearch Service
 
Amazon ECS를 통한 도커 기반 콘테이너 서비스 구축하기 - AWS Summit Seoul 2017
Amazon ECS를 통한 도커 기반 콘테이너 서비스 구축하기 - AWS Summit Seoul 2017Amazon ECS를 통한 도커 기반 콘테이너 서비스 구축하기 - AWS Summit Seoul 2017
Amazon ECS를 통한 도커 기반 콘테이너 서비스 구축하기 - AWS Summit Seoul 2017
 
Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL Administration
 
Getting Started with Amazon Kinesis
Getting Started with Amazon KinesisGetting Started with Amazon Kinesis
Getting Started with Amazon Kinesis
 

Ähnlich wie Intent Classifier with Facebook fastText

Moore_slides.ppt
Moore_slides.pptMoore_slides.ppt
Moore_slides.ppt
butest
 
Masterclass: Natural Language Processing in Trading with Terry Benzschawel & ...
Masterclass: Natural Language Processing in Trading with Terry Benzschawel & ...Masterclass: Natural Language Processing in Trading with Terry Benzschawel & ...
Masterclass: Natural Language Processing in Trading with Terry Benzschawel & ...
QuantInsti
 
[IJET-V2I2P3] Authors:Vijay Choure, Kavita Mahajan ,Nikhil Patil, Aishwarya N...
[IJET-V2I2P3] Authors:Vijay Choure, Kavita Mahajan ,Nikhil Patil, Aishwarya N...[IJET-V2I2P3] Authors:Vijay Choure, Kavita Mahajan ,Nikhil Patil, Aishwarya N...
[IJET-V2I2P3] Authors:Vijay Choure, Kavita Mahajan ,Nikhil Patil, Aishwarya N...
IJET - International Journal of Engineering and Techniques
 

Ähnlich wie Intent Classifier with Facebook fastText (20)

Paper id 28201441
Paper id 28201441Paper id 28201441
Paper id 28201441
 
White paper - Job skills extraction with LSTM and Word embeddings - Nikita Sh...
White paper - Job skills extraction with LSTM and Word embeddings - Nikita Sh...White paper - Job skills extraction with LSTM and Word embeddings - Nikita Sh...
White paper - Job skills extraction with LSTM and Word embeddings - Nikita Sh...
 
Topic detecton by clustering and text mining
Topic detecton by clustering and text miningTopic detecton by clustering and text mining
Topic detecton by clustering and text mining
 
Class Diagram Extraction from Textual Requirements Using NLP Techniques
Class Diagram Extraction from Textual Requirements Using NLP TechniquesClass Diagram Extraction from Textual Requirements Using NLP Techniques
Class Diagram Extraction from Textual Requirements Using NLP Techniques
 
D017232729
D017232729D017232729
D017232729
 
Supervised Sentiment Classification using DTDP algorithm
Supervised Sentiment Classification using DTDP algorithmSupervised Sentiment Classification using DTDP algorithm
Supervised Sentiment Classification using DTDP algorithm
 
Suggestion Generation for Specific Erroneous Part in a Sentence using Deep Le...
Suggestion Generation for Specific Erroneous Part in a Sentence using Deep Le...Suggestion Generation for Specific Erroneous Part in a Sentence using Deep Le...
Suggestion Generation for Specific Erroneous Part in a Sentence using Deep Le...
 
NE7012- SOCIAL NETWORK ANALYSIS
NE7012- SOCIAL NETWORK ANALYSISNE7012- SOCIAL NETWORK ANALYSIS
NE7012- SOCIAL NETWORK ANALYSIS
 
Moore_slides.ppt
Moore_slides.pptMoore_slides.ppt
Moore_slides.ppt
 
ML crash course
ML crash courseML crash course
ML crash course
 
Bridging the gap between AI and UI - DSI Vienna - full version
Bridging the gap between AI and UI - DSI Vienna - full versionBridging the gap between AI and UI - DSI Vienna - full version
Bridging the gap between AI and UI - DSI Vienna - full version
 
Demo day
Demo dayDemo day
Demo day
 
Advancements in Hindi-English Neural Machine Translation: Leveraging LSTM wit...
Advancements in Hindi-English Neural Machine Translation: Leveraging LSTM wit...Advancements in Hindi-English Neural Machine Translation: Leveraging LSTM wit...
Advancements in Hindi-English Neural Machine Translation: Leveraging LSTM wit...
 
introduction to machine learning and nlp
introduction to machine learning and nlpintroduction to machine learning and nlp
introduction to machine learning and nlp
 
Masterclass: Natural Language Processing in Trading with Terry Benzschawel & ...
Masterclass: Natural Language Processing in Trading with Terry Benzschawel & ...Masterclass: Natural Language Processing in Trading with Terry Benzschawel & ...
Masterclass: Natural Language Processing in Trading with Terry Benzschawel & ...
 
Summarization using ntc approach based on keyword extraction for discussion f...
Summarization using ntc approach based on keyword extraction for discussion f...Summarization using ntc approach based on keyword extraction for discussion f...
Summarization using ntc approach based on keyword extraction for discussion f...
 
PyCon 2013 - Experiments in data mining, entity disambiguation and how to thi...
PyCon 2013 - Experiments in data mining, entity disambiguation and how to thi...PyCon 2013 - Experiments in data mining, entity disambiguation and how to thi...
PyCon 2013 - Experiments in data mining, entity disambiguation and how to thi...
 
[IJET-V2I2P3] Authors:Vijay Choure, Kavita Mahajan ,Nikhil Patil, Aishwarya N...
[IJET-V2I2P3] Authors:Vijay Choure, Kavita Mahajan ,Nikhil Patil, Aishwarya N...[IJET-V2I2P3] Authors:Vijay Choure, Kavita Mahajan ,Nikhil Patil, Aishwarya N...
[IJET-V2I2P3] Authors:Vijay Choure, Kavita Mahajan ,Nikhil Patil, Aishwarya N...
 
Extraction of Data Using Comparable Entity Mining
Extraction of Data Using Comparable Entity MiningExtraction of Data Using Comparable Entity Mining
Extraction of Data Using Comparable Entity Mining
 
E017252831
E017252831E017252831
E017252831
 

Mehr von Bayu Aldi Yansyah

Pertemuan 2 & 3: A.I. Indonesia Academy Surabaya Batch #1
Pertemuan 2 & 3: A.I. Indonesia Academy Surabaya Batch #1Pertemuan 2 & 3: A.I. Indonesia Academy Surabaya Batch #1
Pertemuan 2 & 3: A.I. Indonesia Academy Surabaya Batch #1
Bayu Aldi Yansyah
 

Mehr von Bayu Aldi Yansyah (9)

Panduan Memulai Karir di Data Science (Binus University)
Panduan Memulai Karir di Data Science (Binus University)Panduan Memulai Karir di Data Science (Binus University)
Panduan Memulai Karir di Data Science (Binus University)
 
Penerapan Machine Learning di Industri
Penerapan Machine Learning di IndustriPenerapan Machine Learning di Industri
Penerapan Machine Learning di Industri
 
PyTorch for Deep Learning Practitioners
PyTorch for Deep Learning PractitionersPyTorch for Deep Learning Practitioners
PyTorch for Deep Learning Practitioners
 
Asynchronous Python at Kumparan
Asynchronous Python at KumparanAsynchronous Python at Kumparan
Asynchronous Python at Kumparan
 
Panduan untuk Memulai Karir di Data Science
Panduan untuk Memulai Karir di Data SciencePanduan untuk Memulai Karir di Data Science
Panduan untuk Memulai Karir di Data Science
 
Introduction to Python and TensorFlow
Introduction to Python and TensorFlowIntroduction to Python and TensorFlow
Introduction to Python and TensorFlow
 
Clustering Semantically Similar Words
Clustering Semantically Similar WordsClustering Semantically Similar Words
Clustering Semantically Similar Words
 
Pertemuan 2 & 3: A.I. Indonesia Academy Surabaya Batch #1
Pertemuan 2 & 3: A.I. Indonesia Academy Surabaya Batch #1Pertemuan 2 & 3: A.I. Indonesia Academy Surabaya Batch #1
Pertemuan 2 & 3: A.I. Indonesia Academy Surabaya Batch #1
 
Pertemuan 1 - AI Indonesia Academy Surabaya Batch #1
Pertemuan 1 - AI Indonesia Academy Surabaya Batch #1Pertemuan 1 - AI Indonesia Academy Surabaya Batch #1
Pertemuan 1 - AI Indonesia Academy Surabaya Batch #1
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Kürzlich hochgeladen (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Intent Classifier with Facebook fastText

  • 1. Intent Classifier with Facebook fastText Facebook Developer Circle, Malang 22 February 2017 Bayu Aldi Yansyah Data Scientist at Sale Stock
  • 2. OUR GOALS 1. Understand how Machine Learning is applied in Messenger bot development. 2. Understand what is fastText and why it is important. 3. Able to create intent classifier model with fastText.
  • 3. Aku mau pesan tiket surabaya-jakarta buat minggu pagi ya Untuk 2 org Ada yang bisa Aska bantu? Aska Bayu Aska is our Messenger bot
  • 4. HUMAN Understand the context and extract the available information easily. Intent : Book Flight Ticket Departure Location : Surabaya Departure Time : Minggu pagi Arrival Location : Jakarta Quantity : 2 Aku pesan tiket surabaya-jakarta buat minggu pagi ya Untuk 2 org
  • 5. OUR BOT 1. What is the intent? Book Flight Ticket Book Hotel Ask a Question Buy a Product … Aku pesan tiket surabaya-jakarta buat minggu pagi ya Untuk 2 org 2. Extract information DepLoc : Surabaya DepTime : Minggu pagi ArrLoc : Jakarta Quantity : 2 He need to know the intent of the chat first and extract the available information.
  • 6. INTENT CLASSIFIER INPUT CLASSIFIER OUTPUT User’s chat User’s intent Example of user’s intent: Book a flight ticket, book a hotel, buy a product and asking a specific questions.
  • 7. INTENT CLASSIFIER - Intent Classifier can be seen as Document Classification/Text Classification task - Text categorization (a.k.a. text classification) is the task of assigning predefined categories to free-text documents. - We can use Machine Learning approach to solve this task. - Popular method is Supervised learning.
  • 8. SUPERVISED LEARNING DATA INPUT OUTPUT MODELALGORITHM TRAINING EVALUATE DEPLOY - Example data: chat message as an input and the label of intent as the output. - Popular algorithms for text classification: - Linear classifiers: Support Vector Machine (Joachims, 1998) - Convolutional Neural Networks based: Kim 2014 & Zhang and LeCun 2015 - Example of the metrics to evaluate: Precision & Recall
  • 9. SUPERVISED LEARNING - Neural Network based models achieve very good performance in practice, but it is time consuming to train and test. It need large resources for large datasets. - Linear classifiers are simple and often obtain state-of-the-art performance if the right features is used. It doesn’t need large resources resource. However, linear classifiers do not share parameters among features and classes. - fastText is trying to solve these problems.
  • 10. FASTTEXT - fastText is a C++ library for efficient learning of word representations and sentence classification. - Word Representation learning: - Continuous Bag-Of-Words (CBOW) - Continuous Skip-gram - Text Classification: A simple linear model where using averaged word representation as text representation.
  • 11. - Word representation learning or word embedding is a technique to represent a word as a vector. - The result of word embedding frequently referred as “word vector” or “distributed representation of words”. - There are 3 main approaches to word embedding: 1. Neural Networks model based 2. Dimensionality reduction based 3. Probabilistic model based - The idea of these approaches are to learn vector representations of words in an unsupervised manner. WORD REPRESENTATION LEARNING
  • 12. CONTINOUS BAG-OF-WORDS - A simple neural networks model. - The training data is a sequence of words 𝑤1, 𝑤2, … , 𝑤 𝑇 for 𝑤𝑡 ∈ 𝑉 - The model is trying predict the word 𝑤𝑡 based on the surrounding context (𝑛 words from left: 𝑤𝑡−1, 𝑤𝑡−2 and 𝑛 words from the right: 𝑤𝑡−1, 𝑤𝑡−2). - There are no hidden layer in this model. - Projection layer is averaged across input words. 𝑤𝑡+2 Keren Sale bisa bayar dirumah... ... 𝑤𝑡+1𝑤𝑡𝑤𝑡−1𝑤𝑡−2
  • 13. CONTINOUS BAG-OF-WORDS 𝑥 𝑡+2𝑥 𝑡+1𝑥 𝑡−1𝑥 𝑡−2 𝑥′ 𝑡 𝑣 Visualization of CBOW model
  • 14. CONTINOUS SKIP-GRAM - The training data is a sequence of words 𝑤1, 𝑤2, … , 𝑤 𝑇 for 𝑤𝑡 ∈ 𝑉 - The model is trying predict the surrounding context (𝑛 words from left: 𝑤𝑡−1, 𝑤𝑡−2 and 𝑛 words from the right: 𝑤𝑡−1, 𝑤𝑡−2) based on the word 𝑤𝑡. 𝑤𝑡+2 Keren bisa... ... 𝑤𝑡+1𝑤𝑡𝑤𝑡−1𝑤𝑡−2
  • 15. CONTINOUS SKIP-GRAM 𝑥 𝑡+2𝑥 𝑡+1𝑥 𝑡−1𝑥 𝑡−2 𝑥 𝑡 𝑣 Visualization of Skip-gram model
  • 16. More detailed information about word embedding available at “Clustering semantically similar words” https://github.com/pyk/talks WORD REPRESENTATION LEARNING
  • 17. LINEAR CLASSIFIER - The architecture is similar with Continuous Bag-of-Words model, where the middle of words is replaced by the label. - The word representations are averaged into text representation, which is in turn fed to a linear classifier.
  • 18. FASTTEXT Step by step to create intent classifier model with fastText. It’s super easy. Install the fasttext(1) first https://github.com/facebookresearch/fasttext (Only support Linux and OSX)
  • 19. FASTTEXT Prepare the training data: 1. Convert the intent as numeric. For example: Booking flight = 0, Buy product = 1 2. Preprocess the data: Tokenization, remove symbols etc 3. Create the training data with the following format: prefix_labelnum token1 token2 token3 …
  • 20. FASTTEXT Create the model: 1. Run: ./fasttext supervised -input train.dat -output intent_classifier -dim 100 -lr 0.1 -wordNgrams 2 -minCount 1 -bucket 2000000 -epoch 5 -thread 4 - train.dat is the training data - output model: intent_classifier.bin
  • 21. DEPLOY If you are Python programmer, you can use fastText.py https://github.com/salestock/fastText.py to deploy the model. - Create a API service with Flask - Load & serve the model - Create new endpoint for the inference step
  • 22. - Enriching Word Vectors with Subword Information by Bojanowski et al (2016) https://arxiv.org/abs/1607.04606 - Bag of Tricks for Efficient Text Classification by Joulin et al (2016) https://arxiv.org/abs/1607.01759 REFERENCES