openai-cookbook icon indicating copy to clipboard operation
openai-cookbook copied to clipboard

[PROBLEM] Semantic text search using embeddings cookbook has confusing imports for embeddings_utils

Open chanonroy opened this issue 1 year ago • 0 comments
trafficstars

[optional format]

Identify the file to be fixed Semantic_text_search_using_embeddings.ipynb

Describe the problem

from utils.embeddings_utils import get_embedding, cosine_similarity

This import line is failing in the cookbook. Not sure if it's intended as a relative import

Describe a solution A clear and concise description of what a fixed version should do.

For cosine_similarity, we could use scipy tools:

from scipy.spatial import distance

distance.cosine()

For get_embedding, we could write it out for clarity:

def get_embedding(text, model):
   ...

Screenshots Screenshot 2024-04-05 at 2 05 45 PM

Additional context General suggestion here is to remove the relative importing so that people can get to "Hello World" faster here

chanonroy avatar Apr 05 '24 13:04 chanonroy