GenAI Basics · Question 27 · Hard

GenAI Basics question 27

A query embedding is q = (1, 2, 2). Four document embeddings are:
D1 = (2, 1, -2)
D2 = (1, 1, 1)
D3 = (4, 0, 4)
D4 = (0.5, 1, 1)
Which document is most similar to q by cosine similarity?

  1. D3
  2. D4
  3. D2
  4. D1
Answer and explanation

Answer: B. D4

Explanation: D4 = 0.5 × q points in exactly the same direction, so its cosine similarity is 1. D3 has the largest dot product (12) but its cosine is only 12 / (3 × 5.66) ≈ 0.71; D2 ≈ 0.96 and D1 = 0. Cosine similarity ignores vector length.

Previous: In a RAG system, what is the main purpose of a vector database? · Next: A model's two candidate next tokens have logits 2 and 0. With softmax at…

Practise genai basics

Try a fresh set of genai basics questions with an explanation after every answer, free and without signing up: GenAI Basics practice. Or sit a full placement mock test.

More genai basics questions

More technical & programming practice

Pseudo-code · C Programming · Java · Python · Data Structures · Algorithms · Object-Oriented Programming · DBMS

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge