Skip to content

Commit

Permalink
refine token similarity (#2824)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?


### Type of change

- [x] Performance Improvement
  • Loading branch information
KevinHuSh authored Oct 14, 2024
1 parent 8e5efcc commit b164116
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion agent/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def get_history(self, window_size):
convs = []
for role, obj in self.history[(window_size + 1) * -1:]:
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

def add_user_input(self, question):
Expand Down
7 changes: 2 additions & 5 deletions rag/nlp/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,5 @@ def similarity(self, qtwt, dtwt):
s += v # * dtwt[k]
q = 1e-9
for k, v in qtwt.items():
q += v # * v
#d = 1e-9
# 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)
q += v
return s / q

0 comments on commit b164116

Please sign in to comment.