Spaces:
Sleeping
Sleeping
import json | |
import numpy as np | |
def create_dense_embeddings( | |
query, | |
model, | |
instruction="Represent the financial question for retrieving supporting documents:", | |
): | |
# Fetching embedding from API for Instructor | |
json_output_embedding = model.predict( | |
instruction, | |
query, | |
api_name="/predict", | |
) | |
json_file = open(json_output_embedding, "r") | |
json_dict = json.load(json_file) | |
dense_array = np.array(json_dict["data"], dtype=np.float64) | |
dense_emb = dense_array.tolist() | |
return dense_emb |