0
0
Prompt Engineering / GenAIml~10 mins

Why embeddings capture semantic meaning in Prompt Engineering / GenAI - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create an embedding vector for a word using a simple lookup.

Prompt Engineering / GenAI
embedding_vector = embedding_matrix[[1]]
Drag options to blanks, or click blank then click option'
Aword
Bword_index
Cembedding_matrix
Dvector
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word string directly instead of its index.
2fill in blank
medium

Complete the code to calculate cosine similarity between two embedding vectors.

Prompt Engineering / GenAI
similarity = (vec1 @ vec2) / ([1](vec1) * np.linalg.norm(vec2))
Drag options to blanks, or click blank then click option'
Anp.linalg.norm
Bnp.dot
Cnp.sum
Dnp.mean
Attempts:
3 left
💡 Hint
Common Mistakes
Using dot product instead of norm in the denominator.
3fill in blank
hard

Fix the error in the code that normalizes an embedding vector.

Prompt Engineering / GenAI
normalized_vec = vec / np.linalg.[1](vec)
Drag options to blanks, or click blank then click option'
Adot
Bmean
Csum
Dnorm
Attempts:
3 left
💡 Hint
Common Mistakes
Using sum or mean instead of norm for normalization.
4fill in blank
hard

Fill both blanks to create a dictionary of word embeddings for words longer than 3 letters.

Prompt Engineering / GenAI
word_embeddings = {word: [1] for word in words if len(word) [2] 3}
Drag options to blanks, or click blank then click option'
Aembedding_matrix[word_index[word]]
Bembedding_matrix[word]
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word string directly as index.
Using wrong comparison operator.
5fill in blank
hard

Fill all three blanks to create a filtered dictionary of embeddings where the vector norm is greater than 0.5.

Prompt Engineering / GenAI
filtered_embeddings = { [1]: [2] for [3] in word_embeddings if np.linalg.norm(word_embeddings[[1]]) > 0.5 }
Drag options to blanks, or click blank then click option'
Aword
Bembedding
Dvector
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent variable names.
Using 'vector' instead of 'embedding'.