Skip to content

Commit

Permalink
更新README
Browse files Browse the repository at this point in the history
  • Loading branch information
fengwm64 committed Sep 6, 2024
1 parent 17ef7c1 commit 7cdac4f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
# Financial_agent
# Financial_agent

## 简介
根据用户问题自主查询基金表数据库或检索公司招股书文档库的智能LLM系统

## 功能框架

- **意图识别**:基于ICL技术和提示词工程,将用户意图准确分为数据查询(NL2SQL任务)和文本检索(RAG任务),同时对文本检索任务提取公司名称和关键词。

- **数据查询**:使用RAG-ICL技术,并引入反馈重试机制,通过SQL查询报错和COT技术构造提示词,提升数据查询任务的准确度,并对提示词进行调整以对齐用户问题中关于保留位数的要求。

- **文本理解**:设计基于BM25的两级检索机制,首先通过公司名称检索得到包含公司信息的文档名,然后使用关键词检索获取相关片段,最后构造提示词调用大模型生成回答。

![](http://www.linfeng-coding.top:85/i/2024/09/06/xvid69.png)
6 changes: 4 additions & 2 deletions modules/Sql_Task.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def run(self, new_question):
# 找出最相似的2-4个问题及其对应的SQL
exps = self.find_most_similar_questions(new_question)
q_exps, sql_exps, query_result_exps, final_response_exps = zip(*exps)
logging.info(q_exps)
logging.info(sql_exps)

# 生成初始的SQL
prompt = Prompt.create_sql_icl_prompt(new_question, zip(q_exps, sql_exps))
Expand All @@ -48,11 +50,11 @@ def run(self, new_question):
sql_query = self.extract_sql_code(llm_first_respon)

# 尝试执行SQL查询
for attempt in range(4): # 最多尝试4次
for attempt in range(3): # 最多尝试3次
try:
logging.info(f"尝试 {attempt + 1}: 执行SQL查询: {sql_query}")
query_result = self.db.select(sql_query)
logging.info(f"SQL查询成功: {sql_query}")
logging.info(f"SQL查询成功: {query_result}")

# 返回提示词
return Prompt.create_final_icl_prompt(new_question, query_result, zip(q_exps, query_result_exps, final_response_exps)), sql_query
Expand Down

0 comments on commit 7cdac4f

Please sign in to comment.