SlideShare a Scribd company logo
1 of 28
Download to read offline
Apache MXNet Seattle meetup - August
GluonNLP:
A Deep Learning Toolkit for
NLP Practitioners
Presenter: Chenguang Wang
MXNet Science Team
1
Apache MXNet Seattle meetup - August
GluonNLP
2
Apache MXNet Seattle meetup - August
GluonNLP
• A deep learning framework designed for fast data processing/
loading, and model building
3
Apache MXNet Seattle meetup - August
GluonNLP APIs
gluonnlp.data

Build efficient data pipelines for NLP tasks

gluonnlp.model

Train or load state-of-the-arts models for common NLP tasks

gluonnlp.embedding

Train or load state-of-the-arts embeddings for common NLP tasks
4
Apache MXNet Seattle meetup - August
GluonNLP Community
Main contributors:
Sheng Zha, Chenguang Wang, Aston Zhang, Mu Li, Shuai Zheng, Leonard Lausen,
Xingjian Shi

Code&docs:
https://github.com/dmlc/gluon-nlp

http://gluon-nlp.mxnet.io/

Forums:
https://discuss.gluon.ai/

https://discuss.mxnet.io/

5
Apache MXNet Seattle meetup - August
GluonNLP Cool Examples
6
Apache MXNet Seattle meetup - August
Data Bucketing
How to generate the mini-batches?
7
Apache MXNet Seattle meetup - August
No Bucketing
Average Padding = 11.7
8
Data loading
slow and memory inefficient
Apache MXNet Seattle meetup - August
Sorted Bucketing
Average Padding = 3.7
9
GluonNLP data bucketing
fast and memory efficient
Apache MXNet Seattle meetup - August
Google Neural Machine Translation
10
Encoder: Bidireciontal LSTM
+ LSTM + Residual
Decoder: LSTM + Residual
+ MLP Attention
• Our implementation:
• BLEU 26.22 on
IWSLT2015, 10 epochs,
Beam Size=10
• Tensorflow/nmt:
• BLEU 26.10 on
IWSLT2015, Beam
Size=10
Wu, Yonghui, et al. "Google's neural machine translation system: Bridging the gap between human and machine translation." arXiv preprint arXiv:1609.08144 (2016).
Apache MXNet Seattle meetup - August
Transformer
• Encoder
• 6 layers of self-attention+ffn
• Decoder
• 6 layers of masked self-attention and
• output of encoder + ffn
11
• Our implementation:
• BLEU 26.81 on WMT2014en_de, 40 epochs
• Tensorflow/t2t:
• BLEU 26.55 on WMT2014en_de
Vaswani, Ashish, et al. "Attention is all you need." Advances in Neural Information Processing Systems. 2017.
Apache MXNet Seattle meetup - August
GluonNLP Step-by-step
-A language model example
12
Apache MXNet Seattle meetup - August
Language Model
• Language model is trying to predict the next word based on the
previous ones
13
Apache MXNet Seattle meetup - August
Steps to Write Language Model
• 1. Collect a dataset <-most of the work
• 2. Build the model <-a few lines of code
• 3. Train <-a few lines of code
• 4. Evaluate <-one line
• 5. Inference <-one line
14
http://gluon-nlp.mxnet.io/examples/language_model/language_model.html
Apache MXNet Seattle meetup - August
Step #1: Collect a dataset
import gluonnlp as nlp
dataset_name = 'wikitext-2'
train_dataset, val_dataset, test_dataset = [nlp.data.WikiText2(segment=segment,
bos=None, eos='<eos>',
skip_empty=False)
for segment in ['train', 'val', 'test']]
vocab = nlp.Vocab(nlp.data.Counter(train_dataset[0]), padding_token=None,
bos_token=None)
train_data, val_data, test_data = [x.bptt_batchify(vocab, bptt, batch_size,
last_batch='discard')
for x in [train_dataset, val_dataset,
test_dataset]]
15
Apache MXNet Seattle meetup - August
Step #2: Build the model
with self.name_scope():
self.embedding = self._get_embedding()
self.encoder = self._get_encoder()
self.decoder = self._get_decoder()
16self.embedding self.encoder self.decoder
model = nlp.model.train.StandardRNN(args.model, len(vocab), args.emsize,
args.nhid, args.nlayers, args.dropout, args.tied)
Apache MXNet Seattle meetup - August
Step #3: Train
model.initialize(mx.init.Xavier(), ctx=context)
trainer = gluon.Trainer(model.collect_params(), 'sgd',
{'learning_rate': lr,
'momentum': 0,
'wd': 0})
loss = gluon.loss.SoftmaxCrossEntropyLoss()
train(model, train_data, val_data, test_data, epochs, lr)
17
Apache MXNet Seattle meetup - August
Step #4: Evaluate
test_L = evaluate(model, test_data, batch_size)
18
Apache MXNet Seattle meetup - August
Step #5: Inference
model, _ = nlp.model.get_model('standard_lstm_lm_200', vocab=vocab)
test_L = evaluate(model, test_data, batch_size)
19
Apache MXNet Seattle meetup - August
GluonNLP Embedding
http://gluon-nlp.mxnet.io/api/embedding.html
20
Apache MXNet Seattle meetup - August
Embedding is Powerful!
21
Language Embedding Graph Embedding Image Embedding
Word Embedding, Sentence Embedding,
Paragraph embedding etc.
Word2vec, Fasttext, Glove, etc
Language model,
machine translation,
QA, Dialog System, etc.
Network embedding,
Subgraph embedding
LINE, Deepwalk,
CNN embedding
CNN embedding
Faster R-CNN, etc.
Graph mining
etc.
Image classification,
Image detection,
SSD, etc
Recommendation
Information Retrieval
Advertising, etc.
Embedding
… … …
Apache MXNet Seattle meetup - August
Word Embedding
Map words or phrases from the vocabulary to vectors of real numbers.
22
Apache MXNet Seattle meetup - August
Word2vec
• Skip-gram
• Given a center word,
predict surrounding
words
23
“Tomas Mikolov, Kai Chen, Greg Corrado, and Jeffrey Dean.
Efficient estimation of word representations in vector space.
ICLR Workshop , 2013.”
Apache MXNet Seattle meetup - August
FastText
• (Unknown) word:
• the sum of char-n-gram.
24
Bojanowski, Piotr, et al. "Enriching word vectors with subword information." arXiv preprint arXiv:1607.04606 (2016).
Apache MXNet Seattle meetup - August
Embedding Evaluation
• Similarity
• See the example: http://gluon-nlp.mxnet.io/index.html
• Analogy
• See the example: http://gluon-nlp.mxnet.io/examples/
word_embedding/word_embedding.html
25
Apache MXNet Seattle meetup - August
• Dataset
• Many public datasets.
• Streaming for very large
datasets.
• Text data processing
• Vocabulary
• Tokenization
• Bucketing
• Modeling
• Attention
• Beam Search
• Weight Drop
• Embedding
• Pretrained Embedding
• Embedding Training
GluonNLP Status
• State-of-the-art models
• Embedding, LM, MT, SA
• Examples friendly to users that
are new to the task
• Reproducible training scripts
26
More is coming soon!
Apache MXNet Seattle meetup - August
Summary
• In GluonNLP, we provide
• High-level APIs
• gluonnlp.data, gluonnlp.model, gluonnlp.embedding
• Low-Level APIs
• gluonnlp.data.batchify, gluonnlp.model.StandardRNN
• Designed for practitioners: researchers and engineers
27
Apache MXNet Seattle meetup - August
Thanks && QA
gluon-nlp.mxnet.io
28

