You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Confirm this is an issue with the Python library and not an underlying OpenAI API
This is an issue with the Python library
Describe the bug
Symptons: Creating multiple embeddings with one api call is very slow (seconds vs miliseconds)
Where to look:
The bug is in https://github.com/openai/openai-python/blob/main/src/openai/lib/_parsing/_embeddings.py line 27
The code calls has_numpy() in a loop for every embedding. The function tries to import numpy, catches the exeption and returns a bool. If numpy isnt installed this is very slow.
Fix:
call has_numpy() either as global on instantiation, outside of the loop once or wrap has_numpy in functools.cache.
To Reproduce
create embeddings for 1500 strings with one api call. Leave the encoding_format option empty
meassure the time the api call takes
do the same with encoding_format="base64", decode the entries with numpy manually and compare the time, it should be identical
Activity
fix: avoid repeated numpy checks for embeddings (openai#3757)