Target branch: Verify that the pull request targets the dev branch. Not targeting the dev branch will lead to immediate closure of the PR.
Description: Provide a concise description of the changes made in this pull request down below.
Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
Documentation: If necessary, update relevant documentation Open WebUI Docs like environment variables, the tutorials, or other documentation sources.
Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
Testing: Perform manual tests to verify the implemented fix/feature works as intended AND does not break any other functionality. Take this as an opportunity to make screenshots of the feature/fix and include it in the PR description.
Agentic AI Code: Confirm this Pull Request is not written by any AI Agent or has at least gone through additional human review AND manual testing. If any AI Agent is the co-author of this PR, it may lead to immediate closure of the PR.
Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
Title Prefix: To clearly categorize this pull request, prefix the pull request title using one of the following:
BREAKING CHANGE: Significant changes that may affect compatibility
build: Changes that affect the build system or external dependencies
ci: Changes to our continuous integration processes or workflows
chore: Refactor, cleanup, or other non-functional code changes
docs: Documentation update or addition
feat: Introduces a new feature or enhancement to the codebase
fix: Bug fix or error correction
i18n: Internationalization or localization changes
perf: Performance improvement
refactor: Code restructuring for better maintainability, readability, or scalability
style: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc.)
test: Adding missing tests or correcting existing tests
WIP: Work in progress, a temporary label for incomplete or ongoing work
Changelog Entry
Description
We reworked the pgvector backend so Open WebUI can handle large dimensional embeddings (> 2000). The PR allows now to configure which index type should be used, allowing backwards compatibility.
The column definition now switches to the pgvector halfvec type whenever the configured dimension exceeds 2000, because Postgres can’t build HNSW indexes on the standard vector type beyond that limit. Every place that emits vectors now pulls from the same helper to choose either Vector or halfvec, and the HNSW index uses the matching operator class (halfvec_cosine_ops).
Added
Added following configuration environment variables:
PGVECTOR_INDEX_METHOD with possible values ivfflat, hnsw or empty.
PGVECTOR_HNSW_M and PGVECTOR_HNSW_EF_CONSTRUCTION to configure hnsw performance
PGVECTOR_IVFFLAT_LISTS to configure previously hardcoded lists for ivfflat type.
Changed
Switch pgvector storage to use halfvec(dim) automatically when VECTOR_LENGTH exceeds 2000, keeping standard Vector(dim) for smaller embeddings.
Update index creation to choose the correct operator class (halfvec_cosine_ops vs vector_cosine_ops) while retaining HNSW defaults and honoring config overrides.
Additional Information
[Insert any additional context, notes, or explanations for the changes]
[Attach any relevant screenshots or videos demonstrating the changes]
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
Note
Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/open-webui/open-webui/pull/19158
**Author:** [@lazariv](https://github.com/lazariv)
**Created:** 11/13/2025
**Status:** ✅ Merged
**Merged:** 11/18/2025
**Merged by:** [@tjbck](https://github.com/tjbck)
**Base:** `dev` ← **Head:** `pgvector-hnsw-index-type`
---
### 📝 Commits (6)
- [`03349e6`](https://github.com/open-webui/open-webui/commit/03349e63ec69c90564140238b839f310895ebca5) Adding hnsw index type for pgvector, allowing vector dimensions larger than 2000
- [`e8e7637`](https://github.com/open-webui/open-webui/commit/e8e7637bb5e1b21f07488baaed3daa5aeca68557) remove some variable assignments
- [`456eefc`](https://github.com/open-webui/open-webui/commit/456eefcca1e6d9132e0753d2d8b4c6c276c49a48) Merge pull request #1 from curious-broccoli/pgvector-hnsw-index-type
- [`1dea0f0`](https://github.com/open-webui/open-webui/commit/1dea0f039de2c8de5fcdff5d958f7a85041336f7) Make USE_HALFVEC variable configurable
- [`c37453c`](https://github.com/open-webui/open-webui/commit/c37453ca17eec60891c10844b6fd1e33c463b4ad) Simplify USE_HALFVEC handling
- [`ac15f0a`](https://github.com/open-webui/open-webui/commit/ac15f0a345b59b1fa6a1df3f15dc2061afb89e87) Raise runtime error if the index requires rebuilt
### 📊 Changes
**2 files changed** (+152 additions, -21 deletions)
<details>
<summary>View changed files</summary>
📝 `backend/open_webui/config.py` (+49 -0)
📝 `backend/open_webui/retrieval/vector/dbs/pgvector.py` (+103 -21)
</details>
### 📄 Description
# Pull Request Checklist
- [x] **Target branch:** Verify that the pull request targets the `dev` branch. **Not targeting the `dev` branch will lead to immediate closure of the PR.**
- [x] **Description:** Provide a concise description of the changes made in this pull request down below.
- [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description.
- [x] **Documentation:** If necessary, update relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs) like environment variables, the tutorials, or other documentation sources.
- [x] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation?
- [x] **Testing:** Perform manual tests to **verify the implemented fix/feature works as intended AND does not break any other functionality**. Take this as an opportunity to **make screenshots of the feature/fix and include it in the PR description**.
- [x] **Agentic AI Code:** Confirm this Pull Request is **not written by any AI Agent** or has at least **gone through additional human review AND manual testing**. If any AI Agent is the co-author of this PR, it may lead to immediate closure of the PR.
- [x] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
- [x] **Title Prefix:** To clearly categorize this pull request, prefix the pull request title using one of the following:
- **BREAKING CHANGE**: Significant changes that may affect compatibility
- **build**: Changes that affect the build system or external dependencies
- **ci**: Changes to our continuous integration processes or workflows
- **chore**: Refactor, cleanup, or other non-functional code changes
- **docs**: Documentation update or addition
- **feat**: Introduces a new feature or enhancement to the codebase
- **fix**: Bug fix or error correction
- **i18n**: Internationalization or localization changes
- **perf**: Performance improvement
- **refactor**: Code restructuring for better maintainability, readability, or scalability
- **style**: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc.)
- **test**: Adding missing tests or correcting existing tests
- **WIP**: Work in progress, a temporary label for incomplete or ongoing work
# Changelog Entry
### Description
We reworked the pgvector backend so Open WebUI can handle large dimensional embeddings (> 2000). The PR allows now to configure which index type should be used, allowing backwards compatibility.
The column definition now switches to the pgvector `halfvec` type whenever the configured dimension exceeds 2000, because Postgres can’t build HNSW indexes on the standard vector type beyond that limit. Every place that emits vectors now pulls from the same helper to choose either `Vector` or `halfvec`, and the HNSW index uses the matching operator class (`halfvec_cosine_ops`).
### Added
- Added following configuration environment variables:
- `PGVECTOR_INDEX_METHOD` with possible values `ivfflat`, `hnsw` or empty.
- `PGVECTOR_HNSW_M` and `PGVECTOR_HNSW_EF_CONSTRUCTION` to configure hnsw performance
- `PGVECTOR_IVFFLAT_LISTS` to configure previously hardcoded lists for ivfflat type.
### Changed
- Switch pgvector storage to use `halfvec(dim)` automatically when `VECTOR_LENGTH` exceeds 2000, keeping standard `Vector(dim)` for smaller embeddings.
- Update index creation to choose the correct operator class (`halfvec_cosine_ops` vs `vector_cosine_ops`) while retaining HNSW defaults and honoring config overrides.
---
### Additional Information
- [Insert any additional context, notes, or explanations for the changes]
- https://github.com/open-webui/open-webui/discussions/16890
### Screenshots or Videos
- [Attach any relevant screenshots or videos demonstrating the changes]
### Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms.
> [!NOTE]
> Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/19158
Author: @lazariv
Created: 11/13/2025
Status: ✅ Merged
Merged: 11/18/2025
Merged by: @tjbck
Base:
dev← Head:pgvector-hnsw-index-type📝 Commits (6)
03349e6Adding hnsw index type for pgvector, allowing vector dimensions larger than 2000e8e7637remove some variable assignments456eefcMerge pull request #1 from curious-broccoli/pgvector-hnsw-index-type1dea0f0Make USE_HALFVEC variable configurablec37453cSimplify USE_HALFVEC handlingac15f0aRaise runtime error if the index requires rebuilt📊 Changes
2 files changed (+152 additions, -21 deletions)
View changed files
📝
backend/open_webui/config.py(+49 -0)📝
backend/open_webui/retrieval/vector/dbs/pgvector.py(+103 -21)📄 Description
Pull Request Checklist
devbranch. Not targeting thedevbranch will lead to immediate closure of the PR.Changelog Entry
Description
We reworked the pgvector backend so Open WebUI can handle large dimensional embeddings (> 2000). The PR allows now to configure which index type should be used, allowing backwards compatibility.
The column definition now switches to the pgvector
halfvectype whenever the configured dimension exceeds 2000, because Postgres can’t build HNSW indexes on the standard vector type beyond that limit. Every place that emits vectors now pulls from the same helper to choose eitherVectororhalfvec, and the HNSW index uses the matching operator class (halfvec_cosine_ops).Added
PGVECTOR_INDEX_METHODwith possible valuesivfflat,hnswor empty.PGVECTOR_HNSW_MandPGVECTOR_HNSW_EF_CONSTRUCTIONto configure hnsw performancePGVECTOR_IVFFLAT_LISTSto configure previously hardcoded lists for ivfflat type.Changed
halfvec(dim)automatically whenVECTOR_LENGTHexceeds 2000, keeping standardVector(dim)for smaller embeddings.halfvec_cosine_opsvsvector_cosine_ops) while retaining HNSW defaults and honoring config overrides.Additional Information
Screenshots or Videos
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.