Yoxas commited on
Commit
f7cf69d
·
verified ·
1 Parent(s): efc571a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -19,19 +19,19 @@ data = dataset["train"]
19
  # Convert the string embeddings to numerical arrays
20
  def convert_and_ensure_2d_embeddings(example):
21
  # Convert the string to a numpy array
22
- embedding_str = example['Abstract']
23
  embedding_str = embedding_str.replace('\n', ' ')
24
  embedding_list = list(map(float, embedding_str.strip("[]").split()))
25
  embeddings = np.array(embedding_list, dtype=np.float32)
26
  # Ensure the embeddings are 2-dimensional
27
  if embeddings.ndim == 1:
28
  embeddings = embeddings.reshape(1, -1)
29
- return {'Abstract': embeddings}
30
 
31
  # Apply the function to ensure embeddings are 2-dimensional and of type float32
32
  data = data.map(convert_and_ensure_2d_embeddings)
33
 
34
- data = data.add_faiss_index("Abstract")
35
 
36
  model_id = "meta-llama/Meta-Llama-3-8B-Instruct"
37
 
 
19
  # Convert the string embeddings to numerical arrays
20
  def convert_and_ensure_2d_embeddings(example):
21
  # Convert the string to a numpy array
22
+ embedding_str = example['embedding']
23
  embedding_str = embedding_str.replace('\n', ' ')
24
  embedding_list = list(map(float, embedding_str.strip("[]").split()))
25
  embeddings = np.array(embedding_list, dtype=np.float32)
26
  # Ensure the embeddings are 2-dimensional
27
  if embeddings.ndim == 1:
28
  embeddings = embeddings.reshape(1, -1)
29
+ return {'embedding': embeddings}
30
 
31
  # Apply the function to ensure embeddings are 2-dimensional and of type float32
32
  data = data.map(convert_and_ensure_2d_embeddings)
33
 
34
+ data = data.add_faiss_index("embedding")
35
 
36
  model_id = "meta-llama/Meta-Llama-3-8B-Instruct"
37