Skip to content

.Net: Added dimensions property to OpenAI embedding generation services#6077

Merged
dmytrostruk merged 7 commits intomicrosoft:mainfrom
dmytrostruk:openai-text-embedding-dimensions
May 2, 2024
Merged

.Net: Added dimensions property to OpenAI embedding generation services#6077
dmytrostruk merged 7 commits intomicrosoft:mainfrom
dmytrostruk:openai-text-embedding-dimensions

Conversation

@dmytrostruk
Copy link
Copy Markdown
Member

Motivation and Context

Resolves: #6026

This PR contains changes to expose dimensions property which is supported by OpenAI and Azure .NET SDK:
https://platform.openai.com/docs/api-reference/embeddings/create#embeddings-create-dimensions
image

Contribution Checklist

@dmytrostruk dmytrostruk self-assigned this May 1, 2024
@dmytrostruk dmytrostruk requested a review from a team as a code owner May 1, 2024 01:46
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel labels May 1, 2024
@rogerbarreto
Copy link
Copy Markdown
Member

Adding this parameter at the connector level seems to be an issue, we might consider having a ExecutionSettings for embeddings API...

Any change on this matter I would add as experimental if the plan is to soon move this to be a setting per Invocation.

@westey-m

@dmytrostruk
Copy link
Copy Markdown
Member Author

Adding this parameter at the connector level seems to be an issue, we might consider having a ExecutionSettings for embeddings API...

@rogerbarreto I thought about that, but I also think that we can have both options supported. If you set vector dimensions once on connector level, you won't have to do that with each request. And I don't think that this parameter will change too much in runtime, because every time you change the dimension, your data may lose a context.

ExecutionSettings for embedding API will be supported, here is ADR for this:
#5277

Any change on this matter I would add as experimental if the plan is to soon move this to be a setting per Invocation.

All embedding functionality is marked as Experimental at the moment.

@rogerbarreto
Copy link
Copy Markdown
Member

rogerbarreto commented May 1, 2024

IF this is Experimental, suggest creating a new method marked as Experimental with the new dimension extra parameter to avoid the breaking change.

@dmytrostruk
Copy link
Copy Markdown
Member Author

IF this is Experimental, suggest creating a new method marked as Experimental with the new dimension extra parameter to avoid the breaking change.

@rogerbarreto I thought about that as well :) But the thing is that there are 11 methods that were modified. In order to avoid breaking changes, I will need to add 11 more overload methods with new parameter. It's not a big problem, but since we agreed that at some point we will have to obsolete existing methods and replace them with Config classes, I'm not sure if we need to add new methods now in order to obsolete them later.

Besides, this is breaking change only from API compatibility point of view, but not for compiler, that's the reason I added this parameter as last one. And since these are static methods, it's not possible to mock them in tests, so it should not break mocking scenarios.

@dmytrostruk dmytrostruk added this pull request to the merge queue May 2, 2024
Merged via the queue into microsoft:main with commit b4bfef1 May 2, 2024
@dmytrostruk dmytrostruk deleted the openai-text-embedding-dimensions branch May 2, 2024 18:06
LudoCorporateShark pushed a commit to LudoCorporateShark/semantic-kernel that referenced this pull request Aug 25, 2024
…es (microsoft#6077)

### Motivation and Context

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

Resolves: microsoft#6026

This PR contains changes to expose `dimensions` property which is
supported by OpenAI and Azure .NET SDK:

https://platform.openai.com/docs/api-reference/embeddings/create#embeddings-create-dimensions

![image](https://github.com/microsoft/semantic-kernel/assets/13853051/e6b5233e-d6de-4fb6-aa48-fa1147474637)

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.Net: Support for embedding dimensions

5 participants