October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

Reduce Embedding Dimensions in Spring AI and pgvector Without Guesswork

Smaller embeddings can reduce vector storage and help meet pgvector index limits, but the model, query vectors, Spring AI setting, and database schema must all match.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Reducing embedding dimensions can make vectors smaller and help fit pgvector index limits, but it is not a switch that can be changed independently in a live database. The embedding model’s output width, Spring AI’s PgVectorStore setting, and the database column must agree. Before moving production traffic, create a compatible schema, re-embed data as needed, and measure retrieval quality on your own corpus.

What embedding dimensions change

An embedding is a vector: a sequence of numbers whose count is its dimensional width. The model determines that width, and the database column and index must support it. Spring AI’s PgVectorStore reference uses vector(1536) as an example and explains that the configured dimensions determine the embedding column width. That example is not a universal model setting. Spring AI PgVectorStore documentation

As an Amazon Associate I earn from qualifying purchases.

Reducing width can reduce the amount of vector data stored and may make an index configuration possible where the original width exceeded a limit. It is also a retrieval-quality tradeoff: fewer dimensions do not guarantee equivalent results for your application. The cited documentation does not establish universal percentages for storage savings, index size, latency, or recall.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check pgvector limits before choosing a width

Spring AI’s PgVectorStore reference cites a maximum of 2,000 dimensions for pgvector HNSW indexes when using its vector example. The pgvector project README documents vector up to 2,000 dimensions and halfvec up to 4,000. These are type and index compatibility limits, not a recommendation that every application use the largest supported width. Spring AI PgVectorStore documentation · pgvector README

#1 Best Overall

Do not infer that selecting a larger Spring AI dimensions value automatically switches the database column to halfvec. Confirm the column type and index support in the integration and schema you actually deploy.

Request a shorter embedding from a supported model

OpenAI’s text-embedding-3 models support a dimensions parameter in the embeddings API. This lets an application request a shorter output from a model that supports the option; it does not mean every embedding model can produce arbitrary widths. Check the API reference and the Spring AI version used by your application for the exact model property or runtime option wiring. OpenAI embeddings API reference

OpenAI reported that text-embedding-3-large shortened to 256 dimensions outperformed unshortened text-embedding-ada-002 at 1,536 dimensions on the MTEB benchmark. That is a particular benchmark comparison between two model configurations, not evidence that shortening will preserve or improve retrieval quality for every corpus or task. OpenAI’s embedding models announcement

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep model, query, and database widths aligned

For a working retrieval pipeline, embeddings generated for stored documents and incoming queries must use compatible model and dimension settings, and the database column must match. Spring AI documents spring.ai.vectorstore.pgvector.dimensions for the PgVectorStore column width. If omitted, the store retrieves dimensions from the configured EmbeddingModel. The setting applies when the table is created; changing it does not reshape an existing table. Spring AI PgVectorStore documentation

Schema initialization is disabled by default: the property documentation lists initialize-schema as false, and the guide says initialization must be explicitly enabled. Verify the exact property names and model configuration against the Spring AI version pinned in your application rather than copying configuration across versions without checking.

For OpenAI API embeddings specifically, outputs are L2-normalized by default, including after shortening. OpenAI says cosine similarity and Euclidean distance produce identical rankings for these normalized vectors. This behavior should not be generalized to embeddings from other providers or models. OpenAI embeddings FAQ

Plan a dimension change as a data and index migration

A dimension change affects stored vectors and schema, so treat it as a migration rather than a configuration-only adjustment. A practical sequence is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Choose a candidate width. Check the selected pgvector type and index limits, model support, and application constraints.
  2. Capture a baseline. Build representative queries and record current retrieval results and task-level answer quality before changing embeddings.
  3. Align both embedding paths. Configure document ingestion and query embedding generation to use the same model and requested width.
  4. Create a compatible schema and index. Plan for a new or recreated vector_store table; Spring AI states that changing dimensions requires recreating the table.
  5. Re-embed or reload the corpus. Existing vectors do not become shorter merely because the application property changes.
  6. Evaluate before cutover. Compare recall or task-level quality, latency, storage and index size, and index build/update cost on the workload that matters to your application.

Spring AI’s documentation establishes the schema behavior, while the evaluation sequence is operational guidance: the cited sources do not report a universal benchmark for these migration outcomes.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Decide whether shorter vectors are the right fix

Compare the options against the constraints that prompted the change rather than assuming a smaller width is always better.

Option What it addresses What to validate
Keep the model’s full supported width Avoids reducing the model’s output dimensions; compatible only if the selected column and index support that width. Index/type limits and measured storage, latency, and retrieval quality on your workload.
Request shorter output from a model that supports it Can bring vectors within a chosen width limit and reduce vector storage. Model API support, matching query and document widths, and retrieval quality on representative queries.
Use another supported pgvector type or index approach May allow a different compatibility range; pgvector documents halfvec up to 4,000 dimensions. Whether the Spring AI integration and deployed schema support the chosen type and index, plus quality and operational tradeoffs.

The available documentation does not provide a general quantitative comparison of recall, index size, or latency across these options. Use a corpus-specific evaluation to decide whether the space and index benefits justify the migration and any retrieval change.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.