Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,7 @@ from torch import Tensor
|
|
| 9 |
from transformers import AutoTokenizer, AutoModel
|
| 10 |
from sklearn.metrics.pairwise import cosine_similarity
|
| 11 |
|
| 12 |
-
import
|
| 13 |
|
| 14 |
|
| 15 |
def average_pool(last_hidden_states: Tensor,
|
|
@@ -65,7 +65,8 @@ with gr.Blocks() as demo:
|
|
| 65 |
if str(idx) == n.split(".")[0]:
|
| 66 |
df_idx = int(n.split(" // ")[-1])
|
| 67 |
print(df_idx)
|
| 68 |
-
article = df.iloc[df_idx]['text']
|
|
|
|
| 69 |
chat_history.append((message, f"contents of {n}:\n{article}"))
|
| 70 |
return "", chat_history
|
| 71 |
print("nothing found")
|
|
|
|
| 9 |
from transformers import AutoTokenizer, AutoModel
|
| 10 |
from sklearn.metrics.pairwise import cosine_similarity
|
| 11 |
|
| 12 |
+
import re
|
| 13 |
|
| 14 |
|
| 15 |
def average_pool(last_hidden_states: Tensor,
|
|
|
|
| 65 |
if str(idx) == n.split(".")[0]:
|
| 66 |
df_idx = int(n.split(" // ")[-1])
|
| 67 |
print(df_idx)
|
| 68 |
+
article = df.iloc[df_idx]['text']
|
| 69 |
+
article = re.sub(r'(===?=?[A-Z ].+?===?=?)', r'\n\n\1\n', article)
|
| 70 |
chat_history.append((message, f"contents of {n}:\n{article}"))
|
| 71 |
return "", chat_history
|
| 72 |
print("nothing found")
|