mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-26 17:16:52 +08:00
Fix: metadata issue & graphrag speeding up. (#12113)
### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --------- Co-authored-by: Liu An <asiro@qq.com>
This commit is contained in:
@ -406,7 +406,7 @@ async def async_chat(dialog, messages, stream=True, **kwargs):
|
|||||||
dialog.vector_similarity_weight,
|
dialog.vector_similarity_weight,
|
||||||
doc_ids=attachments,
|
doc_ids=attachments,
|
||||||
top=dialog.top_k,
|
top=dialog.top_k,
|
||||||
aggs=False,
|
aggs=True,
|
||||||
rerank_mdl=rerank_mdl,
|
rerank_mdl=rerank_mdl,
|
||||||
rank_feature=label_question(" ".join(questions), kbs),
|
rank_feature=label_question(" ".join(questions), kbs),
|
||||||
)
|
)
|
||||||
@ -769,7 +769,7 @@ async def async_ask(question, kb_ids, tenant_id, chat_llm_name=None, search_conf
|
|||||||
vector_similarity_weight=search_config.get("vector_similarity_weight", 0.3),
|
vector_similarity_weight=search_config.get("vector_similarity_weight", 0.3),
|
||||||
top=search_config.get("top_k", 1024),
|
top=search_config.get("top_k", 1024),
|
||||||
doc_ids=doc_ids,
|
doc_ids=doc_ids,
|
||||||
aggs=False,
|
aggs=True,
|
||||||
rerank_mdl=rerank_mdl,
|
rerank_mdl=rerank_mdl,
|
||||||
rank_feature=label_question(question, kbs)
|
rank_feature=label_question(question, kbs)
|
||||||
)
|
)
|
||||||
|
|||||||
@ -97,7 +97,7 @@ class TenantLLMService(CommonService):
|
|||||||
if llm_type == LLMType.EMBEDDING.value:
|
if llm_type == LLMType.EMBEDDING.value:
|
||||||
mdlnm = tenant.embd_id if not llm_name else llm_name
|
mdlnm = tenant.embd_id if not llm_name else llm_name
|
||||||
elif llm_type == LLMType.SPEECH2TEXT.value:
|
elif llm_type == LLMType.SPEECH2TEXT.value:
|
||||||
mdlnm = tenant.asr_id
|
mdlnm = tenant.asr_id if not llm_name else llm_name
|
||||||
elif llm_type == LLMType.IMAGE2TEXT.value:
|
elif llm_type == LLMType.IMAGE2TEXT.value:
|
||||||
mdlnm = tenant.img2txt_id if not llm_name else llm_name
|
mdlnm = tenant.img2txt_id if not llm_name else llm_name
|
||||||
elif llm_type == LLMType.CHAT.value:
|
elif llm_type == LLMType.CHAT.value:
|
||||||
|
|||||||
@ -71,18 +71,17 @@ class Extractor:
|
|||||||
_, system_msg = message_fit_in([{"role": "system", "content": system}], int(self._llm.max_length * 0.92))
|
_, system_msg = message_fit_in([{"role": "system", "content": system}], int(self._llm.max_length * 0.92))
|
||||||
response = ""
|
response = ""
|
||||||
for attempt in range(3):
|
for attempt in range(3):
|
||||||
|
|
||||||
if task_id:
|
if task_id:
|
||||||
if has_canceled(task_id):
|
if has_canceled(task_id):
|
||||||
logging.info(f"Task {task_id} cancelled during entity resolution candidate processing.")
|
logging.info(f"Task {task_id} cancelled during entity resolution candidate processing.")
|
||||||
raise TaskCanceledException(f"Task {task_id} was cancelled")
|
raise TaskCanceledException(f"Task {task_id} was cancelled")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = asyncio.run(self._llm.async_chat(system_msg[0]["content"], hist, conf))
|
response = asyncio.run(self._llm.async_chat(system_msg[0]["content"], hist, conf))
|
||||||
response = re.sub(r"^.*</think>", "", response, flags=re.DOTALL)
|
response = re.sub(r"^.*</think>", "", response, flags=re.DOTALL)
|
||||||
if response.find("**ERROR**") >= 0:
|
if response.find("**ERROR**") >= 0:
|
||||||
raise Exception(response)
|
raise Exception(response)
|
||||||
set_llm_cache(self._llm.llm_name, system, response, history, gen_conf)
|
set_llm_cache(self._llm.llm_name, system, response, history, gen_conf)
|
||||||
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.exception(e)
|
logging.exception(e)
|
||||||
if attempt == 2:
|
if attempt == 2:
|
||||||
|
|||||||
@ -198,7 +198,7 @@ async def run_graphrag_for_kb(
|
|||||||
|
|
||||||
for d in raw_chunks:
|
for d in raw_chunks:
|
||||||
content = d["content_with_weight"]
|
content = d["content_with_weight"]
|
||||||
if num_tokens_from_string(current_chunk + content) < 1024:
|
if num_tokens_from_string(current_chunk + content) < 4096:
|
||||||
current_chunk += content
|
current_chunk += content
|
||||||
else:
|
else:
|
||||||
if current_chunk:
|
if current_chunk:
|
||||||
|
|||||||
@ -78,10 +78,6 @@ class GraphExtractor(Extractor):
|
|||||||
hint_prompt = self._entity_extract_prompt.format(**self._context_base, input_text=content)
|
hint_prompt = self._entity_extract_prompt.format(**self._context_base, input_text=content)
|
||||||
|
|
||||||
gen_conf = {}
|
gen_conf = {}
|
||||||
final_result = ""
|
|
||||||
glean_result = ""
|
|
||||||
if_loop_result = ""
|
|
||||||
history = []
|
|
||||||
logging.info(f"Start processing for {chunk_key}: {content[:25]}...")
|
logging.info(f"Start processing for {chunk_key}: {content[:25]}...")
|
||||||
if self.callback:
|
if self.callback:
|
||||||
self.callback(msg=f"Start processing for {chunk_key}: {content[:25]}...")
|
self.callback(msg=f"Start processing for {chunk_key}: {content[:25]}...")
|
||||||
|
|||||||
@ -380,7 +380,7 @@ async def build_chunks(task, progress_callback):
|
|||||||
cached = await gen_metadata(chat_mdl,
|
cached = await gen_metadata(chat_mdl,
|
||||||
metadata_schema(task["parser_config"]["metadata"]),
|
metadata_schema(task["parser_config"]["metadata"]),
|
||||||
d["content_with_weight"])
|
d["content_with_weight"])
|
||||||
set_llm_cache(chat_mdl.llm_name, d["content_with_weight"], cached, "metadata")
|
set_llm_cache(chat_mdl.llm_name, d["content_with_weight"], cached, "metadata", {})
|
||||||
if cached:
|
if cached:
|
||||||
d["metadata_obj"] = cached
|
d["metadata_obj"] = cached
|
||||||
tasks = []
|
tasks = []
|
||||||
|
|||||||
Reference in New Issue
Block a user