kambris commited on
Commit
8c80330
·
verified ·
1 Parent(s): 3f0f6de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -15,7 +15,11 @@ emotion_classifier = pipeline("text-classification", model=emotion_model, tokeni
15
 
16
  # Function to generate embeddings using AraBERT
17
  def generate_embeddings(texts):
18
- # Tokenize the list of texts using the tokenizer
 
 
 
 
19
  inputs = bert_tokenizer(texts, return_tensors="pt", padding=True, truncation=False, max_length=512)
20
 
21
  # Split large sequences into chunks of size 512
 
15
 
16
  # Function to generate embeddings using AraBERT
17
  def generate_embeddings(texts):
18
+ # Ensure texts is a list of strings
19
+ if isinstance(texts, str): # If single string, convert to list
20
+ texts = [texts]
21
+
22
+ # Tokenize the list of strings (ensure all are strings)
23
  inputs = bert_tokenizer(texts, return_tensors="pt", padding=True, truncation=False, max_length=512)
24
 
25
  # Split large sequences into chunks of size 512