0% found this document useful (0 votes)
22 views2 pages

NLU Assignment: Neural Machine Translation

This document outlines an assignment to experiment with neural machine translation using different attention mechanisms. The tasks include: 1. Preparing a dataset for translation between the student's native language and English, with proper attribution. 2. Implementing and comparing the performance of general attention, multiplicative attention, and additive attention mechanisms. 3. Evaluating the models with performance metrics and visualizations, including attention maps. 4. Developing a web application to demonstrate the best model for translation between the student's native language and English.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

NLU Assignment: Neural Machine Translation

This document outlines an assignment to experiment with neural machine translation using different attention mechanisms. The tasks include: 1. Preparing a dataset for translation between the student's native language and English, with proper attribution. 2. Implementing and comparing the performance of general attention, multiplicative attention, and additive attention mechanisms. 3. Evaluating the models with performance metrics and visualizations, including attention maps. 4. Developing a web application to demonstrate the best model for translation between the student's native language and English.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Chaklam Silpasuwanchai, Todsavad Tangtortan

AT82.05 Artificial Intelligence: Natural Language Understanding (NLU)


A3: Translate your own language

In this assignment, we will explore the domain of neural machine translation. The focus will be on
translating between your native language and English. We will experiment with different types of attention
mechanisms, including general attention, multiplicative attention, and additive attention, to evaluate their
effectiveness in the translation process.
Note: You are ENCOURAGED to work with your friends, but DISCOURAGED to blindly copy other’s
work. Both parties will be given 0.
Note: Comments should be provided sufficiently so we know you understand. Failure to do so can raise
suspicion of possible copying/plagiarism.
Note: You will be graded upon (1) documentation, (2) experiment, (3) implementation.
Note: This is a one-weeks assignment, but start early.
Deliverables: The GitHub link containing the jupyter notebook, a [Link] of the github, and
the folder of your web application called ‘app’.

Task 1. Get Language Pair - Based on MT + [Link], modify the dataset as follows:
1) Find a dataset suitable for translation between your native language and English. Ensure to source
this dataset from reputable public databases or repositories. It is imperative to give proper credit
to the dataset source in your documentation. (1 points)
2) Describe in detail the process of preparing the dataset for use in your translation model. This
includes steps like text normalization, tokenization, and word segmentation, particularly focusing
on your native language’s specific requirements. Specify the libraries or tools you will use for these
tasks and give appropriate credit to the developers or organizations behind these tools. If your
native language requires special handling in tokenization (e.g., for languages like Chinese, Thai, or
Japanese), mention the libraries (like Jieba, PyThaiNLP, or Mecab) and the procedures used for
word segmentation. (1 points)
Note: proper attribution for both the dataset and the tools used in its processing is essential for main-
taining academic integrity.

Task 2. Experiment with Attention Mechanisms - Implement a sequence-to-sequence neural network


for the translation task. Your implementation should include the following attention mechanisms, with
their respective equations:
1) General Attention: (0.5 points)

ei = sT hi ∈ R where d1 = d2

2) Multiplicative Attention: (0.5 points)

ei = sT W hi ∈ R where W ∈ Rd2 ×d1

3) Additive Attention: (0.5 points)

ei = v t tanh(W1 hi + W2 s) ∈ R

Note: For an in-depth exploration of attention mechanisms, you can refer to this paper1.

1An Attentive Survey of Attention Models [Link]


1
2

Attentions Training Loss Traning PPL Validation Loss Validation PPL


General Attention
Multiplicative Attention
Additive Attention

