0
0
Prompt Engineering / GenAIml~20 mins

Embedding generation in Prompt Engineering / GenAI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Embedding Expert
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
What is the main purpose of embedding generation in machine learning?

Embedding generation transforms raw data into a format that machine learning models can understand better. What is the main goal of this process?

ATo increase the size of the dataset by duplicating samples
BTo convert data into fixed-size vectors capturing semantic meaning
CTo remove all noise from the data by filtering
DTo convert numerical data into categorical labels
Attempts:
2 left
💡 Hint

Think about how words or images are represented so models can work with them.

Predict Output
intermediate
1:30remaining
What is the output shape of the embedding vector?

Given the following code snippet generating embeddings for 3 sentences using a model that outputs 768-dimensional vectors, what is the shape of the resulting embedding array?

Prompt Engineering / GenAI
sentences = ['Hello world', 'Machine learning is fun', 'AI helps humans']
embeddings = model.encode(sentences)
print(embeddings.shape)
A(768,)
B(768, 3)
C(3, 3)
D(3, 768)
Attempts:
2 left
💡 Hint

Each sentence gets its own vector of length 768.

Model Choice
advanced
2:00remaining
Which model type is best suited for generating contextual word embeddings?

You want to generate embeddings that capture the meaning of words depending on their sentence context. Which model type should you choose?

ATransformer-based model like BERT
BRecurrent Neural Network (RNN) without attention
CSimple Bag-of-Words model
DK-Nearest Neighbors (KNN) classifier
Attempts:
2 left
💡 Hint

Think about models that understand word order and context deeply.

Metrics
advanced
1:30remaining
Which metric is most appropriate to evaluate similarity between two embedding vectors?

You have two embedding vectors representing sentences. Which metric best measures how similar their meanings are?

AMean squared error
BEuclidean distance
CCosine similarity
DAccuracy
Attempts:
2 left
💡 Hint

Consider a metric that measures the angle between vectors rather than their length.

🔧 Debug
expert
2:00remaining
Why does this embedding generation code raise a TypeError?

Examine the code below that attempts to generate embeddings for a list of texts. Why does it raise a TypeError?

Prompt Engineering / GenAI
texts = ['data science', 'deep learning']
embeddings = model.encode(texts[0], texts[1])
AThe encode method expects a single list argument, not multiple string arguments
BThe model variable is not defined
CThe encode method requires integer inputs, not strings
DThe texts list is empty
Attempts:
2 left
💡 Hint

Check how the encode method is called and what arguments it expects.