More Related Content

What's hot

An excursion into Graph Analytics with Apache Spark GraphX
An excursion into Graph Analytics with Apache Spark GraphXAn excursion into Graph Analytics with Apache Spark GraphX
An excursion into Graph Analytics with Apache Spark GraphXKrishna Sankar
 
Congressional PageRank: Graph Analytics of US Congress With Neo4j
Congressional PageRank: Graph Analytics of US Congress With Neo4jCongressional PageRank: Graph Analytics of US Congress With Neo4j
Congressional PageRank: Graph Analytics of US Congress With Neo4jWilliam Lyon
 
Jake Mannix, Lead Data Engineer, Lucidworks at MLconf SEA - 5/20/16
Jake Mannix, Lead Data Engineer, Lucidworks at MLconf SEA - 5/20/16Jake Mannix, Lead Data Engineer, Lucidworks at MLconf SEA - 5/20/16
Jake Mannix, Lead Data Engineer, Lucidworks at MLconf SEA - 5/20/16MLconf
 
Microservices, containers, and machine learning
Microservices, containers, and machine learningMicroservices, containers, and machine learning
Microservices, containers, and machine learningPaco Nathan
 
Unifying State-of-the-Art AI and Big Data in Apache Spark with Reynold Xin
Unifying State-of-the-Art AI and Big Data in Apache Spark with Reynold XinUnifying State-of-the-Art AI and Big Data in Apache Spark with Reynold Xin
Unifying State-of-the-Art AI and Big Data in Apache Spark with Reynold XinDatabricks
 
H2O World - Benchmarking Open Source ML Platforms - Szilard Pafka
H2O World - Benchmarking Open Source ML Platforms - Szilard PafkaH2O World - Benchmarking Open Source ML Platforms - Szilard Pafka
H2O World - Benchmarking Open Source ML Platforms - Szilard PafkaSri Ambati
 
GraphGen: Conducting Graph Analytics over Relational Databases
GraphGen: Conducting Graph Analytics over Relational DatabasesGraphGen: Conducting Graph Analytics over Relational Databases
GraphGen: Conducting Graph Analytics over Relational DatabasesKonstantinos Xirogiannopoulos
 
FlinkML: Large Scale Machine Learning with Apache Flink
FlinkML: Large Scale Machine Learning with Apache FlinkFlinkML: Large Scale Machine Learning with Apache Flink
FlinkML: Large Scale Machine Learning with Apache FlinkTheodoros Vasiloudis
 
Sparkling Water 5 28-14
Sparkling Water 5 28-14Sparkling Water 5 28-14
Sparkling Water 5 28-14Sri Ambati
 
Intro to H2O Machine Learning in R at Santa Clara University
Intro to H2O Machine Learning in R at Santa Clara UniversityIntro to H2O Machine Learning in R at Santa Clara University
Intro to H2O Machine Learning in R at Santa Clara UniversitySri Ambati
 
Taking Jupyter Notebooks and Apache Spark to the Next Level PixieDust with Da...
Taking Jupyter Notebooks and Apache Spark to the Next Level PixieDust with Da...Taking Jupyter Notebooks and Apache Spark to the Next Level PixieDust with Da...
Taking Jupyter Notebooks and Apache Spark to the Next Level PixieDust with Da...Databricks
 
