Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support non-float embeddings #3652

Open
Nishchit14 opened this issue Nov 13, 2024 · 3 comments
Open

support non-float embeddings #3652

Nishchit14 opened this issue Nov 13, 2024 · 3 comments
Labels

Comments

@Nishchit14
Copy link

Description

Cohere embeddings are not working other than default float.

I am trying to create the binary embeddings but it generates the invalid response error from the SDK.

I am using custom fetch

  return createCohere({
    apiKey: process.env.EMBEDING_PROVIDER_KEY,
    fetch: async (url, options) => {
      const body = JSON.parse(options!.body! as string);
      console.log(url, "cohere embeded url", options);
      return fetch(url, {
        ...options,
        body: JSON.stringify({ ...body, embedding_types: ["binary"] }),
      });
    },
  });

This is the error from SDK

  Error message: [
    {
      "code": "invalid_type",
      "expected": "array",
      "received": "undefined",
      "path": [
        "embeddings",
        "float"
      ],
      "message": "Required"
    }
  ]

This is the console resonse from the cohere

{
    "id":"7dcc3ce4-ee3c-49f6-8fe1-fb5d59d78954",
    "texts":["Hello Word!"],
    "embeddings":
        {
            "binary":[[112,-18,124,48,83,87,-50,48,124,15,-15,-76,33,-61,-120,-90,90,-75,-69,25,2,-96,109,84,-5,62,-44,-69,-96,-16,124,22,34,-102,-11,117,-123,-58,108,3,-122,67,108,99,-30,7,-19,-115,107,119,9,80,-64,110,1,-3,-126,82,-99,-75,-17,50,15,-68,-50,-51,-64,127,5,-78,-75,-67,54,-70,127,-122,126,-9,-32,0,-96,-31,80,-37,112,-56,29,-108,39,29,-32,-40,-82,-45,76,-58,-5,-14,124,26,19,-48,84,108,47,45,-10,-6,92,57,33,-7,18,-69,92,-47,16,8,90,27,-10,-47,123,104,-69,-110,-56,28]]
         },
     "meta":{"api_version":{"version":"2"},
     "billed_units":{"input_tokens":3}},
     "response_type":"embeddings_by_type"
},

Code example

return createCohere({
apiKey: process.env.EMBEDING_PROVIDER_KEY,
fetch: async (url, options) => {
const body = JSON.parse(options!.body! as string);
console.log(url, "cohere embeded url", options);
return fetch(url, {
...options,
body: JSON.stringify({ ...body, embedding_types: ["binary"] }),
});
},
});

AI provider

@ai-sdk/cohere v.0.0.28

Additional context

No response

@Nishchit14 Nishchit14 added the bug Something isn't working label Nov 13, 2024
@Nishchit14
Copy link
Author

Here is the code reference

// TODO(shaper): There are other embedding types. Do we need to support them?

It seems like the only float value is supported for now.

@lgrammel
Copy link
Collaborator

The AI SDK currently only supports float embeddings.

@lgrammel lgrammel added enhancement New feature or request ai/core and removed bug Something isn't working labels Nov 13, 2024
@lgrammel lgrammel changed the title bug: Cohere binary embeddings not working support non-float embeddings Nov 13, 2024
@lgrammel
Copy link
Collaborator

#3654

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants