Skip to content

Conversation

@elk-cloner
Copy link
Contributor

Add base64 encoding format support for embeddings endpoints

Overview

This PR implements support for base64 format in embedding responses, aligning with OpenAI's API functionality and improving payload efficiency.

Changes

  • Added encoding_format parameter support to embedding endpoints
  • Implemented base64 encoding for embedding vectors when specified
  • Updated response handling to support both float and base64 formats
  • Added tests to verify base64 encoding functionality

Related Issue

Closes #10887

@elk-cloner elk-cloner requested a review from ngxson as a code owner December 24, 2024 15:06
@github-actions github-actions bot added examples python python script changes server labels Dec 24, 2024
assert len(floats) > 0
assert all(isinstance(x, float) for x in floats)
except Exception as e:
pytest.fail(f"Invalid base64 format: {str(e)}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's a bad practice to use try..catch inside a test, because if one of the assert fails, it won't let you know it happens at exactly which line of code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ngxson, thanks for the hint. my bad, I forgot to remove it.

@ngxson ngxson changed the title Add support for "encoding_format": "base64" to the */embeddings endpoints server : add support for "encoding_format": "base64" to the */embeddings endpoints Dec 24, 2024
@ngxson ngxson merged commit 9ba399d into ggml-org:master Dec 24, 2024
50 checks passed
tinglou pushed a commit to tinglou/llama.cpp that referenced this pull request Feb 13, 2025
…ngs endpoints (ggml-org#10967)

* add support for base64

* fix base64 test

* improve test

---------

Co-authored-by: Xuan Son Nguyen <[email protected]>
arthw pushed a commit to arthw/llama.cpp that referenced this pull request Feb 26, 2025
…ngs endpoints (ggml-org#10967)

* add support for base64

* fix base64 test

* improve test

---------

Co-authored-by: Xuan Son Nguyen <[email protected]>
mglambda pushed a commit to mglambda/llama.cpp that referenced this pull request Mar 8, 2025
…ngs endpoints (ggml-org#10967)

* add support for base64

* fix base64 test

* improve test

---------

Co-authored-by: Xuan Son Nguyen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

examples python python script changes server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: support "encoding_format": "base64" in the */embeddings endpoints

2 participants