Julia + R for Data Science
Julia + R for Data ScienceJulia + R for Data Science
Julia + R for Data ScienceWork-Bench
 
Charles_Qian_Resume
Charles_Qian_ResumeCharles_Qian_Resume
Charles_Qian_ResumeCharles Qian
 
Extending the Yahoo Streaming Benchmark
Extending the Yahoo Streaming BenchmarkExtending the Yahoo Streaming Benchmark
Extending the Yahoo Streaming BenchmarkJamie Grier
 
Msr2010 ibrahim
Msr2010 ibrahimMsr2010 ibrahim
Msr2010 ibrahimSAIL_QU
 
Intro to Python Data Analysis in Wakari
Intro to Python Data Analysis in WakariIntro to Python Data Analysis in Wakari
Intro to Python Data Analysis in WakariKarissa Rae McKelvey
 
Graph Databases in Python (PyCon Canada 2012)
Graph Databases in Python (PyCon Canada 2012)Graph Databases in Python (PyCon Canada 2012)
Graph Databases in Python (PyCon Canada 2012)Javier de la Rosa
 
Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark...
 Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark... Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark...
Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark...Databricks
 
Data Science Challenges in Personal Program Analysis
Data Science Challenges in Personal Program AnalysisData Science Challenges in Personal Program Analysis
Data Science Challenges in Personal Program AnalysisWork-Bench
 
K. Tzoumas & S. Ewen – Flink Forward Keynote
K. Tzoumas & S. Ewen – Flink Forward KeynoteK. Tzoumas & S. Ewen – Flink Forward Keynote
K. Tzoumas & S. Ewen – Flink Forward KeynoteFlink Forward
 

What's hot (20)

An excursion into Graph Analytics with Apache Spark GraphX
An excursion into Graph Analytics with Apache Spark GraphXAn excursion into Graph Analytics with Apache Spark GraphX
An excursion into Graph Analytics with Apache Spark GraphX
 
Congressional PageRank: Graph Analytics of US Congress With Neo4j
Congressional PageRank: Graph Analytics of US Congress With Neo4jCongressional PageRank: Graph Analytics of US Congress With Neo4j
Congressional PageRank: Graph Analytics of US Congress With Neo4j
 
Jake Mannix, Lead Data Engineer, Lucidworks at MLconf SEA - 5/20/16
Jake Mannix, Lead Data Engineer, Lucidworks at MLconf SEA - 5/20/16Jake Mannix, Lead Data Engineer, Lucidworks at MLconf SEA - 5/20/16
Jake Mannix, Lead Data Engineer, Lucidworks at MLconf SEA - 5/20/16
 
Microservices, containers, and machine learning
Microservices, containers, and machine learningMicroservices, containers, and machine learning
Microservices, containers, and machine learning
 
Unifying State-of-the-Art AI and Big Data in Apache Spark with Reynold Xin
Unifying State-of-the-Art AI and Big Data in Apache Spark with Reynold XinUnifying State-of-the-Art AI and Big Data in Apache Spark with Reynold Xin
Unifying State-of-the-Art AI and Big Data in Apache Spark with Reynold Xin
 
H2O World - Benchmarking Open Source ML Platforms - Szilard Pafka
H2O World - Benchmarking Open Source ML Platforms - Szilard PafkaH2O World - Benchmarking Open Source ML Platforms - Szilard Pafka
H2O World - Benchmarking Open Source ML Platforms - Szilard Pafka
 
GraphGen: Conducting Graph Analytics over Relational Databases
GraphGen: Conducting Graph Analytics over Relational DatabasesGraphGen: Conducting Graph Analytics over Relational Databases
GraphGen: Conducting Graph Analytics over Relational Databases
 
FlinkML: Large Scale Machine Learning with Apache Flink
FlinkML: Large Scale Machine Learning with Apache FlinkFlinkML: Large Scale Machine Learning with Apache Flink
FlinkML: Large Scale Machine Learning with Apache Flink
 
Sparkling Water 5 28-14
Sparkling Water 5 28-14Sparkling Water 5 28-14
Sparkling Water 5 28-14
 
Intro to H2O Machine Learning in R at Santa Clara University
Intro to H2O Machine Learning in R at Santa Clara UniversityIntro to H2O Machine Learning in R at Santa Clara University
Intro to H2O Machine Learning in R at Santa Clara University
 
Taking Jupyter Notebooks and Apache Spark to the Next Level PixieDust with Da...
Taking Jupyter Notebooks and Apache Spark to the Next Level PixieDust with Da...Taking Jupyter Notebooks and Apache Spark to the Next Level PixieDust with Da...
Taking Jupyter Notebooks and Apache Spark to the Next Level PixieDust with Da...
 
Julia + R for Data Science
Julia + R for Data ScienceJulia + R for Data Science
Julia + R for Data Science
 
Charles_Qian_Resume
Charles_Qian_ResumeCharles_Qian_Resume
Charles_Qian_Resume
 
Extending the Yahoo Streaming Benchmark
Extending the Yahoo Streaming BenchmarkExtending the Yahoo Streaming Benchmark
Extending the Yahoo Streaming Benchmark
 
Msr2010 ibrahim
Msr2010 ibrahimMsr2010 ibrahim
Msr2010 ibrahim
 
Intro to Python Data Analysis in Wakari
Intro to Python Data Analysis in WakariIntro to Python Data Analysis in Wakari
Intro to Python Data Analysis in Wakari
 
