Operation on word vectors : How can they generate a word?

Hi, I am doing the first assignment for Week2 in Sequence models(DLS course 5)

In this assignment, there is “Exercise2- complete_analogy” part.
I do not have any problem with coding assignment but I am so curious how
“complete analogy” function can predict the words from given inputs.

For instance, with this input:
[(‘italy’, ‘italian’, ‘spain’), (‘india’, ‘delhi’, ‘japan’), (‘man’, ‘woman’, ‘boy’), (‘small’, ‘smaller’, ‘large’)]

output is as follows:

italy → italian :: spain → spanish
india → delhi :: japan → tokyo
man → woman :: boy → girl
small → smaller :: large → smaller

but I do not see those predicted words in wordlist. How did they generate that word such as spanish or tokyo although it is not in a training set? Or idk if I did not understand the code.

Hi @Hamin-Yoon ,

Please refer to Fig.1 and the complete_analogy() function for details of mechanism behind how it works.