pretzinger commited on
Commit
621e1a3
1 Parent(s): 68270be

fixed hidden states

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -24,8 +24,9 @@ index = faiss.IndexFlatL2(dimension)
24
 
25
  def embed_text(text):
26
  inputs = tokenizer(text, return_tensors="pt", truncation=True, padding="max_length", max_length=512)
27
- outputs = model(**inputs)
28
- return outputs.last_hidden_state.mean(dim=1).detach().numpy()
 
29
 
30
  # Example: Embed past conversation and store in FAISS
31
  past_conversation = "FDA approval for companion diagnostics requires careful documentation."
 
24
 
25
  def embed_text(text):
26
  inputs = tokenizer(text, return_tensors="pt", truncation=True, padding="max_length", max_length=512)
27
+ outputs = model(**inputs, output_hidden_states=True) # Ensure hidden states are returned
28
+ hidden_state = outputs.hidden_states[-1] # Get the last hidden state
29
+ return hidden_state.mean(dim=1).detach().numpy() # Take the mean across the sequence
30
 
31
  # Example: Embed past conversation and store in FAISS
32
  past_conversation = "FDA approval for companion diagnostics requires careful documentation."