Graph Databases in Python (PyCon Canada 2012)
Graph Databases in Python (PyCon Canada 2012)Graph Databases in Python (PyCon Canada 2012)
Graph Databases in Python (PyCon Canada 2012)
 
Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark...
 Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark... Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark...
Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark...
 
Data Science Challenges in Personal Program Analysis
Data Science Challenges in Personal Program AnalysisData Science Challenges in Personal Program Analysis
Data Science Challenges in Personal Program Analysis
 
K. Tzoumas & S. Ewen – Flink Forward Keynote
K. Tzoumas & S. Ewen – Flink Forward KeynoteK. Tzoumas & S. Ewen – Flink Forward Keynote
K. Tzoumas & S. Ewen – Flink Forward Keynote
 

Similar to GluonNLP MXNet Meetup-Aug

jlettvin.resume.20160922.STAR
jlettvin.resume.20160922.STARjlettvin.resume.20160922.STAR
jlettvin.resume.20160922.STARJonathan Lettvin
 
Maoye resume 2017_1_v10_short
Maoye resume 2017_1_v10_shortMaoye resume 2017_1_v10_short
Maoye resume 2017_1_v10_shortMao Ye
 
Building and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache AirflowBuilding and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache AirflowKaxil Naik
 
2021 04-20 apache arrow and its impact on the database industry.pptx
2021 04-20  apache arrow and its impact on the database industry.pptx2021 04-20  apache arrow and its impact on the database industry.pptx
2021 04-20 apache arrow and its impact on the database industry.pptxAndrew Lamb
 
ApacheCon 2021 Apache Deep Learning 302
ApacheCon 2021   Apache Deep Learning 302ApacheCon 2021   Apache Deep Learning 302
ApacheCon 2021 Apache Deep Learning 302Timothy Spann
 
Challenges on Distributed Machine Learning
Challenges on Distributed Machine LearningChallenges on Distributed Machine Learning
Challenges on Distributed Machine Learningjie cao
 
New Developments in H2O: April 2017 Edition
New Developments in H2O: April 2017 EditionNew Developments in H2O: April 2017 Edition
New Developments in H2O: April 2017 EditionSri Ambati
 
The Big Data Puzzle, Where Does the Eclipse Piece Fit?
The Big Data Puzzle, Where Does the Eclipse Piece Fit?The Big Data Puzzle, Where Does the Eclipse Piece Fit?
The Big Data Puzzle, Where Does the Eclipse Piece Fit?J Langley
 
Bryan Cheng-20170222
Bryan Cheng-20170222Bryan Cheng-20170222
Bryan Cheng-20170222Bryan Cheng
 
David_Thomas_Resume_Software_08_29_16
David_Thomas_Resume_Software_08_29_16David_Thomas_Resume_Software_08_29_16
David_Thomas_Resume_Software_08_29_16Dave Thomas
 
Analyzing Big Data's Weakest Link (hint: it might be you)
Analyzing Big Data's Weakest Link  (hint: it might be you)Analyzing Big Data's Weakest Link  (hint: it might be you)
Analyzing Big Data's Weakest Link (hint: it might be you)HPCC Systems
 
RMLL 2013 : Build Your Personal Search Engine using Crawlzilla
RMLL 2013 : Build Your Personal Search Engine using CrawlzillaRMLL 2013 : Build Your Personal Search Engine using Crawlzilla
RMLL 2013 : Build Your Personal Search Engine using CrawlzillaJazz Yao-Tsung Wang
 
Big Data: the weakest link
Big Data: the weakest linkBig Data: the weakest link
Big Data: the weakest linkCS, NcState
 
Shiwei Liu-resume - 2017
Shiwei Liu-resume - 2017Shiwei Liu-resume - 2017
Shiwei Liu-resume - 2017Savill Liu
 
A Maturing Role of Workflows in the Presence of Heterogenous Computing Archit...
A Maturing Role of Workflows in the Presence of Heterogenous Computing Archit...A Maturing Role of Workflows in the Presence of Heterogenous Computing Archit...
A Maturing Role of Workflows in the Presence of Heterogenous Computing Archit...Ilkay Altintas, Ph.D.
 
Swift: A parallel scripting for applications at the petascale and beyond.
Swift: A parallel scripting for applications at the petascale and beyond.Swift: A parallel scripting for applications at the petascale and beyond.
Swift: A parallel scripting for applications at the petascale and beyond.Nagasuri Bala Venkateswarlu
 
Cytoscape: Now and Future
Cytoscape: Now and FutureCytoscape: Now and Future
Cytoscape: Now and FutureKeiichiro Ono
 

Similar to GluonNLP MXNet Meetup-Aug (20)

jlettvin.resume.20160922.STAR
jlettvin.resume.20160922.STARjlettvin.resume.20160922.STAR
jlettvin.resume.20160922.STAR
 
Maoye resume 2017_1_v10_short
Maoye resume 2017_1_v10_shortMaoye resume 2017_1_v10_short
Maoye resume 2017_1_v10_short
 
Building and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache AirflowBuilding and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache Airflow
 
2021 04-20 apache arrow and its impact on the database industry.pptx
2021 04-20  apache arrow and its impact on the database industry.pptx2021 04-20  apache arrow and its impact on the database industry.pptx
2021 04-20 apache arrow and its impact on the database industry.pptx
 
ApacheCon 2021 Apache Deep Learning 302
ApacheCon 2021   Apache Deep Learning 302ApacheCon 2021   Apache Deep Learning 302
ApacheCon 2021 Apache Deep Learning 302
 
