|
|
|
|
|
|
|
|
# |
|
|
# |
|
|
import re |
|
|
import re |
|
|
import threading |
|
|
import threading |
|
|
|
|
|
from collections.abc import Iterable |
|
|
from urllib.parse import urljoin |
|
|
from urllib.parse import urljoin |
|
|
|
|
|
|
|
|
import requests |
|
|
import requests |
|
|
|
|
|
|
|
|
else: |
|
|
else: |
|
|
scores = self._model.compute_score(batch_pairs, max_length=max_length) |
|
|
scores = self._model.compute_score(batch_pairs, max_length=max_length) |
|
|
scores = sigmoid(np.array(scores)).tolist() |
|
|
scores = sigmoid(np.array(scores)).tolist() |
|
|
|
|
|
if not isinstance(scores, Iterable): |
|
|
|
|
|
scores = [scores] |
|
|
return scores |
|
|
return scores |
|
|
|
|
|
|
|
|
def similarity(self, query: str, texts: list): |
|
|
def similarity(self, query: str, texts: list): |