AI / A CONCEPT NOTE

Semantic Search

finding documents by conceptual meaning rather than exact keywords

~65 sec read

Overview · mechanism
pitfall · examples

01 / THE SHORT VERSION

The idea in a few sentences.

Uses vector embeddings to map queries and documents into a shared high-dimensional latent space, measuring relevance via Cosine Similarity rather than string matching.

02 / FOLLOW THE MECHANISM

How semantic retrieval operates

  1. User Query

    is passed through an embedding model to generate a dense vector.

  2. Vector DB Index

    performs Approximate Nearest Neighbors (ANN) vector search.

  3. Distance Calculation

    ranks top-K documents by highest cosine similarity.

  4. Result Chunks

    are returned to the application as grounded prompt context.

04 / COMMAND NOTES

Read the command, then the result.

Inspect the flags and arguments before trying an example. Snippets can need local setup, replacement values, or resources in your own environment.

EXAMPLE 01 · REFERENCE

calculate cosine similarity

python -c import numpy as np; a=np.array([1,0]); b=np.array([0.9,0.1]); print(np.dot(a,b)/(np.linalg.norm(a)*np.linalg.norm(b)))

Explore command anatomy in the CLI lab