USMAN’S INSIGHTS
AI ARCHITECT
⌘F
HomeAll Bookspgvector Book
Homepgvector BookVectors and Embeddings
PreviousVectors Without Intimidating MathematicsNext L2, Cosine, Inner Product, L1, Hamming, and Jaccard Distance
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

Embeddings: Models, Tokens, Dimensions, and Meaning

An embedding model transforms an input—such as text, an image, or audio—into a fixed-length vector. During training, the model learns a geometry useful for particular similarity tasks. Results depend on the exact model, revision, preprocessing, input type, language, truncation, and task instructions, so every stored embedding needs versioned provenance.

What will you be able to do?

  • Explain the embedding pipeline from input to vector.
  • Distinguish tokens from vector dimensions.
  • Record enough metadata to reproduce an embedding.
  • Identify model incompatibility before querying.
  • Explain why semantic proximity is not factual proof.

How does text become a vector?

Rendering diagram...

Tokens are the model's input units. Dimensions are the number of numbers in the output vector. A 200-token passage can produce a 1,024-dimensional vector; those quantities describe different stages.

Models may distinguish document and query inputs through prefixes or parameters. If the model expects search_document: and search_query: instructions, omitting them can reduce retrieval quality even though dimensions still match.

What must you store with an embedding?

At minimum:

sql
CREATE TABLE app.embedding_models ( id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY, provider text NOT NULL, model_name text NOT NULL, model_revision text NOT NULL, dimensions integer NOT NULL CHECK (dimensions > 0), distance_metric text NOT NULL, preprocessing_version text NOT NULL, created_at timestamptz NOT NULL DEFAULT now(), UNIQUE (provider, model_name, model_revision, preprocessing_version) );

For derived rows, also store source checksum, chunker version, embedded timestamp, and model ID. The vector column's dimension enforces shape, but shape alone cannot prove that query and document embeddings share the same semantic space.

What does semantic similarity mean?

It means the model's learned representation places two inputs near one another under a chosen metric. That can reflect topic, intent, style, syntax, image content, or training artifacts. It does not prove equivalence, truth, causation, safety, or authorization. Measure whether neighborhoods serve your task with labeled examples.

How should you test without a paid provider?

Unit tests can use a deterministic fake embedder:

python
from hashlib import sha256 def fake_embedding(text: str, dimensions: int = 3) -> list[float]: digest = sha256(text.encode("utf-8")).digest() values = [digest[i] / 255.0 for i in range(dimensions)] return values

This tests plumbing, dimensions, idempotency, and SQL parameters—not semantic quality. Integration and retrieval evaluations must use the intended embedding model and representative data.

How do you verify it?

Embed the same input twice with identical settings; compare vectors or provider guarantees. Embed it after changing whitespace, case policy, task prefix, or model revision. Record what changes. Query the vector length in application code and compare it with the PostgreSQL column definition before any insert.

What breaks in production?

  • Query and document embeddings use different models.
  • Long inputs are silently truncated.
  • A model alias changes behind an unversioned name.
  • Personal data is sent to an unapproved external provider.
  • Model output is cached without tenant, model, and preprocessing keys.
  • Re-embedding replaces old vectors before the new index is ready.

AI pair-work prompt

Design an EmbeddingProvider interface for [Python/TypeScript]. It must expose model identity, revision, dimensions, supported input types, maximum input policy, document/query modes, batch embedding, and typed errors. Include a deterministic fake for unit tests. Do not include real API keys or assume retries are always safe.

Verification contract: Tests must reject a wrong-length vector, distinguish query and document modes, and prove that cache keys include model revision and preprocessing version.

Check your understanding

  1. What is the difference between a token and a dimension?
  2. Why is matching dimension insufficient to prove model compatibility?
  3. List five pieces of embedding provenance you would store.

Official references

  • pgvector supported vector types
  • PostgreSQL constraints