Skip to content

Enable bfloat16 and on-disk rescoring for dense vectors#138492

Merged
thecoop merged 30 commits intoelastic:mainfrom
thecoop:enable-generic-vector-formats
Dec 5, 2025
Merged

Enable bfloat16 and on-disk rescoring for dense vectors#138492
thecoop merged 30 commits intoelastic:mainfrom
thecoop:enable-generic-vector-formats

Conversation

@thecoop
Copy link
Member

@thecoop thecoop commented Nov 24, 2025

New options have been added to the dense_vector field type.

The first is support for storing vectors in bfloat16 format. This is a floating-point format that utilises two bytes per value rather than four, halving the storage space required compared to element_type: float. This can be specified with element_type: bfloat16 when creating the index, for all dense_vector indexing types:

PUT vectors
{
  "mappings": {
    "properties": {
      "vector": {
        "type": "dense_vector",
        "element_type": "bfloat16",
        "index_options": {"type": "bbq_hnsw"}
      }
    }
  }
}

Float values are automatically rounded to 2-bytes when writing to disk, so this format can be used with original source vectors at 2- or 4-byte precision. BFloat16 values are zero-expanded back to 4-byte floats when read into memory. Using bfloat16 will cause a loss of precision compared to the original vector values, as well as a small performance hit due to converting between bfloat16 and float when reading and writing vectors; however this may be counterbalanced by a corresponding decrease in I/O, depending on your workload.

The second option is to utilise on-disk rescoring. When rescoring vectors during kNN searches, the raw vectors are read into memory. When the vector data is larger than the amount of available RAM, this might cause the OS to evict some in-memory pages that then need to be paged back in immediately afterwards. This can cause a significant slowdown in search speed. Utilising on-disk rescoring causes rescoring to use raw vector data on-disk during rescoring, and to not read it into memory first. This may significantly increase search performance in such low-memory situations.
This is specified as an index option for HNSW vector index types:

PUT vectors
{
  "mappings": {
    "properties": {
      "vector": {
        "type": "dense_vector",
        "index_options": {"type": "bbq_hnsw", "on_disk_rescore": true}
      }
    }
  }
}

bfloat16 support is GA, on-disk rescoring is preview functionality.

Doc changes: elastic/docs-content#3847
Spec changes: elastic/elasticsearch-specification#5728

@thecoop thecoop added >feature :Search Relevance/Vectors Vector search test-full-bwc Trigger full BWC version matrix tests test-release Trigger CI checks against release build labels Nov 24, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-relevance (Team:Search Relevance)

@elasticsearchmachine elasticsearchmachine added v9.3.0 Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch labels Nov 24, 2025
@elasticsearchmachine
Copy link
Collaborator

Hi @thecoop, I've created a changelog YAML for you.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 24, 2025

@github-actions
Copy link
Contributor

ℹ️ Important: Docs version tagging

👋 Thanks for updating the docs! Just a friendly reminder that our docs are now cumulative. This means all 9.x versions are documented on the same page and published off of the main branch, instead of creating separate pages for each minor version.

We use applies_to tags to mark version-specific features and changes.

Expand for a quick overview

When to use applies_to tags:

✅ At the page level to indicate which products/deployments the content applies to (mandatory)
✅ When features change state (e.g. preview, ga) in a specific version
✅ When availability differs across deployments and environments

What NOT to do:

❌ Don't remove or replace information that applies to an older version
❌ Don't add new information that applies to a specific version without an applies_to tag
❌ Don't forget that applies_to tags can be used at the page, section, and inline level

🤔 Need help?

@elasticsearchmachine
Copy link
Collaborator

Hi @thecoop, I've updated the changelog YAML for you. Note that since this PR is labelled release highlight, you need to update the changelog YAML to fill out the extended information sections.

Copy link
Contributor

@tteofili tteofili left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thecoop thecoop force-pushed the enable-generic-vector-formats branch from ee094b9 to bf465d5 Compare November 25, 2025 15:55
@thecoop thecoop added the >docs General docs changes label Nov 25, 2025
@elasticsearchmachine elasticsearchmachine added the Team:Docs Meta label for docs team label Nov 25, 2025
@thecoop thecoop removed the >docs General docs changes label Nov 25, 2025
@elasticsearchmachine elasticsearchmachine removed the Team:Docs Meta label for docs team label Nov 25, 2025
Copy link
Contributor

@shainaraskas shainaraskas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some suggestions for signaling availability

Copy link
Contributor

@shainaraskas shainaraskas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added some comments to the changelog entry while I was answering your question :)

Copy link
Contributor

@shainaraskas shainaraskas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added some comments to the changelog entry while I was answering your question :)

@thecoop thecoop force-pushed the enable-generic-vector-formats branch from 2464888 to f5da14b Compare December 4, 2025 09:22
Copy link
Contributor

@jimczi jimczi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's split this in two please, one PR to enable bfloat16 and another one for rescoring dense vectors.

Copy link
Contributor

@jimczi jimczi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that we have a single feature flag here so we cannot split. I am approving to unblock but let's at least have a separate change log that we can link with the appropriate issue.

@thecoop thecoop merged commit 17bbe46 into elastic:main Dec 5, 2025
30 checks passed
@thecoop thecoop deleted the enable-generic-vector-formats branch December 5, 2025 12:10
mamazzol pushed a commit to mamazzol/elasticsearch that referenced this pull request Dec 5, 2025
This enables the bfloat16 element_type and on-disk rescoring options for dense_vector indexes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>feature release highlight :Search Relevance/Vectors Vector search Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch test-full-bwc Trigger full BWC version matrix tests test-release Trigger CI checks against release build v9.3.0

6 participants