Spaces:
Runtime error
Runtime error
Update stri.py
Browse files
stri.py
CHANGED
@@ -16,10 +16,10 @@ model = AutoModel.from_pretrained(model_name, output_hidden_states=True)
|
|
16 |
books = pd.read_csv('book_6000.csv')
|
17 |
books.dropna(inplace=True)
|
18 |
|
19 |
-
|
20 |
books = books[books['annotation'].apply(lambda x: len(x.split()) >= 10)]
|
21 |
books.drop_duplicates(subset='title', keep='first', inplace=True)
|
22 |
-
books.reset_index(drop=True)
|
23 |
|
24 |
|
25 |
def data_preprocessing(text: str) -> str:
|
@@ -50,7 +50,7 @@ book_embeddings = []
|
|
50 |
for inputs, attention_masks in zip(input_ids, attention_mask):
|
51 |
with torch.no_grad():
|
52 |
book_embedding = model(inputs.unsqueeze(0), attention_mask=attention_masks.unsqueeze(0))
|
53 |
-
book_embedding = book_embedding[0][:, 0, :]
|
54 |
book_embeddings.append(np.squeeze(book_embedding))
|
55 |
|
56 |
# Определение запроса пользователя
|
|
|
16 |
books = pd.read_csv('book_6000.csv')
|
17 |
books.dropna(inplace=True)
|
18 |
|
19 |
+
|
20 |
books = books[books['annotation'].apply(lambda x: len(x.split()) >= 10)]
|
21 |
books.drop_duplicates(subset='title', keep='first', inplace=True)
|
22 |
+
books = books.reset_index(drop=True)
|
23 |
|
24 |
|
25 |
def data_preprocessing(text: str) -> str:
|
|
|
50 |
for inputs, attention_masks in zip(input_ids, attention_mask):
|
51 |
with torch.no_grad():
|
52 |
book_embedding = model(inputs.unsqueeze(0), attention_mask=attention_masks.unsqueeze(0))
|
53 |
+
book_embedding = book_embedding[0][:, 0, :]#.detach().cpu().numpy()
|
54 |
book_embeddings.append(np.squeeze(book_embedding))
|
55 |
|
56 |
# Определение запроса пользователя
|