บทนำสู่การแปลภาษาด้วยเครื่อง

Machine Translation ด้วย Keras

Thushan Ganegedara

Data Scientist and Author

การแปลภาษาด้วยเครื่อง

การแปลคำว่า Hello

Machine Translation ด้วย Keras

การแปลภาษาด้วยเครื่อง

การแปลคำว่า Hello พร้อมไอคอน Google

Machine Translation ด้วย Keras

โครงร่างคอร์ส

  • บทที่ 1 - บทนำสู่การแปลภาษาด้วยเครื่อง
  • บทที่ 2 - สร้างโมเดลแปลภาษา (สถาปัตยกรรม encoder-decoder)
  • บทที่ 3 - ฝึกโมเดลและสร้างคำแปล
  • บทที่ 4 - ปรับปรุงโมเดลแปลภาษา
Machine Translation ด้วย Keras

ชุดข้อมูล (คอร์ปัสประโยคภาษาอังกฤษ-ฝรั่งเศส)

  • คอร์ปัสภาษาอังกฤษ
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 .
  • คอร์ปัสภาษาฝรั่งเศส
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 ด้วย Keras

การแปลภาษาด้วยเครื่อง - ภาพรวม

อังกฤษเป็นฝรั่งเศส

Machine Translation ด้วย Keras

การแปลภาษาด้วยเครื่อง - ภาพรวม

คำศัพท์ภาษาต้นทางและปลายทาง

Machine Translation ด้วย Keras

การแปลภาษาด้วยเครื่อง - ภาพรวม

โมเดลแปลภาษาด้วยเครื่อง

Machine Translation ด้วย Keras

การแปลภาษาด้วยเครื่อง - ภาพรวม

โมเดลแปลภาษาด้วยเครื่อง

Machine Translation ด้วย Keras

เวกเตอร์แบบ one-hot encoding

  • เวกเตอร์ที่ประกอบด้วย 0 และ 1
  • ความยาวของเวกเตอร์ขึ้นอยู่กับขนาดของ vocabulary
  • Vocabulary คือกลุ่มของคำที่ไม่ซ้ำกันในชุดข้อมูล

เวกเตอร์แบบ one-hot

Machine Translation ด้วย Keras

เวกเตอร์แบบ one-hot encoding

การแมปคำกับดัชนีที่ตรงกัน

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

การแปลงคำเป็น ID หรือดัชนี

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

เวกเตอร์แบบ one-hot encoding

One-hot encoding โดยไม่ระบุ ความยาวเวกเตอร์

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 encoding โดยระบุ ความยาวเวกเตอร์

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 ด้วย Keras

มาฝึกกันเถอะ!

Machine Translation ด้วย Keras

Preparing Video For Download...