Spaces:
Runtime error
Runtime error
Update stri.py
Browse files
stri.py
CHANGED
@@ -45,7 +45,7 @@ length = 512
|
|
45 |
query = st.text_input("Введите запрос")
|
46 |
|
47 |
if st.button('Сгенерировать'):
|
48 |
-
with open("
|
49 |
book_embeddings = pickle.load(f)
|
50 |
|
51 |
query_tokens = tokenizer.encode_plus(
|
@@ -58,11 +58,11 @@ if st.button('Сгенерировать'):
|
|
58 |
|
59 |
with torch.no_grad():
|
60 |
query_outputs = model(**query_tokens)
|
61 |
-
query_hidden_states = query_outputs.hidden_states
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
|
|
|
66 |
# Вычисление косинусного расстояния между эмбеддингом запроса и каждой аннотацией
|
67 |
cosine_similarities = torch.nn.functional.cosine_similarity(
|
68 |
query_embedding.squeeze(0),
|
|
|
45 |
query = st.text_input("Введите запрос")
|
46 |
|
47 |
if st.button('Сгенерировать'):
|
48 |
+
with open("book_embeddingsN.pkl", "rb") as f:
|
49 |
book_embeddings = pickle.load(f)
|
50 |
|
51 |
query_tokens = tokenizer.encode_plus(
|
|
|
58 |
|
59 |
with torch.no_grad():
|
60 |
query_outputs = model(**query_tokens)
|
61 |
+
query_hidden_states = query_outputs.hidden_states[-1][:,0,:]
|
62 |
+
query_hidden_states = torch.nn.functional.normalize(query_hidden_states)query_hidden_states = query_outputs.hidden_states[-1][:,0,:]
|
63 |
+
query_hidden_states = torch.nn.functional.normalize(query_hidden_states)
|
|
|
64 |
|
65 |
+
|
66 |
# Вычисление косинусного расстояния между эмбеддингом запроса и каждой аннотацией
|
67 |
cosine_similarities = torch.nn.functional.cosine_similarity(
|
68 |
query_embedding.squeeze(0),
|