mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-06-04 11:24:00 +08:00
refine token similarity (#2824)
### What problem does this PR solve? ### Type of change - [x] Performance Improvement
This commit is contained in:
parent
8e5efcc47f
commit
b164116277
@ -262,7 +262,7 @@ class Canvas(ABC):
|
|||||||
convs = []
|
convs = []
|
||||||
for role, obj in self.history[(window_size + 1) * -1:]:
|
for role, obj in self.history[(window_size + 1) * -1:]:
|
||||||
convs.append({"role": role, "content": (obj if role == "user" else
|
convs.append({"role": role, "content": (obj if role == "user" else
|
||||||
'\n'.join(pd.DataFrame(obj)['content']))})
|
'\n'.join([str(s) for s in pd.DataFrame(obj)['content']]))})
|
||||||
return convs
|
return convs
|
||||||
|
|
||||||
def add_user_input(self, question):
|
def add_user_input(self, question):
|
||||||
|
@ -186,8 +186,5 @@ class EsQueryer:
|
|||||||
s += v # * dtwt[k]
|
s += v # * dtwt[k]
|
||||||
q = 1e-9
|
q = 1e-9
|
||||||
for k, v in qtwt.items():
|
for k, v in qtwt.items():
|
||||||
q += v # * v
|
q += v
|
||||||
#d = 1e-9
|
return s / q
|
||||||
# for k, v in dtwt.items():
|
|
||||||
# d += v * v
|
|
||||||
return s / q / max(1, math.sqrt(math.log10(max(len(qtwt.keys()), len(dtwt.keys())))))# math.sqrt(q) / math.sqrt(d)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user