AashitaK commited on
Commit
c254fea
·
verified ·
1 Parent(s): 3c86168

Create embedding_generation.py

Browse files
Files changed (1) hide show
  1. embedding_generation.py +12 -0
embedding_generation.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import get_embedding from openai_api
3
+
4
+ def compute_doc_embeddings(df: pd.DataFrame) -> dict[tuple[str, str], list[float]]:
5
+ """
6
+ Create an embedding for each row in the dataframe using the OpenAI Embeddings API.
7
+
8
+ Return a dictionary that maps between each embedding vector and the index of the row that it corresponds to.
9
+ """
10
+ return {
11
+ idx: get_embedding(r.description) for idx, r in df.iterrows()
12
+ }