1. Application of NLG
in eCommerce
By Fatemeh Kazemi
Presented at TensorFlow User Group Toronto
Women in AI – 20 Mar 2019
1
2. Agenda
• What is NLG
• Types of NLG
• Template-Based NLG system
• Advance NLG system
• Sequence to Sequence model
• Encoder-Decoder architecture
• Application of Seq2Seq Model
• NLG in eCommerce
• ginnie.ai
• Model Architecture
• Results
• Challenges
• Solutions 2
3. What is NLG?
• NLG is characterized as the subfield of artificial
intelligence and computational linguistics that is
concerned with the construction of computer systems
than can produce understandable texts in English or other
human languages
• Template-based NLG
• Advanced NLG
3
4. NLG Type - Template-Based
• It uses templates with canned text and placeholders to
insert data into them
For example the systems that generate form letters
stating that a credit card spending limit is reached
• Advantages
Allow for full control over the quality of the output
Avoid the generation of ungrammatical structures
• Disadvantages:
Rely on hard-coded rules
Can not be easily reused across different projects
4
5. NLG Type - Advanced
• Advanced NLG systems automatically understand user
intent and generate content. They are intelligent
• Being very flexible thanks to the use of supervised and
unsupervised Machine Learning algorithms
• Using neural networks that learn morphological, lexical,
and grammar patterns from large corpora of written
language
• Allowing correcting language errors, such as misspellings
5
6. Seq2Seq Model
• The State-of-the-art NLG systems are built on deep neural
sequence to sequence models with an encoder-decoder
architecture
• Seq2seq models provide a framework to process
information that is in the form of sequences and both the
input and output are in the form of sequences of single
units like sequence of words, images, or speech units
• Convert sequences from one domain to sequences in
another domain
6
7. Encoder-Decoder Architecture
• Both the Encoder and Decoder are practically
two different neural network models
• The encoder is an RNN that reads each
symbol of an input sequence x sequentially
and as it reads each symbol, the hidden state
of the RNN changes
• After reading the end of the sequence
completely the hidden state of the RNN is a
summary of the whole input sequence
• Decoder is an RNN which is trained to
generate the output sequence by using the
hidden state of encoder 7
8. Applications of Seq2Seq Model
• Machine translation such as Google Translation
• Question answering application such as Siri
• Text summarization
• Speech Recognition
• Image captioning
• Video captioning
8
9. What Does NLG Mean For eCommerce?
• In a competitive environment where brands compete for wallet
share, the ability to create and present consistent content can be
a make-or-break
• A good description increases the likelihood of purchase
• It also helps your product gain visibility
• Usually product descriptions are written by writers or using
Template-based NLG tools
• By using Advanced NLG tools, businesses are able to generate
thousands of unique product descriptions in a matter of minutes
which are more cost effective than manual writing
• The advanced methods automatically transform raw product
specifications into engaging, unique, optimized content 9
12. ginnie.ai Example
NLG is characterized as ‘the subfield of artificial
intelligence and Inputs:
• Sleeve type: Long-Sleeve
• Pattern: Polka Dot
• Collar type: Classic Shirt
• Color: Black
• Material: Cotton
Output:
Complete your look with style this season in one of
these fun and fashionable tops for women. Opt for a
flattering and neutral black shade that is easy to
accessorize. A polka dot pattern adds whimsy and style
to this garment for a fun choice you'll enjoy wearing.
With a crisp, clean look, this classic shirt collar is a
staple in any woman's wardrobe. Keep arms protected
from the sun with these practical and comfortable long
sleeves. Cotton provides lasting comfort and retains its 12
15. ginnie Architecture Abstraction
• LSTM Encoder-Decoder is used for automatic description
generation
• LSTMs are a special kind of RNN, capable of learning long-term
dependencies
• We need 2 multilayered LSTM, one as encoder and another as
decoder
• The encoder processes the input sequence and returns its own
internal state
• The decoder is trained to turn the target sequences into the same
sequences but offset by one timestep in the future, this training
process called "teacher forcing"
• The decoder uses as initial state the state vectors from the
encoder, which is how the decoder obtains information about 15
16. Using Seq2Seq Model in ginnie
LSTM
Encoder
LSTM
Decoder
“Apparel Women Shirts Color Black”
“[START] Breathable and durable cotton materials allow for lightweight all-day comfort”
“Available in a dark, cool black for lots of attitude[STOP]”
“Apparel Women Shirts Material Cotton”
“Apparel Women Shirts Collar Classic”
“Apparel Women Shirts Sleeve Long-Sleeve” “[START] Get ready for the office in the fashionable long sleeves of this design”
“[START] Available in a dark, cool black for lots of attitude”
“[START] Designed with a classic shirt collar for a timeless look that is always in style”
“Breathable and durable cotton materials allow for lightweight all-day comfort[STOP]”
“Designed with a classic shirt collar for a timeless look that is always in style[STOP]”
“Get ready for the office in the fashionable long sleeves of this design[STOP]”
Internal LSTM
states(h,c)
16
17. ginnie Results
• We have obtained 80 to 90 percent accuracy across various
product categories
• We have achieved a reduction of 85 percent in time and
cost, resulting in us being able to produce high quality and
budget-friendly solutions for our customers
17
18. Challenges
• Lack of training data
Solutions
• Translating the sentences from one language to another
language
• Using Synonyms
18
19. References
1. C. Xiong, V. Zhong, and R. Socher, “Dynamic coattention networks for question answering,” in ICLR, 2016.
2. Cho, Kyunghyun, van Merrienboer, Bart, Gulcehre, Caglar, Bougares, Fethi, Schwenk, Holger, and Bengio, Yoshua.
Learning phrase representations using RNN encoder-decoder for statistical machine translation. In EMNLP, October
2014.
3. D. Bahdanau, J. Chorowski, D. Serdyuk, P. Brakel, and Y. Bengio, “End-to-end attention-based large vocabulary
speech recognition,” in IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP). IEEE,
2016, pp. 4945–4949.
4. Ilya Sutskever, Oriol Vinyals, and Quoc V. Le. 2014. Sequence to sequence learning with neural networks. In NIPS.
5. J. Ba, V. Mnih, and K. Kavukcuoglu, “Multiple object recognition with visual attention,” arXiv preprint
arXiv:1412.7755, 2014.
6. K. Xu, J. Ba, R. Kiros, K. Cho, A. Courville, R. Salakhudinov, R. Zemel, and Y. Bengio, “Show, attend and tell: Neural
image caption generation with visual attention,” in International Conference on Machine Learning, 2015, pp. 2048–
2057.
7. Kyunghyun Cho, Bart van Merrienboer, C¸ aglar ¨ Gulc¸ehre, Dzmitry Bahdanau, Fethi Bougares, Hol- ¨ ger Schwenk,
and Yoshua Bengio. 2014. Learning phrase representations using rnn encoder-decoder for statistical machine
translation. In EMNLP.
8. R. Nallapati, B. Zhou, C. dos Santos, C. Gulcehre, and B. Xiang, “Abstractive text summarization using sequence-to-
sequence rnns and beyond,” in Proceedings of The 20th SIGNLL Conference on Computational Natural Language
Learning, 2016, pp. 280–290.
9. T. Luong, H. Pham, and C. D. Manning, “Effective approaches to attention-based neural machine translation,” in
Proceedings of the Conference on Empirical Methods in Natural Language Processing, 2015, pp. 1412–1421. 19