จาก ep ที่แล้ว Neural Machine Translation แปลภาษาฝรั่งเศส เป็นภาษาอังกฤษ ด้วย Sequence to Sequence RNN Model ใน ep นี้ เราจะมาเรียนรู้ Neural Machine Translation กันต่อ แต่จะใช้เทคนิคที่เรียกว่า Attention Mechanism มาเพิ่มประสิทธิภาพของโมเดล


Attention Mechanism คืออะไร

This shows which parts of the input sentence has the model's attention while translating. Credit https://www.tensorflow.org/tutorials/text/nmt_with_attention
This shows which parts of the input sentence has the model’s attention while translating. Credit https://www.tensorflow.org/tutorials/text/nmt_with_attention

ในการแปลภาษา ยกตัวอย่างเช่น การแปลประโยคภาษาฝรั่งเศส ไปเป็นภาษาอังกฤษ ขณะที่เราเขียนคำแปลแต่ละคำออกมา เราจะโฟกัสเฉพาะคำบางคำ สนใจเฉพาะข้อความบางส่วนในต้นฉบับเท่านั้น และหลาย ๆ ครั้งในขณะที่แปลคำต่อไป เราก็จะสอดส่ายสายตา ย้อนไปมองหาคำที่เกี่ยวข้องในข้อความต้นฉบับ มองไปแปลไป ทีละส่วน ๆ

เราสามารถออกแบบโมเดล Neural Machine Translation ให้มีความสามารถนี้ ด้วย Attention Mechanism โมเดลจะโฟกัสเฉพาะบางส่วนของ Input เท่านั้น ณ เวลาหนึ่ง ส่วนจะโฟกัสที่ไหนเป็น Parameter ที่เราจะเทรนให้โมเดลเรียนรู้ได้ด้วยตัวเอง ด้วย Machine Learning

Scaled Dot-Product Attention. Credit https://arxiv.org/abs/1706.03762
Scaled Dot-Product Attention. Credit https://arxiv.org/abs/1706.03762

โมเดลจะเรียนรู้จากข้อมูลว่าควรโฟกัสตรงไหน ณ เวลา Step ไหน จะได้ประสิทธิภาพสูงสุด

เรามาเริ่มกันเลยดีกว่า

Open In Colab

แชร์ให้เพื่อน:

Surapong Kanoktipsatharporn on FacebookSurapong Kanoktipsatharporn on LinkedinSurapong Kanoktipsatharporn on Rss
Surapong Kanoktipsatharporn
Solutions Architect at Bua Labs
The ultimate test of your knowledge is your capacity to convey it to another.

Published by Surapong Kanoktipsatharporn

The ultimate test of your knowledge is your capacity to convey it to another.