Challenges on Distributed Machine Learning
Challenges on Distributed Machine LearningChallenges on Distributed Machine Learning
Challenges on Distributed Machine Learning
 
New Developments in H2O: April 2017 Edition
New Developments in H2O: April 2017 EditionNew Developments in H2O: April 2017 Edition
New Developments in H2O: April 2017 Edition
 
Goncalo Pereira CV
Goncalo Pereira CVGoncalo Pereira CV
Goncalo Pereira CV
 
The Big Data Puzzle, Where Does the Eclipse Piece Fit?
The Big Data Puzzle, Where Does the Eclipse Piece Fit?The Big Data Puzzle, Where Does the Eclipse Piece Fit?
The Big Data Puzzle, Where Does the Eclipse Piece Fit?
 
Bryan Cheng-20170222
Bryan Cheng-20170222Bryan Cheng-20170222
Bryan Cheng-20170222
 
David_Thomas_Resume_Software_08_29_16
David_Thomas_Resume_Software_08_29_16David_Thomas_Resume_Software_08_29_16
David_Thomas_Resume_Software_08_29_16
 
Manoj_Rajandrakumar_Resume
Manoj_Rajandrakumar_ResumeManoj_Rajandrakumar_Resume
Manoj_Rajandrakumar_Resume
 
Analyzing Big Data's Weakest Link (hint: it might be you)
Analyzing Big Data's Weakest Link  (hint: it might be you)Analyzing Big Data's Weakest Link  (hint: it might be you)
Analyzing Big Data's Weakest Link (hint: it might be you)
 
RMLL 2013 : Build Your Personal Search Engine using Crawlzilla
RMLL 2013 : Build Your Personal Search Engine using CrawlzillaRMLL 2013 : Build Your Personal Search Engine using Crawlzilla
RMLL 2013 : Build Your Personal Search Engine using Crawlzilla
 
Big Data: the weakest link
Big Data: the weakest linkBig Data: the weakest link
Big Data: the weakest link
 
Shiwei Liu-resume - 2017
Shiwei Liu-resume - 2017Shiwei Liu-resume - 2017
Shiwei Liu-resume - 2017
 
A Maturing Role of Workflows in the Presence of Heterogenous Computing Archit...
A Maturing Role of Workflows in the Presence of Heterogenous Computing Archit...A Maturing Role of Workflows in the Presence of Heterogenous Computing Archit...
A Maturing Role of Workflows in the Presence of Heterogenous Computing Archit...
 
Swift: A parallel scripting for applications at the petascale and beyond.
Swift: A parallel scripting for applications at the petascale and beyond.Swift: A parallel scripting for applications at the petascale and beyond.
Swift: A parallel scripting for applications at the petascale and beyond.
 
Cytoscape: Now and Future
Cytoscape: Now and FutureCytoscape: Now and Future
Cytoscape: Now and Future
 
Resume
ResumeResume
Resume
 

Recently uploaded

Technical english Technical english.pptx
Technical english Technical english.pptxTechnical english Technical english.pptx
Technical english Technical english.pptxyoussefboujtat3
 
Introduction and significance of Symbiotic algae
Introduction and significance of  Symbiotic algaeIntroduction and significance of  Symbiotic algae
Introduction and significance of Symbiotic algaekushbuR
 
GBSN - Biochemistry (Unit 8) Enzymology
GBSN - Biochemistry (Unit 8) EnzymologyGBSN - Biochemistry (Unit 8) Enzymology
GBSN - Biochemistry (Unit 8) EnzymologyAreesha Ahmad
 
PARENTAL CARE IN FISHES.pptx for 5th sem
PARENTAL CARE IN FISHES.pptx for 5th semPARENTAL CARE IN FISHES.pptx for 5th sem
PARENTAL CARE IN FISHES.pptx for 5th semborkhotudu123
 
Molecular and Cellular Mechanism of Action of Hormones such as Growth Hormone...
Molecular and Cellular Mechanism of Action of Hormones such as Growth Hormone...Molecular and Cellular Mechanism of Action of Hormones such as Growth Hormone...
Molecular and Cellular Mechanism of Action of Hormones such as Growth Hormone...Ansari Aashif Raza Mohd Imtiyaz
 
Classification of Kerogen, Perspective on palynofacies in depositional envi...
Classification of Kerogen,  Perspective on palynofacies in depositional  envi...Classification of Kerogen,  Perspective on palynofacies in depositional  envi...
Classification of Kerogen, Perspective on palynofacies in depositional envi...Sangram Sahoo
 
Warming the earth and the atmosphere.pptx
Warming the earth and the atmosphere.pptxWarming the earth and the atmosphere.pptx
Warming the earth and the atmosphere.pptxGlendelCaroz
 
GBSN - Biochemistry (Unit 3) Metabolism
GBSN - Biochemistry (Unit 3) MetabolismGBSN - Biochemistry (Unit 3) Metabolism
GBSN - Biochemistry (Unit 3) MetabolismAreesha Ahmad
 
GBSN - Microbiology (Unit 5) Concept of isolation
GBSN - Microbiology (Unit 5) Concept of isolationGBSN - Microbiology (Unit 5) Concept of isolation
GBSN - Microbiology (Unit 5) Concept of isolationAreesha Ahmad
 
ANATOMY OF DICOT AND MONOCOT LEAVES.pptx
ANATOMY OF DICOT AND MONOCOT LEAVES.pptxANATOMY OF DICOT AND MONOCOT LEAVES.pptx
ANATOMY OF DICOT AND MONOCOT LEAVES.pptxRASHMI M G
 
