Hi, I wanted to ask if there is any documentation or samples on how to use embeddings api search in node js. I want to compare a reference text to a bunch of other texts and sort the most relevant. Would really appreciate any help.
Thanks a lot
If you go to the docs, you can select the language on the top right of the code boxes: https://platform.openai.com/docs/guides/embeddings/what-are-embeddings?lang=node
a search is just going through all the embeddings and calculating the cosine similarity
corpus.map(e => cosim(e.embedding, query.embedding))
sort it, and take the top n (maybe 5? or maybe use a cutoff). those are your search results.
if you have tons of elements, it might make sense to use a vector db, like milvus for example.
Thanks, yes I’ve seen the list to select the language, it’s just the search example was python only. Thanks again
Mmmh.
If you’re not familiar with python, I do recommend familiarizing yourself with it. That said, asking chatgpt to translate code for you generally works pretty well, especially if you’re dealing with simple examples.
Good luck!
The problem is I’m more familiar with python than node
Thanks again!