Checklist HAIO 2024 Summer National Final · NLP-3 task
Machine Translation
English title: Gépi Fordítás
Prepare a French–English sentence-pair corpus and complete a GRU encoder–decoder with given weights to translate French sentences into English.
The task
Intelligent John collected French expressions during a tour of France and needs a computer translator. The contestant prepares a sentence-pair corpus and completes a GRU-based encoder–decoder whose decoder architecture and trained weights are provided.
Task 1 (10 points): print the first 10 sentence pairs (2); implement a Lang class with name, word2index, word2count, index2word (pre-filled with SOS, EOS and PAD) and n_words starting from 3, with add_sentence and add_word (4); implement read_langs(lang1, lang2, reverse) using the given normalisation helpers (4). Task 2 (15 points, 3 each): create reversed French–English Lang objects; keep only pairs whose English side starts with one of the given eng_prefixes ("i am", "he is", "you are", ...); drop sentences longer than MAX_LENGTH = 10 words; update the vocabularies; implement prepare_data. Task 3 (6 points): compute what percentage of words makes up 80% of each corpus (3) and bar-plot the 100 most frequent English and French words (3).
Task 4 (12 points): implement the encoder from the figure (4); instantiate both models and load encoder.pth and decoder.pth (1); convert the pairs to index tensors — left-padded input with SOS/EOS, right-padded decoder input starting with SOS, and a target shifted one position left and padded to MAX_LENGTH (7). Task 5 (7 points): generate tokens with the given predict function (1) and translate the first 10 French sentences greedily, stopping at EOS (6).
Abridged by SOTA from the official materials. The official statement has the exact rules, and it wins wherever this summary differs.
At a glance
- You get
- A French–English sentence-pair text file (from
nyelvek.zip) and the weightsencoder.pthanddecoder.pth, all downloaded with gdown. - You submit
- The completed notebook with the translations of the first 10 French sentences.
- Scoring
- 50 points in total (10 + 15 + 6 + 12 + 7); graded by the organisers.
- Rules
- Keras and TensorFlow are not allowed; any PyTorch-based tool may be used.
- MAX_LENGTH = 10 words.
- Format
- Summer National Final (Nyári Országos Döntő), held on site at the ELTE Faculty of Informatics, Budapest, on 30 May 2024. Solved in Google Colab; the completed notebook is downloaded as .ipynb and uploaded, zipped together with the other solutions, to the CMS.