Skip to content

Commit

Permalink
chore: Optimize the log display.
Browse files Browse the repository at this point in the history
  • Loading branch information
xixihahaliu committed Jun 5, 2024
1 parent dc68151 commit 349825a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
5 changes: 1 addition & 4 deletions qanything_kernel/connector/rerank/rerank_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,7 @@ def tokenize_preproc(self,
return merge_inputs, merge_inputs_idxs

@get_time
def predict(self,
query: str,
passages: List[str],
):
def get_rerank(self, query: str, passages: List[str]):
tot_batches, merge_inputs_idxs_sort = self.tokenize_preproc(query, passages)

tot_scores = []
Expand Down
2 changes: 1 addition & 1 deletion qanything_kernel/core/local_doc_qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def rerank_documents(self, query, source_documents):
if num_tokens(query) > 300: # tokens数量超过300时不使用local rerank
return source_documents

scores = self.local_rerank_backend.predict(query, [doc.page_content for doc in source_documents])
scores = self.local_rerank_backend.get_rerank(query, [doc.page_content for doc in source_documents])
debug_logger.info(f"rerank scores: {scores}")
for idx, score in enumerate(scores):
source_documents[idx].metadata['score'] = score
Expand Down
1 change: 1 addition & 0 deletions qanything_kernel/qanything_server/sanic_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ async def init_local_doc_qa(app, loop):
@app.after_server_start
async def print_info(app, loop):
print("已启动后端服务,请复制[ http://0.0.0.0:8777/qanything/ ]到浏览器进行测试。", flush=True)
print("详细调试日志请查看 logs/debug_logs/debug.log,问答日志请查看logs/qa_logs/qa.log", flush=True)
# os.system("tail -f logs/debug_logs/debug.log")

app.add_route(document, "/api/docs", methods=['GET'])
Expand Down
2 changes: 1 addition & 1 deletion qanything_kernel/utils/general_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def inner(*arg, **kwargs):
s_time = time.time()
res = func(*arg, **kwargs)
e_time = time.time()
print('函数 {} 执行耗时: {} 秒'.format(func.__name__, e_time - s_time))
debug_logger.info('函数 {} 执行耗时: {} 秒'.format(func.__name__, e_time - s_time))
return res

return inner
Expand Down

0 comments on commit 349825a

Please sign in to comment.