JasonTPhillipsJr commited on
Commit
f82dac8
1 Parent(s): b23060e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -40,9 +40,18 @@ spaBERT_model.to(device)
40
  spaBERT_model.eval()
41
 
42
 
43
-
44
-
45
-
 
 
 
 
 
 
 
 
 
46
 
47
 
48
 
 
40
  spaBERT_model.eval()
41
 
42
 
43
+ #Get BERT Embedding for review
44
+ def get_bert_embedding(review_text)
45
+ #tokenize review
46
+ inputs = bert_tokenizer(review_text, return_tensors='pt', padding=True, truncation=True).to(device)
47
+
48
+ # Forward pass through the BERT model
49
+ with torch.no_grad():
50
+ outputs = bert_model(**inputs)
51
+
52
+ # Extract embeddings from the last hidden state
53
+ embeddings = outputs.last_hidden_state[:, 0, :].detach() #CLS Token
54
+ return embeddings
55
 
56
 
57