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

Add openai embeddings #915

Merged
merged 7 commits into from Mar 8, 2024
Merged

Conversation

Martok88
Copy link
Contributor

@Martok88 Martok88 commented Mar 8, 2024

This is working, but I haven't tested it extensively. I added a new optional parameter, maxBatchSize, which defaults to 100 if not set in the config. Apparently OpenAI's embedding endpoint can handle batches of 2048, but I also found reports of some users experiencing problems with large batches.
It still needs a documentation update, and should probably be reworked to use the OpenAI library.

TEXT_EMBEDDING_MODELS = `[
  {
    "name": "text-embedding-3-small",
    "displayName": "text-embedding-3-small",
    "description": "OpenAI hosted embedding model",
    "chunkCharLength": 768,
    "endpoints": [
      {
        "type": "openai",
        "url": "https://api.openai.com/v1/embeddings",
      }
    ]
  }
]`

@nsarrazin nsarrazin self-requested a review March 8, 2024 08:02
@nsarrazin
Copy link
Collaborator

I pushed some minor changes here: 6fb16c9

I replaced authorization by apiKey so it matches the open ai endpoint and added a default for the URL.

Tested locally, it seems to work great! Thanks for adding this and if the changes look good to you we can merge this.

@nsarrazin
Copy link
Collaborator

I want to do a documentation pass in a later PR so I'll expand on this endpoint as well when doing it 😄

@Martok88
Copy link
Contributor Author

Martok88 commented Mar 8, 2024

Looks good!

@nsarrazin nsarrazin merged commit f7db219 into huggingface:main Mar 8, 2024
3 checks passed
@nsarrazin
Copy link
Collaborator

Thanks for the contribution! 🚀

@Martok88 Martok88 deleted the add-openai-embeddings branch March 8, 2024 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants