USMAN’S INSIGHTS
AI ARCHITECT
⌘F
HomeAll Bookspgvector Book
Homepgvector BookVectors and Embeddings
PreviousL2, Cosine, Inner Product, L1, Hamming, and Jaccard DistanceNext Choose and Evaluate an Embedding Model
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

Normalization, Dimensions, Precision, and Model Compatibility

Reliable vector search requires more than a matching array length. The query and stored vectors must share model, revision, preprocessing, task mode, dimensions, type, and intended metric. Normalization changes metric behavior; reduced precision changes storage and ranking; zero or null vectors need explicit policy. Encode what you can in schema and validate the rest in ingestion.

What will you be able to do?

  • Enforce dimensions with pgvector types.
  • Detect incompatible query and document embeddings.
  • Decide whether to normalize and where.
  • Compare vector and halfvec precision tradeoffs.
  • Define policies for missing, zero, or failed embeddings.

Why do dimensions matter?

vector(768) accepts exactly 768 coordinates. A new 1,024-dimensional model cannot be written into that column, which is a useful failure. A dangerous case is two different models with the same dimension: PostgreSQL sees compatible shapes even though their semantic spaces are unrelated.

Use an explicit model registry and bind embedding rows to it:

sql
CREATE TABLE app.embeddings ( chunk_id bigint NOT NULL REFERENCES app.chunks(id) ON DELETE CASCADE, model_id bigint NOT NULL REFERENCES app.embedding_models(id), embedding vector(768) NOT NULL, source_checksum text NOT NULL, embedded_at timestamptz NOT NULL DEFAULT now(), PRIMARY KEY (chunk_id, model_id) );

If models have different dimensions, separate typed columns, tables, or partitions give PostgreSQL enforceable definitions. An unconstrained vector column can store mixed dimensions, but indexes apply only to rows cast or constrained to a consistent dimensional type; it also moves more validation into application logic.

Should you normalize vectors?

Normalize only when the embedding model or retrieval design calls for it. A unit vector has L2 norm one. For normalized vectors, inner product can be a fast equivalent ranking to cosine. Store whether normalization occurred as part of preprocessing version. Avoid normalizing a zero vector; define it as an embedding failure or excluded record.

pgvector provides normalization functions for supported types in current versions. Verify the exact function names in your installed extension.

How much precision do you need?

vector stores single-precision floats. halfvec uses half precision, allowing more indexed dimensions and smaller storage at the cost of numeric precision. Binary representations use much less information. The correct choice comes from an evaluation: compare retrieval metrics, size, build time, insert rate, and latency on your data.

Never decide from storage savings alone. A small recall reduction may significantly change rare-query outcomes.

What should happen when embedding fails?

Do not invent a zero vector to satisfy NOT NULL. Keep job state separately:

sql
CREATE TYPE app.embedding_status AS ENUM ('pending', 'processing', 'ready', 'failed', 'superseded'); ALTER TABLE app.chunks ADD COLUMN embedding_status app.embedding_status NOT NULL DEFAULT 'pending', ADD COLUMN embedding_error_code text;

Only ready rows should enter retrieval. Store sanitized error codes rather than provider responses that may contain sensitive inputs.

How do you verify it?

  • Attempt a wrong-dimension insert and confirm rejection.
  • Sample vector_norm(embedding) and inspect the distribution when normalization is expected.
  • Verify every query request resolves one allowed model_id before embedding.
  • Compare a fixed golden query set before and after a precision change.

What breaks in production?

  • An unversioned model alias changes output.
  • Zero vectors create meaningless cosine results.
  • Mixed normalized and unnormalized vectors share an index.
  • Precision is reduced without evaluating rare or multilingual queries.
  • Failed chunks are retried forever without bounded state transitions.

AI pair-work prompt

Review my embedding schema and pipeline contract [paste]. Build a compatibility matrix covering model name, revision, dimensions, preprocessing, query/document mode, normalization, vector type, metric, and index operator class. Propose database constraints and application guards for every detectable mismatch.

Verification contract: Create one failing test per guard, plus a golden-set comparison for any change that cannot be enforced structurally.

Check your understanding

  1. Why can equal dimensions still be incompatible?
  2. Why is a zero vector a poor failure placeholder?
  3. Design a migration from 768-dimensional vector to 1,024-dimensional halfvec without overwriting the old version.

Official references

  • pgvector vector types
  • pgvector half-precision vectors
  • PostgreSQL enumerated types