medium10 pts · first answer countspythonembeddings
Cosine of a scaled vector
What does this NumPy code print?
import numpy as np a = np.array([1.0, 2.0, 2.0]) b = np.array([2.0, 4.0, 4.0]) sim = a @ b / (np.linalg.norm(a) * np.linalg.norm(b)) print(round(float(sim), 2))
Discussion 0
Join free to post in the discussion.
Related questions
- What text embeddings areAI Engineer (LLM & Generative AI)
- Comparing two embeddingsAI Engineer (LLM & Generative AI)
- Dot product of two vectorsAI Engineer (LLM & Generative AI)
- Parsing a JSON reply in PythonAI Engineer (LLM & Generative AI)
- What semantic search adds over keywordsAI Engineer (LLM & Generative AI)
- What an embedding dimension isAI Engineer (LLM & Generative AI)
- Long chunks and embedding limitsAI Engineer (LLM & Generative AI)
- Arabic questions, English documentsAI Engineer (LLM & Generative AI)