Úvod do strojového překladu

Machine Translation with Keras

Thushan Ganegedara

Data Scientist and Author

Strojový překlad

Překlady slova Hello

Machine Translation with Keras

Strojový překlad

Překlad slova Hello s ikonou Google

Machine Translation with Keras

Osnova kurzu

  • Kapitola 1 – Úvod do strojového překladu
  • Kapitola 2 – Implementace modelu strojového překladu (architektura enkodér–dekodér)
  • Kapitola 3 – Trénování modelu a generování překladů
  • Kapitola 4 – Vylepšení modelu překladu
Machine Translation with Keras

Datová sada (korpus anglicko-francouzských vět)

  • Anglický korpus
new jersey is sometimes quiet during autumn , and it is snowy in april .
the united states is usually chilly during july , and it is usually freezing ...
california is usually quiet during march , and it is usually hot in june .
  • Francouzský korpus
new jersey est parfois calme pendant l' automne , et il est neigeux en avril .
les états-unis est généralement froid en juillet , et il gèle habituellement ...
california est généralement calme en mars , et il est généralement chaud en juin .
1 https://github.com/udacity/deep-learning/tree/master/language-translation/data
Machine Translation with Keras

Strojový překlad – přehled

Překlad z angličtiny do francouzštiny

Machine Translation with Keras

Strojový překlad – přehled

Pojmy zdrojový a cílový jazyk

Machine Translation with Keras

Strojový překlad – přehled

Model strojového překladu

Machine Translation with Keras

Strojový překlad – přehled

Model strojového překladu

Machine Translation with Keras

Vektory s one-hot kódováním

  • Vektor jedniček a nul
  • Délka vektoru závisí na velikosti slovníku
  • Slovník – kolekce jedinečných slov v datové sadě

Vektory one-hot

Machine Translation with Keras

Vektory s one-hot kódováním

Mapování slov na jejich indexy

word2index = {"I":0, "like": 1, "cats": 2}

Převod slov na ID nebo indexy

words = ["I", "like", "cats"]
word_ids = [word2index[w] for w in words]
print(word_ids)
[0, 1, 2]
Machine Translation with Keras

Vektory s one-hot kódováním

One-hot kódování bez zadání délky výstupního vektoru

onehot_1 = to_categorical(word_ids)
print([(w,ohe.tolist()) for w,ohe in zip(words, onehot_1)])
[('I', [1.0, 0.0, 0.0]), ('like', [0.0, 1.0, 0.0]), ('cats', [0.0, 0.0, 1.0])]

One-hot kódování se zadáním délky výstupního vektoru

onehot_2 = to_categorical(word_ids, num_classes=5)
print([(w,ohe.tolist()) for w,ohe in zip(words, onehot_2)])
[('I', [1.0, 0.0, 0.0, 0.0, 0.0]), ('like', [0.0, 1.0, 0.0, 0.0, 0.0]), 
('cats', [0.0, 0.0, 1.0, 0.0, 0.0])]
Machine Translation with Keras

Pojďme si procvičit!

Machine Translation with Keras

Preparing Video For Download...