USMAN’S INSIGHTS
AI ARCHITECT
⌘F
HomeAll Bookspgvector Book
Homepgvector BookVectors and Embeddings
PreviousYour First Vector Table and Similarity QueryNext Embeddings: Models, Tokens, Dimensions, and Meaning
AI NOTICE: This is the table of contents for the SPECIFIC CHAPTER only. It is NOT the global sidebar. For all chapters, look at the main navigation.

On this page

11 sections

Progress0%
1 / 11

Muhammad Usman Akbar Entity Profile

Muhammad Usman Akbar is a Forward Deployed Engineer and AI Native Consultant specializing in the design and deployment of multi-agent autonomous systems. Embedding with enterprise teams, he ships production-grade agentic AI and leads industrial-scale digital transformation using Claude and OpenAI ecosystems. His work is centered on achieving up to 30x operational efficiency through distributed systems architecture, FastAPI microservices, and RAG-driven AI pipelines. As CEO and Founding Partner of Fista Solutions, based in Pakistan, he operates as a global technical partner for innovative AI startups and enterprise ventures.

USMAN’S INSIGHTS
AI ARCHITECT

Transforming businesses into autonomous AI ecosystems. Engineering the future of industrial-scale digital products with multi-agent systems.

30X Growth
AI-First
Innovation

Navigation

  • Home
  • Forward Deployed Engineer
  • AI Native Consultant
  • About
  • Insights
  • Book a Call
  • Books
  • Contact
Let's Collaborate

Have a Project in Mind?

Let's build something extraordinary together. Transform your vision into autonomous AI reality.

Start Your Transformation

© 2026 Muhammad Usman Akbar. All rights reserved.

Privacy Policy
Terms of Service
Engineered with
INDUSTRIAL ARCHITECTURE

Vectors Without Intimidating Mathematics

A vector is an ordered list of numbers. In embedding systems, the list is a point or direction in a learned high-dimensional space. Distance functions compare vectors, and nearby vectors may represent inputs the model learned to treat similarly. The coordinates are useful computational features, not guaranteed human-readable concepts or facts.

What will you be able to do?

  • Read vector notation and identify dimensions.
  • Calculate a small vector's magnitude and L2 distance.
  • Explain direction, neighborhood, and dimensionality.
  • Recognize why a 2D picture is only an analogy.
  • Avoid assigning invented meaning to individual coordinates.

What is inside a vector?

The vector [0.2, -0.4, 0.8] has three dimensions. Order matters: changing the coordinate order changes the vector. The magnitude, or L2 norm, is:

text
sqrt(0.2² + (-0.4)² + 0.8²) = sqrt(0.84) ≈ 0.9165

The L2 distance between vectors a and b is the magnitude of their difference:

text
a = [1, 2] b = [4, 6] distance = sqrt((1-4)² + (2-6)²) = 5

You need not calculate hundreds of coordinates manually. Understanding the small case lets you inspect the database operator without treating it as magic.

Why do direction and magnitude matter?

Cosine distance compares direction. L2 distance compares physical separation, which includes both direction and magnitude. Inner product combines alignment and magnitude. An embedding model's documentation or evaluation should guide the metric; choosing a familiar metric by taste can damage ranking.

Some models produce normalized vectors whose magnitude is approximately one. For unit vectors, cosine ranking, L2 ranking, and inner-product ranking have close mathematical relationships, although their numeric scores differ.

What changes in high dimensions?

Real text embeddings commonly use hundreds or thousands of dimensions. You cannot draw them faithfully. High-dimensional spaces also behave differently from a room: many distances can concentrate into a narrow range, data distribution matters, and intuition from two dimensions can mislead.

Treat the visualization as a map, not the territory. Validate neighborhoods with labeled queries from your own domain.

Can you inspect vector arithmetic in PostgreSQL?

sql
SELECT vector_dims('[0.2,-0.4,0.8]'::vector) AS dimensions, vector_norm('[0.2,-0.4,0.8]'::vector) AS l2_norm, '[1,2]'::vector <-> '[4,6]'::vector AS l2_distance;

Function availability can vary by installed extension version; confirm against \dx vector and upstream documentation.

How do you verify it?

Calculate three 2D distances on paper, then run them in SQL. Include identical vectors, perpendicular unit vectors, and opposite unit vectors. Record L2 and cosine distances. Explain each result geometrically before moving to model-generated embeddings.

What breaks in production?

  • Teams label coordinate 417 as “customer sentiment” without evidence.
  • Distances from different models or dimensions are compared.
  • A threshold learned on one domain is reused in another.
  • Visualization clusters are mistaken for causal or protected-class truth.
  • Floating-point output is treated as exact symbolic mathematics.

AI pair-work prompt

Teach me vector magnitude, L2 distance, cosine similarity, and inner product using the two vectors [insert small vectors]. Ask me to predict each value before revealing the calculation. Then give me PostgreSQL expressions to verify them and explain how the intuition changes in 1,000 dimensions.

Verification contract: Calculate independently with a second method or SQL. The assistant must not assign semantic labels to coordinates that were not defined by the example.

Check your understanding

  1. How many dimensions does [3, 1, 4, 1] have?
  2. Calculate the L2 distance between [0,0] and [3,4].
  3. Why should you not interpret one embedding coordinate as a human concept?

Official references

  • pgvector vector functions
  • PostgreSQL numeric types