Yoxas commited on
Commit
32db4b3
·
verified ·
1 Parent(s): 48dc91c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -19,14 +19,14 @@ data = dataset["train"]
19
  example_embedding = data[0]['embedding']
20
  print(f"Example embedding shape: {np.array(example_embedding).shape}")
21
 
22
- # Ensure embeddings are 2-dimensional
23
  def ensure_2d_embeddings(embeddings):
24
- embeddings = np.array(embeddings)
25
  if embeddings.ndim == 1:
26
  embeddings = embeddings.reshape(1, -1)
27
  return embeddings
28
 
29
- # Apply the function to ensure embeddings are 2-dimensional
30
  data = data.map(lambda example: {'embedding': ensure_2d_embeddings(example['embedding'])})
31
 
32
  data = data.add_faiss_index("embedding")
 
19
  example_embedding = data[0]['embedding']
20
  print(f"Example embedding shape: {np.array(example_embedding).shape}")
21
 
22
+ # Ensure embeddings are 2-dimensional and of type float32
23
  def ensure_2d_embeddings(embeddings):
24
+ embeddings = np.array(embeddings, dtype=np.float32)
25
  if embeddings.ndim == 1:
26
  embeddings = embeddings.reshape(1, -1)
27
  return embeddings
28
 
29
+ # Apply the function to ensure embeddings are 2-dimensional and of type float32
30
  data = data.map(lambda example: {'embedding': ensure_2d_embeddings(example['embedding'])})
31
 
32
  data = data.add_faiss_index("embedding")