Task 3. Evaluation and Verification - For the final evaluation and verification, perform the following:
1) Compare the performance of these attention mechanisms in terms of translation accuracy, compu-
tational efficiency, and other relevant metrics. (1 points)
2) Provide performance plots showing training and validation loss for each type of attention mechanism
(General, Multiplicative, and Additive). These plots will help in visualizing and comparing the
learning curves of different attention models. (0.5 points)
3) Display the attention maps generated by your model. Attention maps are crucial for understanding
how the model focuses on different parts of the input sequence while generating the translation.
This visualization will offer insights into the interpretability of your model. (1 points)
4) Analyze the results and discuss the effectiveness of the selected attention mechanism in translating
between your native language and English. (1 points)
Note: Provide the performance table and graph to [Link] GitHub as well.
Task 4. Machine Translation - Web Application Development - Develop a simple web application
that showcases the capabilities of your language model in machine translation. (3 points)
1) The application should feature an input box where users can enter a sentence or phrase in a source
language.
2) Based on the input, the model should generate and display the translated version in a target lan-
guage. For example, if the input is ”Hello, how are you?” in English, the model might generate
”Hola, ¿cómo estás?” in Spanish.
3) Provide documentation on how the web application interfaces with the language model for machine
translation.
Note : Choose the most effective attention mechanism based on your experiments in Task 2.
As always, the example Dash Project in the GitHub repository contains an example that you can follow
(if you use the Dash framework).
Best of luck in developing your machine translation!

Common questions

Powered by AI

Preparation involves ensuring the dataset is sourced from reputable public databases, includes text normalization, and processes text through tokenization tailored to language specifics. For languages like Thai, Japanese, or Chinese, specialized libraries such as PyThaiNLP, Mecab, or Jieba facilitate word segmentation. This step is crucial because these languages do not use spaces between words, thus necessitating tools that effectively tokenize text by recognizing word boundaries .

Attention mechanisms enhance interpretability by allowing the model to focus on relevant input sections, providing a transparent process where model decision paths can be understood through attention weights. These weights, visualized as attention maps, indicate which source sentences influence the target translation at each step, offering insights into linguistic transformations and contextual prioritization during translation .

Crucial metrics include training and validation loss across epochs to analyze convergence speed and overfitting potentials. Attention mechanisms' impact on translation quality and computational demands should also be evaluated, contextualized within the plots of loss and potential perplexity (PPL) metrics. These metrics collectively offer insights into each mechanism's learning efficiency and effectiveness in translation tasks .

User interaction should focus on intuitive design, featuring a simple input box for enter sentences, real-time translation feedback, and an interface that showcases the reliability and speed of translations. Detailed documentation on how the frontend interfaces with the model backend adds transparency, enhancing user trust and ease of use. The application should also highlight the chosen attention mechanism, demonstrating its impact on translation quality .

Strategies could include experimenting with different tokenization algorithms provided by tools like Mecab for Japanese or Jieba for Chinese to optimize segmentation accuracy. Comparative analyses on translation accuracy across datasets using varied tokenization settings can reveal optimal library configurations. Additionally, fine-tuning models on custom tokenized datasets adjusted for dialect or regional variations ensures improved translation outputs .

Essential documentation should include detailed accounts of dataset sources, preprocessing steps, tool libraries used for tokenization, and their attribution. Clearly documenting these ensures appropriate recognition of contributors and resources, preventing plagiarism. It's crucial to describe each experimental step and provide GitHub links with all code and instructions for verification and reproducibility .

Evaluation should consider translation accuracy, computational efficiency, training and validation loss, and learning curves from performance plots to ascertain the model's learning progression. Additionally, attention maps play a crucial role in understanding model interpretability and focus areas during translation. The chosen attention mechanism should show clear advantages in these metrics to be deemed effective .

Attention maps are significant because they visually depict how the model allocates focus on different parts of the input sequence while translating. This insight into the translation process aids in evaluating model interpretability and pinpointing potential inefficiencies or biases in word alignment and contextual understanding. It enhances model transparency and helps refine the model's internal weighting mechanisms for better translation outputs .

The computational efficiency is pivotal as it affects model training time and resource use. General attention is computationally simplest due to its basic dot product. Multiplicative attention, with its learned weight matrices, offers a trade-off between flexibility and computational load, suitable for models where capturing varying dimensions is critical. Additive attention is computationally intensive due to additional parameters and non-linear transformations, potentially making it less viable for large-scale datasets unless the translation quality benefits significantly outweigh efficiency costs .

General attention is applied using a dot product between the encoder's hidden state and the decoder's state, assuming equal dimensions. Multiplicative attention adds a learned weight matrix, making the computation more flexible by mapping dimensions between encoder and decoder states. Additive attention uses a learned parameter vector to compute the alignment and involves additional computations, like applying a tanh non-linearity, which may better capture complex relationships .

You might also like