64bit / async-openai

Rust library for OpenAI
https://docs.rs/async-openai
MIT License
1.11k stars 165 forks source link

Support variable length embeddings #184

Closed adri1wald closed 7 months ago

adri1wald commented 7 months ago

Describe the feature or improvement you're requesting

From the blog on new embedding models:

Both of our new embedding models were trained with a technique that allows developers to trade-off performance and cost of using embeddings. Specifically, developers can shorten embeddings (i.e. remove some numbers from the end of the sequence) without the embedding losing its concept-representing properties by passing in the dimensions API parameter. For example, on the MTEB benchmark, a text-embedding-3-large embedding can be shortened to a size of 256 while still outperforming an unshortened text-embedding-ada-002 embedding with a size of 1536.

Based on the API reference, this is available via a new parameter on the embedding request called dimensions (optional integer).

Additional context

I'm happy to write a PR for this.

64bit commented 7 months ago

Thank you for the detailed description. PR is most welcome!

vmg-dev commented 7 months ago

Opened a PR for this here: https://github.com/64bit/async-openai/pull/185

64bit commented 7 months ago

This is released in v0.18.2.

Thank you all!