[PR #8145] [CLOSED] Embedding Normalization Options #12647

Closed
opened 2026-04-13 00:05:46 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/8145
Author: @gabe-l-hart
Created: 12/17/2024
Status: Closed

Base: mainHead: LegacyEmbeddingsNormalization


📝 Commits (4)

  • f5c827d feat: Add normalize options to both EmbedRequest and Embeddingrequest
  • 624993e feat: Conditionally apply normalizaiton in EmbedHandler and EmbeddingHandler
  • 62c7c03 docs: Add docs for normalize parameters
  • 2b454af test: Test various normalization combos in embed_test

📊 Changes

4 files changed (+140 additions, -44 deletions)

View changed files

📝 api/types.go (+6 -0)
📝 docs/api.md (+5 -1)
📝 integration/embed_test.go (+119 -42)
📝 server/routes.go (+10 -1)

📄 Description

Description

This PR introduces the new API parameter normalize for the /api/embed and /api/embeddings endpoints that allow the user to explicitly enable/disable normalization. The default behavior of both endpoints is preserved (normalization for embed, no normalization for embeddings), but this allows them to produce equivalent output to avoid future confusion.

Issues

Discussion

The /api/embeddings endpoint is deprecated according to the docs. An argument could be made that we should not add this functionality to this endpoint and simply document around the discrepancy. I'd be totally open to this!

Testing

I updated the embed_test.go to include the various combinations against embed and embedding. I ran them as follows:

OLLAMA_TEST_EXISTING=true go test -tags=integration ./integration/ -test.run TestAllMiniLM.*

🔄 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/ollama/ollama/pull/8145 **Author:** [@gabe-l-hart](https://github.com/gabe-l-hart) **Created:** 12/17/2024 **Status:** ❌ Closed **Base:** `main` ← **Head:** `LegacyEmbeddingsNormalization` --- ### 📝 Commits (4) - [`f5c827d`](https://github.com/ollama/ollama/commit/f5c827df888534353177433cf5f815cc6a2db3e2) feat: Add normalize options to both EmbedRequest and Embeddingrequest - [`624993e`](https://github.com/ollama/ollama/commit/624993e412e8e366194360e289d73885067ebda5) feat: Conditionally apply normalizaiton in EmbedHandler and EmbeddingHandler - [`62c7c03`](https://github.com/ollama/ollama/commit/62c7c036b802a348884381a89a23d0b918c1f2fe) docs: Add docs for `normalize` parameters - [`2b454af`](https://github.com/ollama/ollama/commit/2b454af0b3a9de0bfce40082918abf8aade05385) test: Test various normalization combos in embed_test ### 📊 Changes **4 files changed** (+140 additions, -44 deletions) <details> <summary>View changed files</summary> 📝 `api/types.go` (+6 -0) 📝 `docs/api.md` (+5 -1) 📝 `integration/embed_test.go` (+119 -42) 📝 `server/routes.go` (+10 -1) </details> ### 📄 Description ## Description This PR introduces the new API parameter `normalize` for the `/api/embed` and `/api/embeddings` endpoints that allow the user to explicitly enable/disable normalization. The default behavior of both endpoints is preserved (normalization for `embed`, no normalization for `embeddings`), but this allows them to produce equivalent output to avoid future confusion. ## Issues - Related to confusion in https://github.com/ollama/ollama/issues/8094 - Closes https://github.com/ollama/ollama/issues/7858 - Closes https://github.com/ollama/ollama/issues/6496 ## Discussion The `/api/embeddings` endpoint is deprecated according to [the docs](https://github.com/ollama/ollama/blob/main/docs/api.md#generate-embedding). An argument could be made that we should not add this functionality to this endpoint and simply document around the discrepancy. I'd be totally open to this! ## Testing I updated the `embed_test.go` to include the various combinations against `embed` and `embedding`. I ran them as follows: ```sh OLLAMA_TEST_EXISTING=true go test -tags=integration ./integration/ -test.run TestAllMiniLM.* ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-13 00:05:46 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#12647