Programming Assignment 5 Hands On - Advanced Deep Learning
Programming Assignment 5 Hands On - Advanced Deep Learning
2. Write your code only in the designated places in the skeleton code, and process
the input data provided to you in the designated variables. Do not alter the input
output structure in the skeleton code.
3. Do not import any additional libraries. Do not use any additional files for the
processing other than those mentioned in the skeleton code. Failure to comply with
these instructions may lead to you getting zero marks for the assignment, even if
the solution is largely correct.
Question:
Objective: The objective of this assignment is to investigate the performance of
two different types of sentence-level representations as well as understand the
type of information encoded in these representations as produced by the bert-base-
uncased model.
There are usually two ways of aggregating sentence-level representation from the
bert model.
I. Using the CLS token
II. Applying some transformation on the hidden state output of the model One such
transformation is the application of max pooling.
In this assignment, you will be given a set of two sentences that will be taken as
input from
the system arguments with the sentences being separated " , ". You will have to use
the pre-trained bert-base-uncased model to generate two different representations
(as described above) for each sentence. You will then apply cosine similarity
between the respective representations of each sentence and report the two values
rounded off to the 2nd decimal.
The output of the assignment can be represented as,
Where f(-) is the bert-base-uncased model, S1 and S2 are the two sentences, y1 and
y2 are
Bonus: The input cases have been provided such that the sentence similarities range
from paraphrase to contradiction. Looking at the scores, try to understand which
type of vector representation works best. Also, based on the last test case, do you
think that the bert-base� uncase model is able to understand semantic information?
"input": "The restaurant offers a variety of vegan dishes , There are many plant�
based options on the menu at the cafe\n",
"output": "0.64 0.74"
"input": "The new iPhone has an improved camera , Android phones are known for
their customizability\n",
"output": "0.64 0.91"
"input": "She loves painting landscapes during the summer , Quantum computing is
expected to revolutionize technology",
"output": "0.57 0.9"
"input": "The fox jumped over the well , The fox did not jump over the well",
"output": "0.86 0.96"