EU START PROJECT. START-Newsletter_Issue_4.pdf
EU START PROJECT. START-Newsletter_Issue_4.pdfEU START PROJECT. START-Newsletter_Issue_4.pdf
EU START PROJECT. START-Newsletter_Issue_4.pdfStart Project
 
RACEMIzATION AND ISOMERISATION completed.pptx
RACEMIzATION AND ISOMERISATION completed.pptxRACEMIzATION AND ISOMERISATION completed.pptx
RACEMIzATION AND ISOMERISATION completed.pptxArunLakshmiMeenakshi
 
Manganese‐RichSandstonesasanIndicatorofAncientOxic LakeWaterConditionsinGale...
Manganese‐RichSandstonesasanIndicatorofAncientOxic  LakeWaterConditionsinGale...Manganese‐RichSandstonesasanIndicatorofAncientOxic  LakeWaterConditionsinGale...
Manganese‐RichSandstonesasanIndicatorofAncientOxic LakeWaterConditionsinGale...Sérgio Sacani
 
GBSN - Microbiology (Unit 4) Concept of Asepsis
GBSN - Microbiology (Unit 4) Concept of AsepsisGBSN - Microbiology (Unit 4) Concept of Asepsis
GBSN - Microbiology (Unit 4) Concept of AsepsisAreesha Ahmad
 
PHOTOSYNTHETIC BACTERIA (OXYGENIC AND ANOXYGENIC)
PHOTOSYNTHETIC BACTERIA  (OXYGENIC AND ANOXYGENIC)PHOTOSYNTHETIC BACTERIA  (OXYGENIC AND ANOXYGENIC)
PHOTOSYNTHETIC BACTERIA (OXYGENIC AND ANOXYGENIC)kushbuR
 
TEST BANK for Organic Chemistry 6th Edition.pdf
TEST BANK for Organic Chemistry 6th Edition.pdfTEST BANK for Organic Chemistry 6th Edition.pdf
TEST BANK for Organic Chemistry 6th Edition.pdfmarcuskenyatta275
 
X-rays from a Central “Exhaust Vent” of the Galactic Center Chimney
X-rays from a Central “Exhaust Vent” of the Galactic Center ChimneyX-rays from a Central “Exhaust Vent” of the Galactic Center Chimney
X-rays from a Central “Exhaust Vent” of the Galactic Center ChimneySérgio Sacani
 
POST TRANSCRIPTIONAL GENE SILENCING-AN INTRODUCTION.pptx
POST TRANSCRIPTIONAL GENE SILENCING-AN INTRODUCTION.pptxPOST TRANSCRIPTIONAL GENE SILENCING-AN INTRODUCTION.pptx
POST TRANSCRIPTIONAL GENE SILENCING-AN INTRODUCTION.pptxArpitaMishra69
 
NuGOweek 2024 programme final FLYER short.pdf
NuGOweek 2024 programme final FLYER short.pdfNuGOweek 2024 programme final FLYER short.pdf
NuGOweek 2024 programme final FLYER short.pdfpablovgd
 

Recently uploaded (20)

Technical english Technical english.pptx
Technical english Technical english.pptxTechnical english Technical english.pptx
Technical english Technical english.pptx
 
Introduction and significance of Symbiotic algae
Introduction and significance of  Symbiotic algaeIntroduction and significance of  Symbiotic algae
Introduction and significance of Symbiotic algae
 
GBSN - Biochemistry (Unit 8) Enzymology
GBSN - Biochemistry (Unit 8) EnzymologyGBSN - Biochemistry (Unit 8) Enzymology
GBSN - Biochemistry (Unit 8) Enzymology
 
PARENTAL CARE IN FISHES.pptx for 5th sem
PARENTAL CARE IN FISHES.pptx for 5th semPARENTAL CARE IN FISHES.pptx for 5th sem
PARENTAL CARE IN FISHES.pptx for 5th sem
 
Molecular and Cellular Mechanism of Action of Hormones such as Growth Hormone...
Molecular and Cellular Mechanism of Action of Hormones such as Growth Hormone...Molecular and Cellular Mechanism of Action of Hormones such as Growth Hormone...
Molecular and Cellular Mechanism of Action of Hormones such as Growth Hormone...
 
Classification of Kerogen, Perspective on palynofacies in depositional envi...
Classification of Kerogen,  Perspective on palynofacies in depositional  envi...Classification of Kerogen,  Perspective on palynofacies in depositional  envi...
Classification of Kerogen, Perspective on palynofacies in depositional envi...
 
Warming the earth and the atmosphere.pptx
Warming the earth and the atmosphere.pptxWarming the earth and the atmosphere.pptx
Warming the earth and the atmosphere.pptx
 
GBSN - Biochemistry (Unit 3) Metabolism
GBSN - Biochemistry (Unit 3) MetabolismGBSN - Biochemistry (Unit 3) Metabolism
GBSN - Biochemistry (Unit 3) Metabolism
 
GBSN - Microbiology (Unit 5) Concept of isolation
GBSN - Microbiology (Unit 5) Concept of isolationGBSN - Microbiology (Unit 5) Concept of isolation
GBSN - Microbiology (Unit 5) Concept of isolation
 
ANATOMY OF DICOT AND MONOCOT LEAVES.pptx
ANATOMY OF DICOT AND MONOCOT LEAVES.pptxANATOMY OF DICOT AND MONOCOT LEAVES.pptx
ANATOMY OF DICOT AND MONOCOT LEAVES.pptx
 
