Spaces:
Paused
Paused
Commit
·
a2e05fb
1
Parent(s):
eb6c6fa
Update mapper.py
Browse files
mapper.py
CHANGED
@@ -4,12 +4,12 @@ class Mapper:
|
|
4 |
def __init__(self, repo: str, model: str):
|
5 |
self.__model = SentenceTransformer(f"{repo}/{model}")
|
6 |
|
7 |
-
def __call__(self, query: str,
|
8 |
query_emb = self.__model.encode(query)
|
9 |
data_emb = self.__model.encode(data)
|
10 |
|
11 |
-
scores = util.dot_score(query_emb, data_emb)[0].cpu().tolist()
|
12 |
-
data_score_pairs = list(zip(data, scores))
|
13 |
|
14 |
return sorted(
|
15 |
data_score_pairs,
|
|
|
4 |
def __init__(self, repo: str, model: str):
|
5 |
self.__model = SentenceTransformer(f"{repo}/{model}")
|
6 |
|
7 |
+
def __call__(self, query: str, data: list[str]):
|
8 |
query_emb = self.__model.encode(query)
|
9 |
data_emb = self.__model.encode(data)
|
10 |
|
11 |
+
scores: list[float] = util.dot_score(query_emb, data_emb)[0].cpu().tolist()
|
12 |
+
data_score_pairs = list(zip(range(0, len(data)), scores))
|
13 |
|
14 |
return sorted(
|
15 |
data_score_pairs,
|