Cyantist8208 commited on
Commit
d94f39b
·
1 Parent(s): 083e441

k out of range

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -120,7 +120,7 @@ def answer(system: str, context: str, question: str, user_id="demo", history="No
120
  context_list = [context]
121
  # 1. Retrieve top-k similar passages
122
  if history == "Some":
123
- q_vec = embed(question).T.cpu()
124
  store = kb[user_id]
125
  sims = torch.matmul(store["vecs"], q_vec) # [N]
126
  if sims.numel() == 0:
@@ -160,7 +160,7 @@ def answer(system: str, context: str, question: str, user_id="demo", history="No
160
 
161
 
162
  except Exception as e:
163
- return f"Error in app.py: {e}"
164
  finally:
165
  torch.cuda.empty_cache()
166
 
 
120
  context_list = [context]
121
  # 1. Retrieve top-k similar passages
122
  if history == "Some":
123
+ q_vec = embed(question).view(-1).cpu()
124
  store = kb[user_id]
125
  sims = torch.matmul(store["vecs"], q_vec) # [N]
126
  if sims.numel() == 0:
 
160
 
161
 
162
  except Exception as e:
163
+ return f"Error in app.py: {e}, k={k}, q_vec.shape={q_vec.shape if 'q_vec' in locals() else 'N/A'}"
164
  finally:
165
  torch.cuda.empty_cache()
166