EU START PROJECT. START-Newsletter_Issue_4.pdf
EU START PROJECT. START-Newsletter_Issue_4.pdfEU START PROJECT. START-Newsletter_Issue_4.pdf
EU START PROJECT. START-Newsletter_Issue_4.pdf
 
RACEMIzATION AND ISOMERISATION completed.pptx
RACEMIzATION AND ISOMERISATION completed.pptxRACEMIzATION AND ISOMERISATION completed.pptx
RACEMIzATION AND ISOMERISATION completed.pptx
 
HIV AND INFULENZA VIRUS PPT HIV PPT INFULENZA VIRUS PPT
HIV AND INFULENZA VIRUS PPT HIV PPT  INFULENZA VIRUS PPTHIV AND INFULENZA VIRUS PPT HIV PPT  INFULENZA VIRUS PPT
HIV AND INFULENZA VIRUS PPT HIV PPT INFULENZA VIRUS PPT
 
Manganese‐RichSandstonesasanIndicatorofAncientOxic LakeWaterConditionsinGale...
Manganese‐RichSandstonesasanIndicatorofAncientOxic  LakeWaterConditionsinGale...Manganese‐RichSandstonesasanIndicatorofAncientOxic  LakeWaterConditionsinGale...
Manganese‐RichSandstonesasanIndicatorofAncientOxic LakeWaterConditionsinGale...
 
GBSN - Microbiology (Unit 4) Concept of Asepsis
GBSN - Microbiology (Unit 4) Concept of AsepsisGBSN - Microbiology (Unit 4) Concept of Asepsis
GBSN - Microbiology (Unit 4) Concept of Asepsis
 
PHOTOSYNTHETIC BACTERIA (OXYGENIC AND ANOXYGENIC)
PHOTOSYNTHETIC BACTERIA  (OXYGENIC AND ANOXYGENIC)PHOTOSYNTHETIC BACTERIA  (OXYGENIC AND ANOXYGENIC)
PHOTOSYNTHETIC BACTERIA (OXYGENIC AND ANOXYGENIC)
 
TEST BANK for Organic Chemistry 6th Edition.pdf
TEST BANK for Organic Chemistry 6th Edition.pdfTEST BANK for Organic Chemistry 6th Edition.pdf
TEST BANK for Organic Chemistry 6th Edition.pdf
 
X-rays from a Central “Exhaust Vent” of the Galactic Center Chimney
X-rays from a Central “Exhaust Vent” of the Galactic Center ChimneyX-rays from a Central “Exhaust Vent” of the Galactic Center Chimney
X-rays from a Central “Exhaust Vent” of the Galactic Center Chimney
 
POST TRANSCRIPTIONAL GENE SILENCING-AN INTRODUCTION.pptx
POST TRANSCRIPTIONAL GENE SILENCING-AN INTRODUCTION.pptxPOST TRANSCRIPTIONAL GENE SILENCING-AN INTRODUCTION.pptx
POST TRANSCRIPTIONAL GENE SILENCING-AN INTRODUCTION.pptx
 
NuGOweek 2024 programme final FLYER short.pdf
NuGOweek 2024 programme final FLYER short.pdfNuGOweek 2024 programme final FLYER short.pdf
NuGOweek 2024 programme final FLYER short.pdf
 

