Neural Translation with Pytorch · 2017. 5. 29. · Data source Created by Chris Callison-Burch...

23
Neural Translation with Pytorch GTC 2017 JEREMY HOWARD @JEREMYPHOWARD

Transcript of Neural Translation with Pytorch · 2017. 5. 29. · Data source Created by Chris Callison-Burch...

Page 1: Neural Translation with Pytorch · 2017. 5. 29. · Data source Created by Chris Callison-Burch Crawled millions of web pages Used 'a set of simple heuristics’ •Transform French

Neural Translation with PytorchGTC 2017

JEREMY HOWARD

@JEREMYPHOWARD

Page 2: Neural Translation with Pytorch · 2017. 5. 29. · Data source Created by Chris Callison-Burch Crawled millions of web pages Used 'a set of simple heuristics’ •Transform French

I’m assuming some knowledge of…

Python Jupyter Numpy

Word vectors

RNNs

Some review today

Page 3: Neural Translation with Pytorch · 2017. 5. 29. · Data source Created by Chris Callison-Burch Crawled millions of web pages Used 'a set of simple heuristics’ •Transform French

course.fast.ai

Page 4: Neural Translation with Pytorch · 2017. 5. 29. · Data source Created by Chris Callison-Burch Crawled millions of web pages Used 'a set of simple heuristics’ •Transform French

https://github.com/jph00/part2

Page 5: Neural Translation with Pytorch · 2017. 5. 29. · Data source Created by Chris Callison-Burch Crawled millions of web pages Used 'a set of simple heuristics’ •Transform French

Our destination

https://github.com/jph00/part2

Page 6: Neural Translation with Pytorch · 2017. 5. 29. · Data source Created by Chris Callison-Burch Crawled millions of web pages Used 'a set of simple heuristics’ •Transform French

Data source

Created by Chris Callison-Burch

Crawled millions of web pages

Used 'a set of simple heuristics’

• Transform French URLs onto English URLs

• i.e. replacing "fr" with "en" and about 40 other hand-written rules

Assume that these documents are translations of each other

Page 7: Neural Translation with Pytorch · 2017. 5. 29. · Data source Created by Chris Callison-Burch Crawled millions of web pages Used 'a set of simple heuristics’ •Transform French

The dataset – just the questions

Page 8: Neural Translation with Pytorch · 2017. 5. 29. · Data source Created by Chris Callison-Burch Crawled millions of web pages Used 'a set of simple heuristics’ •Transform French

Tokenizing

Because we are translating at word level, we need to tokenize the text first. There are many tokenizers available, but we found we got best results using these simple heuristics.

Page 9: Neural Translation with Pytorch · 2017. 5. 29. · Data source Created by Chris Callison-Burch Crawled millions of web pages Used 'a set of simple heuristics’ •Transform French
Page 10: Neural Translation with Pytorch · 2017. 5. 29. · Data source Created by Chris Callison-Burch Crawled millions of web pages Used 'a set of simple heuristics’ •Transform French
Page 11: Neural Translation with Pytorch · 2017. 5. 29. · Data source Created by Chris Callison-Burch Crawled millions of web pages Used 'a set of simple heuristics’ •Transform French
Page 12: Neural Translation with Pytorch · 2017. 5. 29. · Data source Created by Chris Callison-Burch Crawled millions of web pages Used 'a set of simple heuristics’ •Transform French

Final preprocessing result

Page 13: Neural Translation with Pytorch · 2017. 5. 29. · Data source Created by Chris Callison-Burch Crawled millions of web pages Used 'a set of simple heuristics’ •Transform French
Page 14: Neural Translation with Pytorch · 2017. 5. 29. · Data source Created by Chris Callison-Burch Crawled millions of web pages Used 'a set of simple heuristics’ •Transform French
Page 15: Neural Translation with Pytorch · 2017. 5. 29. · Data source Created by Chris Callison-Burch Crawled millions of web pages Used 'a set of simple heuristics’ •Transform French

Unrolled stacked RNNs for sequences

word 1 input

word 2 input

word 3 input

Input

Hidden

Output

InputHidden

HiddenOutput

HiddenHidden

Page 16: Neural Translation with Pytorch · 2017. 5. 29. · Data source Created by Chris Callison-Burch Crawled millions of web pages Used 'a set of simple heuristics’ •Transform French

Equivalent recursive diagram

char n inputRepeat for 1n-1

Initialize to zeros

Repeat for 1n-1

Initialize to zeros

Page 17: Neural Translation with Pytorch · 2017. 5. 29. · Data source Created by Chris Callison-Burch Crawled millions of web pages Used 'a set of simple heuristics’ •Transform French

This and following 3 slides thanks to Chris Manning (Stanford)https://simons.berkeley.edu/talks/christopher-manning-2017-3-27

Page 18: Neural Translation with Pytorch · 2017. 5. 29. · Data source Created by Chris Callison-Burch Crawled millions of web pages Used 'a set of simple heuristics’ •Transform French
Page 19: Neural Translation with Pytorch · 2017. 5. 29. · Data source Created by Chris Callison-Burch Crawled millions of web pages Used 'a set of simple heuristics’ •Transform French
Page 20: Neural Translation with Pytorch · 2017. 5. 29. · Data source Created by Chris Callison-Burch Crawled millions of web pages Used 'a set of simple heuristics’ •Transform French
Page 21: Neural Translation with Pytorch · 2017. 5. 29. · Data source Created by Chris Callison-Burch Crawled millions of web pages Used 'a set of simple heuristics’ •Transform French

* Equation from: “Grammar as a Foreign Language”

Page 22: Neural Translation with Pytorch · 2017. 5. 29. · Data source Created by Chris Callison-Burch Crawled millions of web pages Used 'a set of simple heuristics’ •Transform French

Beam search

What is canada 's population ?

Quelle est la population du Canada ?

QueQuoi

leles

enpour

Page 23: Neural Translation with Pytorch · 2017. 5. 29. · Data source Created by Chris Callison-Burch Crawled millions of web pages Used 'a set of simple heuristics’ •Transform French

Neural Translation with PytorchGTC 2017

JEREMY HOWARD

@JEREMYPHOWARD