earnings-calls-qa / utils /vector_index.py
awinml's picture
Upload 206 files (#1)
c49f0b0
raw
history blame
547 Bytes
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