GluonNLP MXNet Meetup-Aug

  • 1. Apache MXNet Seattle meetup - August GluonNLP: A Deep Learning Toolkit for NLP Practitioners Presenter: Chenguang Wang MXNet Science Team 1
  • 2. Apache MXNet Seattle meetup - August GluonNLP 2
  • 3. Apache MXNet Seattle meetup - August GluonNLP • A deep learning framework designed for fast data processing/ loading, and model building 3
  • 4. Apache MXNet Seattle meetup - August GluonNLP APIs gluonnlp.data Build efficient data pipelines for NLP tasks gluonnlp.model Train or load state-of-the-arts models for common NLP tasks gluonnlp.embedding Train or load state-of-the-arts embeddings for common NLP tasks 4
  • 5. Apache MXNet Seattle meetup - August GluonNLP Community Main contributors: Sheng Zha, Chenguang Wang, Aston Zhang, Mu Li, Shuai Zheng, Leonard Lausen, Xingjian Shi Code&docs: https://github.com/dmlc/gluon-nlp http://gluon-nlp.mxnet.io/ Forums: https://discuss.gluon.ai/ https://discuss.mxnet.io/ 5
  • 6. Apache MXNet Seattle meetup - August GluonNLP Cool Examples 6
  • 7. Apache MXNet Seattle meetup - August Data Bucketing How to generate the mini-batches? 7
  • 8. Apache MXNet Seattle meetup - August No Bucketing Average Padding = 11.7 8 Data loading slow and memory inefficient
  • 9. Apache MXNet Seattle meetup - August Sorted Bucketing Average Padding = 3.7 9 GluonNLP data bucketing fast and memory efficient
  • 10. Apache MXNet Seattle meetup - August Google Neural Machine Translation 10 Encoder: Bidireciontal LSTM + LSTM + Residual Decoder: LSTM + Residual + MLP Attention • Our implementation: • BLEU 26.22 on IWSLT2015, 10 epochs, Beam Size=10 • Tensorflow/nmt: • BLEU 26.10 on IWSLT2015, Beam Size=10 Wu, Yonghui, et al. "Google's neural machine translation system: Bridging the gap between human and machine translation." arXiv preprint arXiv:1609.08144 (2016).
  • 11. Apache MXNet Seattle meetup - August Transformer • Encoder • 6 layers of self-attention+ffn • Decoder • 6 layers of masked self-attention and • output of encoder + ffn 11 • Our implementation: • BLEU 26.81 on WMT2014en_de, 40 epochs • Tensorflow/t2t: • BLEU 26.55 on WMT2014en_de Vaswani, Ashish, et al. "Attention is all you need." Advances in Neural Information Processing Systems. 2017.
  • 12. Apache MXNet Seattle meetup - August GluonNLP Step-by-step -A language model example 12
  • 13. Apache MXNet Seattle meetup - August Language Model • Language model is trying to predict the next word based on the previous ones 13
  • 14. Apache MXNet Seattle meetup - August Steps to Write Language Model • 1. Collect a dataset <-most of the work • 2. Build the model <-a few lines of code • 3. Train <-a few lines of code • 4. Evaluate <-one line • 5. Inference <-one line 14 http://gluon-nlp.mxnet.io/examples/language_model/language_model.html
  • 15. Apache MXNet Seattle meetup - August Step #1: Collect a dataset import gluonnlp as nlp dataset_name = 'wikitext-2' train_dataset, val_dataset, test_dataset = [nlp.data.WikiText2(segment=segment, bos=None, eos='<eos>', skip_empty=False) for segment in ['train', 'val', 'test']] vocab = nlp.Vocab(nlp.data.Counter(train_dataset[0]), padding_token=None, bos_token=None) train_data, val_data, test_data = [x.bptt_batchify(vocab, bptt, batch_size, last_batch='discard') for x in [train_dataset, val_dataset, test_dataset]] 15
  • 16. Apache MXNet Seattle meetup - August Step #2: Build the model with self.name_scope(): self.embedding = self._get_embedding() self.encoder = self._get_encoder() self.decoder = self._get_decoder() 16self.embedding self.encoder self.decoder model = nlp.model.train.StandardRNN(args.model, len(vocab), args.emsize, args.nhid, args.nlayers, args.dropout, args.tied)
  • 17. Apache MXNet Seattle meetup - August Step #3: Train model.initialize(mx.init.Xavier(), ctx=context) trainer = gluon.Trainer(model.collect_params(), 'sgd', {'learning_rate': lr, 'momentum': 0, 'wd': 0}) loss = gluon.loss.SoftmaxCrossEntropyLoss() train(model, train_data, val_data, test_data, epochs, lr) 17
  • 18. Apache MXNet Seattle meetup - August Step #4: Evaluate test_L = evaluate(model, test_data, batch_size) 18
  • 19. Apache MXNet Seattle meetup - August Step #5: Inference model, _ = nlp.model.get_model('standard_lstm_lm_200', vocab=vocab) test_L = evaluate(model, test_data, batch_size) 19
  • 20. Apache MXNet Seattle meetup - August GluonNLP Embedding http://gluon-nlp.mxnet.io/api/embedding.html 20
  • 21. Apache MXNet Seattle meetup - August Embedding is Powerful! 21 Language Embedding Graph Embedding Image Embedding Word Embedding, Sentence Embedding, Paragraph embedding etc. Word2vec, Fasttext, Glove, etc Language model, machine translation, QA, Dialog System, etc. Network embedding, Subgraph embedding LINE, Deepwalk, CNN embedding CNN embedding Faster R-CNN, etc. Graph mining etc. Image classification, Image detection, SSD, etc Recommendation Information Retrieval Advertising, etc. Embedding … … …
  • 22. Apache MXNet Seattle meetup - August Word Embedding Map words or phrases from the vocabulary to vectors of real numbers. 22
  • 23. Apache MXNet Seattle meetup - August Word2vec • Skip-gram • Given a center word, predict surrounding words 23 “Tomas Mikolov, Kai Chen, Greg Corrado, and Jeffrey Dean. Efficient estimation of word representations in vector space. ICLR Workshop , 2013.”
  • 24. Apache MXNet Seattle meetup - August FastText • (Unknown) word: • the sum of char-n-gram. 24 Bojanowski, Piotr, et al. "Enriching word vectors with subword information." arXiv preprint arXiv:1607.04606 (2016).
  • 25. Apache MXNet Seattle meetup - August Embedding Evaluation • Similarity • See the example: http://gluon-nlp.mxnet.io/index.html • Analogy • See the example: http://gluon-nlp.mxnet.io/examples/ word_embedding/word_embedding.html 25
  • 26. Apache MXNet Seattle meetup - August • Dataset • Many public datasets. • Streaming for very large datasets. • Text data processing • Vocabulary • Tokenization • Bucketing • Modeling • Attention • Beam Search • Weight Drop • Embedding • Pretrained Embedding • Embedding Training GluonNLP Status • State-of-the-art models • Embedding, LM, MT, SA • Examples friendly to users that are new to the task • Reproducible training scripts 26 More is coming soon!
  • 27. Apache MXNet Seattle meetup - August Summary • In GluonNLP, we provide • High-level APIs • gluonnlp.data, gluonnlp.model, gluonnlp.embedding • Low-Level APIs • gluonnlp.data.batchify, gluonnlp.model.StandardRNN • Designed for practitioners: researchers and engineers 27
  • 28. Apache MXNet Seattle meetup - August Thanks && QA gluon-nlp.mxnet.io 28