Update model type in embedding generation to 'text-embedding-3-small' for consistency
Browse files
main.py
CHANGED
@@ -114,7 +114,7 @@ def generate_embedding(model, text: str, model_type: str) -> List[float]:
|
|
114 |
convert_to_tensor=True
|
115 |
)
|
116 |
embedding = np.array(t.Tensor.cpu(chunk_embedding)).tolist()
|
117 |
-
elif model_type == "
|
118 |
response = model.embeddings.create(
|
119 |
input=text,
|
120 |
model="text-embedding-3-small"
|
@@ -128,7 +128,7 @@ def generate_embedding(model, text: str, model_type: str) -> List[float]:
|
|
128 |
def search_query(client, st_model, query: str, df: pd.DataFrame, n: int = 1) -> List[Dict]:
|
129 |
# Generate embeddings for both models
|
130 |
mpnet_embedding = generate_embedding(st_model, query, "all-mpnet-base-v2")
|
131 |
-
openai_embedding = generate_embedding(client, query, "
|
132 |
|
133 |
# Calculate similarities
|
134 |
df['mpnet_similarities'] = df.all_mpnet_embedding.apply(
|
@@ -156,7 +156,7 @@ def search_query(client, st_model, query: str, df: pd.DataFrame, n: int = 1) ->
|
|
156 |
results.append({
|
157 |
"text": row["ext"],
|
158 |
"similarity": float(row["openai_similarities"]),
|
159 |
-
"model_type": "
|
160 |
})
|
161 |
|
162 |
return results
|
|
|
114 |
convert_to_tensor=True
|
115 |
)
|
116 |
embedding = np.array(t.Tensor.cpu(chunk_embedding)).tolist()
|
117 |
+
elif model_type == "text-embedding-3-small":
|
118 |
response = model.embeddings.create(
|
119 |
input=text,
|
120 |
model="text-embedding-3-small"
|
|
|
128 |
def search_query(client, st_model, query: str, df: pd.DataFrame, n: int = 1) -> List[Dict]:
|
129 |
# Generate embeddings for both models
|
130 |
mpnet_embedding = generate_embedding(st_model, query, "all-mpnet-base-v2")
|
131 |
+
openai_embedding = generate_embedding(client, query, "text-embedding-3-small")
|
132 |
|
133 |
# Calculate similarities
|
134 |
df['mpnet_similarities'] = df.all_mpnet_embedding.apply(
|
|
|
156 |
results.append({
|
157 |
"text": row["ext"],
|
158 |
"similarity": float(row["openai_similarities"]),
|
159 |
+
"model_type": "text-embedding-3-small"
|
160 |
})
|
161 |
|
162 |
return results
|