Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -49,12 +49,15 @@ def last_token_pool(last_hidden_states: Tensor, attention_mask: Tensor) -> Tenso
|
|
| 49 |
|
| 50 |
@spaces.GPU
|
| 51 |
def compute_embeddings(selected_task, *input_texts):
|
| 52 |
-
|
| 53 |
-
if selected_task:
|
| 54 |
-
|
| 55 |
-
processed_texts = [f'Instruct: {
|
| 56 |
else:
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
| 58 |
task = tasks[selected_task]
|
| 59 |
batch_dict = tokenizer(processed_texts, max_length=max_length - 1, return_attention_mask=False, padding=False, truncation=True)
|
| 60 |
batch_dict['input_ids'] = [input_ids + [tokenizer.eos_token_id] for input_ids in batch_dict['input_ids']]
|
|
|
|
| 49 |
|
| 50 |
@spaces.GPU
|
| 51 |
def compute_embeddings(selected_task, *input_texts):
|
| 52 |
+
|
| 53 |
+
if selected_task == "None":
|
| 54 |
+
# Use the system prompt if 'None' is selected
|
| 55 |
+
processed_texts = [f'Instruct: {system_prompt}\nQuery: {input_text}']
|
| 56 |
else:
|
| 57 |
+
# Use the task description from the tasks dictionary
|
| 58 |
+
task_description = tasks[selected_task]
|
| 59 |
+
processed_texts = [f'Instruct: {task_description}\nQuery: {input_text}']
|
| 60 |
+
|
| 61 |
task = tasks[selected_task]
|
| 62 |
batch_dict = tokenizer(processed_texts, max_length=max_length - 1, return_attention_mask=False, padding=False, truncation=True)
|
| 63 |
batch_dict['input_ids'] = [input_ids + [tokenizer.eos_token_id] for input_ids in batch_dict['input_ids']]
|