0
0
Prompt Engineering / GenAIml~20 mins

Text embedding models in Prompt Engineering / GenAI - Practice Problems & Coding Challenges

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

Text embedding models convert text into numbers. What is their main purpose?

ATo transform text into fixed-length vectors that capture semantic meaning
BTo translate text from one language to another
CTo generate new text based on a prompt
DTo count the number of words in a sentence
Attempts:
2 left
💡 Hint

Think about how computers understand text in a way that machines can work with.

Model Choice
intermediate
1:30remaining
Which model is best suited for generating text embeddings?

You want to create embeddings for sentences to compare their meanings. Which model type is best?

ATransformer-based model trained on large text corpora
BRecurrent Neural Network (RNN) trained on time series data
CConvolutional Neural Network (CNN) trained on images
DGenerative Adversarial Network (GAN) for image generation
Attempts:
2 left
💡 Hint

Consider models designed to understand language context deeply.

Predict Output
advanced
1:30remaining
What is the output shape of embeddings for 3 sentences using a model that outputs 768-dimensional vectors?

Given this Python code snippet:

sentences = ["Hello world", "Machine learning is fun", "AI helps humans"]
embeddings = model.encode(sentences)
print(embeddings.shape)

What will be printed?

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

Each sentence gets a vector of length 768. How many sentences are there?

Metrics
advanced
1:15remaining
Which metric is best to measure similarity between two text embeddings?

You have two text embeddings and want to measure how similar their meanings are. Which metric is most appropriate?

AEuclidean distance
BAccuracy
CMean squared error
DCosine similarity
Attempts:
2 left
💡 Hint

Think about a metric that measures the angle between two vectors rather than their length.

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

Consider this code snippet:

text = "AI is amazing"
embedding = model.encode(text)
print(embedding.shape)

It raises: TypeError: 'float' object has no attribute 'shape'. Why?

AThe variable 'text' is not defined
BThe model.encode returns a float instead of a vector
CThe model.encode expects a list of strings, not a single string
DThe print statement is missing parentheses
Attempts:
2 left
💡 Hint

Check the input type expected by the encode method.