ragflow icon indicating copy to clipboard operation
ragflow copied to clipboard

[Question]: The `Extract knowledge graph` General and Light Problem

Open emocat17 opened this issue 9 months ago • 10 comments

Describe your problem

Thank you for taking the time to look at my question!

When I choose to Extract knowledge graph ,and Method:Light, the log :


2025-03-06 19:32:25 2025-03-06 19:32:25,461 INFO     19 set_progress(43cda7aafa7e11ef833f0242ac120002), progress: 0.5982456140350877, progress_msg: 19:32:25 Entities extraction of chunk 15 56/57 done, 10 nodes, 1 edges, 16370 tokens.
2025-03-06 19:32:25 2025-03-06 19:32:25,551 INFO     19 set_progress(43cda7aafa7e11ef833f0242ac120002), progress: -1, progress_msg: 19:32:25 [ERROR][Exception]: Exceptions from Trio nursery (1 sub-exception)
2025-03-06 19:32:25 2025-03-06 19:32:25,574 ERROR    19 handle_task got exception for task {"id": "43cda7aafa7e11ef833f0242ac120002", "doc_id": "4d505af4fa7c11efbcad0242ac120002", "from_page": 100000000, "to_page": 100000000, "retry_count": 0, "kb_id": "25e4434afa7c11ef8e8a0242ac120002", "parser_id": "naive", "parser_config": {"layout_recognize": "DeepDOC", "chunk_token_num": 128, "delimiter": "\\n!?;\u3002\uff1b\uff01\uff1f", "auto_keywords": 0, "auto_questions": 0, "html4excel": true, "raptor": {"use_raptor": false}, "graphrag": {"use_graphrag": true, "entity_types": ["organization", "person", "geo", "event", "category"], "method": "light", "resolution": true, "community": true}}, "name": "A Survey on Zero Trust Architecture  Challenges and Future.pdf", "type": "pdf", "location": "A Survey on Zero Trust Architecture  Challenges and Future.pdf", "size": 436754, "tenant_id": "50127440fa4311efb83b0242ac120006", "language": "English", "embd_id": "bge-m3:latest@Ollama", "pagerank": 0, "kb_parser_config": {"layout_recognize": "DeepDOC", "chunk_token_num": 128, "delimiter": "\\n!?;\u3002\uff1b\uff01\uff1f", "auto_keywords": 0, "auto_questions": 0, "html4excel": true, "raptor": {"use_raptor": false}, "graphrag": {"use_graphrag": true, "entity_types": ["organization", "person", "geo", "event", "category"], "method": "light", "resolution": true, "community": true}}, "img2txt_id": "deepseek-r1:1.5b@Ollama", "asr_id": "", "llm_id": "Pro/deepseek-ai/DeepSeek-R1-Distill-Qwen-7B@SILICONFLOW", "update_time": 1741260568217, "task_type": "graphrag"}
2025-03-06 19:32:25   + Exception Group Traceback (most recent call last):
2025-03-06 19:32:25   |   File "/ragflow/rag/svr/task_executor.py", line 617, in handle_task
2025-03-06 19:32:25   |     await do_handle_task(task)
2025-03-06 19:32:25   |   File "/ragflow/rag/svr/task_executor.py", line 529, in do_handle_task
2025-03-06 19:32:25   |     await run_graphrag(task, chat_model, task_language, embedding_model, progress_callback)
2025-03-06 19:32:25   |   File "/ragflow/rag/svr/task_executor.py", line 471, in run_graphrag
2025-03-06 19:32:25   |     await dealer()
2025-03-06 19:32:25   |   File "/ragflow/graphrag/general/index.py", line 62, in __call__
2025-03-06 19:32:25   |     ents, rels = await self.ext(self.chunks, self.callback)
2025-03-06 19:32:25   |   File "/ragflow/graphrag/general/extractor.py", line 101, in __call__
2025-03-06 19:32:25   |     async with trio.open_nursery() as nursery:
2025-03-06 19:32:25   |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_core/_run.py", line 1058, in __aexit__
2025-03-06 19:32:25   |     raise combined_error_from_nursery
2025-03-06 19:32:25   | exceptiongroup.ExceptionGroup: Exceptions from Trio nursery (1 sub-exception)
2025-03-06 19:32:25   +-+---------------- 1 ----------------
2025-03-06 19:32:25     | Traceback (most recent call last):
2025-03-06 19:32:25     |   File "/ragflow/graphrag/light/graph_extractor.py", line 108, in _process_single_content
2025-03-06 19:32:25     |     if_loop_result = await trio.to_thread.run_sync(lambda: self._chat(self._if_loop_prompt, history, gen_conf))
2025-03-06 19:32:25     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 447, in to_thread_run_sync
2025-03-06 19:32:25     |     return msg_from_thread.unwrap()
2025-03-06 19:32:25     |   File "/ragflow/.venv/lib/python3.10/site-packages/outcome/_impl.py", line 213, in unwrap
2025-03-06 19:32:25     |     raise captured_error
2025-03-06 19:32:25     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 373, in do_release_then_return_result
2025-03-06 19:32:25     |     return result.unwrap()
2025-03-06 19:32:25     |   File "/ragflow/.venv/lib/python3.10/site-packages/outcome/_impl.py", line 213, in unwrap
2025-03-06 19:32:25     |     raise captured_error
2025-03-06 19:32:25     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 392, in worker_fn
2025-03-06 19:32:25     |     ret = context.run(sync_fn, *args)
2025-03-06 19:32:25     |   File "/ragflow/graphrag/light/graph_extractor.py", line 108, in <lambda>
2025-03-06 19:32:25     |     if_loop_result = await trio.to_thread.run_sync(lambda: self._chat(self._if_loop_prompt, history, gen_conf))
2025-03-06 19:32:25     |   File "/ragflow/graphrag/general/extractor.py", line 64, in _chat
2025-03-06 19:32:25     |     raise Exception(response)
2025-03-06 19:32:25     | Exception: **ERROR**: Error code: 429 - {'message': 'Request was rejected due to rate limiting. Details: TPM limit reached.', 'data': None}
2025-03-06 19:32:25     +------------------------------------
2025-03-06 19:32:30 2025-03-06 19:32:30,792 INFO     19 HTTP Request: POST https://api.siliconflow.cn/v1/chat/completions "HTTP/1.1 200 OK"
2025-03-06 19:32:46 2025-03-06 19:32:46,714 INFO     19 task_consumer_0 reported heartbeat: {"name": "task_consumer_0", "now": "2025-03-06T19:32:46.713+08:00", "boot_at": "2025-03-06T18:52:04.607+08:00", "pending": 3, "lag": 0, "done": 15, "failed": 10, "current": {"79bdd74afa7e11ef833f0242ac120002": {"id": "79bdd74afa7e11ef833f0242ac120002", "doc_id": "4d3a3b70fa7c11efbcad0242ac120002", "from_page": 100000000, "to_page": 100000000, "retry_count": 0, "kb_id": "25e4434afa7c11ef8e8a0242ac120002", "parser_id": "naive", "parser_config": {"layout_recognize": "DeepDOC", "chunk_token_num": 128, "delimiter": "\\n!?;\u3002\uff1b\uff01\uff1f", "auto_keywords": 0, "auto_questions": 0, "html4excel": true, "raptor": {"use_raptor": false}, "graphrag": {"use_graphrag": true, "entity_types": ["organization", "person", "geo", "event", "category"], "method": "light", "resolution": true, "community": true}}, "name": "A Review and Comparative Analysis of Relevant Approaches of.pdf", "type": "pdf", "location": "A Review and Comparative Analysis of Relevant Approaches of.pdf", "size": 1153775, "tenant_id": "50127440fa4311efb83b0242ac120006", "language": "English", "embd_id": "bge-m3:latest@Ollama", "pagerank": 0, "kb_parser_config": {"layout_recognize": "DeepDOC", "chunk_token_num": 128, "delimiter": "\\n!?;\u3002\uff1b\uff01\uff1f", "auto_keywords": 0, "auto_questions": 0, "html4excel": true, "raptor": {"use_raptor": false}, "graphrag": {"use_graphrag": true, "entity_types": ["organization", "person", "geo", "event", "category"], "method": "light", "resolution": true, "community": true}}, "img2txt_id": "deepseek-r1:1.5b@Ollama", "asr_id": "", "llm_id": "Pro/deepseek-ai/DeepSeek-R1-Distill-Qwen-7B@SILICONFLOW", "update_time": 1741260658710, "task_type": "graphrag"}}}
2025-03-06 19:32:47 2025-03-06 19:32:47,752 INFO     19 HTTP Request: POST https://api.siliconflow.cn/v1/chat/completions "HTTP/1.1 200 OK"
2025-03-06 19:32:48 2025-03-06 19:32:48,234 INFO     19 set_progress(79bdd74afa7e11ef833f0242ac120002), progress: -1, progress_msg: 19:32:48 [ERROR][Exception]: Exceptions from Trio nursery (10 sub-exceptions)
2025-03-06 19:32:48 2025-03-06 19:32:48,257 ERROR    19 handle_task got exception for task {"id": "79bdd74afa7e11ef833f0242ac120002", "doc_id": "4d3a3b70fa7c11efbcad0242ac120002", "from_page": 100000000, "to_page": 100000000, "retry_count": 0, "kb_id": "25e4434afa7c11ef8e8a0242ac120002", "parser_id": "naive", "parser_config": {"layout_recognize": "DeepDOC", "chunk_token_num": 128, "delimiter": "\\n!?;\u3002\uff1b\uff01\uff1f", "auto_keywords": 0, "auto_questions": 0, "html4excel": true, "raptor": {"use_raptor": false}, "graphrag": {"use_graphrag": true, "entity_types": ["organization", "person", "geo", "event", "category"], "method": "light", "resolution": true, "community": true}}, "name": "A Review and Comparative Analysis of Relevant Approaches of.pdf", "type": "pdf", "location": "A Review and Comparative Analysis of Relevant Approaches of.pdf", "size": 1153775, "tenant_id": "50127440fa4311efb83b0242ac120006", "language": "English", "embd_id": "bge-m3:latest@Ollama", "pagerank": 0, "kb_parser_config": {"layout_recognize": "DeepDOC", "chunk_token_num": 128, "delimiter": "\\n!?;\u3002\uff1b\uff01\uff1f", "auto_keywords": 0, "auto_questions": 0, "html4excel": true, "raptor": {"use_raptor": false}, "graphrag": {"use_graphrag": true, "entity_types": ["organization", "person", "geo", "event", "category"], "method": "light", "resolution": true, "community": true}}, "img2txt_id": "deepseek-r1:1.5b@Ollama", "asr_id": "", "llm_id": "Pro/deepseek-ai/DeepSeek-R1-Distill-Qwen-7B@SILICONFLOW", "update_time": 1741260658710, "task_type": "graphrag"}
2025-03-06 19:32:48   + Exception Group Traceback (most recent call last):
2025-03-06 19:32:48   |   File "/ragflow/rag/svr/task_executor.py", line 617, in handle_task
2025-03-06 19:32:48   |     await do_handle_task(task)
2025-03-06 19:32:48   |   File "/ragflow/rag/svr/task_executor.py", line 529, in do_handle_task
2025-03-06 19:32:48   |     await run_graphrag(task, chat_model, task_language, embedding_model, progress_callback)
2025-03-06 19:32:48   |   File "/ragflow/rag/svr/task_executor.py", line 471, in run_graphrag
2025-03-06 19:32:48   |     await dealer()
2025-03-06 19:32:48   |   File "/ragflow/graphrag/general/index.py", line 62, in __call__
2025-03-06 19:32:48   |     ents, rels = await self.ext(self.chunks, self.callback)
2025-03-06 19:32:48   |   File "/ragflow/graphrag/general/extractor.py", line 101, in __call__
2025-03-06 19:32:48   |     async with trio.open_nursery() as nursery:
2025-03-06 19:32:48   |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_core/_run.py", line 1058, in __aexit__
2025-03-06 19:32:48   |     raise combined_error_from_nursery
2025-03-06 19:32:48   | exceptiongroup.ExceptionGroup: Exceptions from Trio nursery (10 sub-exceptions)
2025-03-06 19:32:48   +-+---------------- 1 ----------------
2025-03-06 19:32:48     | Traceback (most recent call last):
2025-03-06 19:32:48     |   File "/ragflow/graphrag/light/graph_extractor.py", line 100, in _process_single_content
2025-03-06 19:32:48     |     glean_result = await trio.to_thread.run_sync(lambda: self._chat(hint_prompt, history, gen_conf))
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 447, in to_thread_run_sync
2025-03-06 19:32:48     |     return msg_from_thread.unwrap()
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/outcome/_impl.py", line 213, in unwrap
2025-03-06 19:32:48     |     raise captured_error
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 373, in do_release_then_return_result
2025-03-06 19:32:48     |     return result.unwrap()
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/outcome/_impl.py", line 213, in unwrap
2025-03-06 19:32:48     |     raise captured_error
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 392, in worker_fn
2025-03-06 19:32:48     |     ret = context.run(sync_fn, *args)
2025-03-06 19:32:48     |   File "/ragflow/graphrag/light/graph_extractor.py", line 100, in <lambda>
2025-03-06 19:32:48     |     glean_result = await trio.to_thread.run_sync(lambda: self._chat(hint_prompt, history, gen_conf))
2025-03-06 19:32:48     |   File "/ragflow/graphrag/general/extractor.py", line 64, in _chat
2025-03-06 19:32:48     |     raise Exception(response)
2025-03-06 19:32:48     | Exception: **ERROR**: Error code: 429 - {'message': 'Request was rejected due to rate limiting. Details: TPM limit reached.', 'data': None}
2025-03-06 19:32:48     +---------------- 2 ----------------
2025-03-06 19:32:48     | Traceback (most recent call last):
2025-03-06 19:32:48     |   File "/ragflow/graphrag/light/graph_extractor.py", line 108, in _process_single_content
2025-03-06 19:32:48     |     if_loop_result = await trio.to_thread.run_sync(lambda: self._chat(self._if_loop_prompt, history, gen_conf))
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 447, in to_thread_run_sync
2025-03-06 19:32:48     |     return msg_from_thread.unwrap()
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/outcome/_impl.py", line 213, in unwrap
2025-03-06 19:32:48     |     raise captured_error
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 373, in do_release_then_return_result
2025-03-06 19:32:48     |     return result.unwrap()
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/outcome/_impl.py", line 213, in unwrap
2025-03-06 19:32:48     |     raise captured_error
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 392, in worker_fn
2025-03-06 19:32:48     |     ret = context.run(sync_fn, *args)
2025-03-06 19:32:48     |   File "/ragflow/graphrag/light/graph_extractor.py", line 108, in <lambda>
2025-03-06 19:32:48     |     if_loop_result = await trio.to_thread.run_sync(lambda: self._chat(self._if_loop_prompt, history, gen_conf))
2025-03-06 19:32:48     |   File "/ragflow/graphrag/general/extractor.py", line 64, in _chat
2025-03-06 19:32:48     |     raise Exception(response)
2025-03-06 19:32:48     | Exception: **ERROR**: Error code: 429 - {'message': 'Request was rejected due to rate limiting. Details: TPM limit reached.', 'data': None}
2025-03-06 19:32:48     +---------------- 3 ----------------
2025-03-06 19:32:48     | Traceback (most recent call last):
2025-03-06 19:32:48     |   File "/ragflow/graphrag/light/graph_extractor.py", line 100, in _process_single_content
2025-03-06 19:32:48     |     glean_result = await trio.to_thread.run_sync(lambda: self._chat(hint_prompt, history, gen_conf))
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 447, in to_thread_run_sync
2025-03-06 19:32:48     |     return msg_from_thread.unwrap()
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/outcome/_impl.py", line 213, in unwrap
2025-03-06 19:32:48     |     raise captured_error
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 373, in do_release_then_return_result
2025-03-06 19:32:48     |     return result.unwrap()
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/outcome/_impl.py", line 213, in unwrap
2025-03-06 19:32:48     |     raise captured_error
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 392, in worker_fn
2025-03-06 19:32:48     |     ret = context.run(sync_fn, *args)
2025-03-06 19:32:48     |   File "/ragflow/graphrag/light/graph_extractor.py", line 100, in <lambda>
2025-03-06 19:32:48     |     glean_result = await trio.to_thread.run_sync(lambda: self._chat(hint_prompt, history, gen_conf))
2025-03-06 19:32:48     |   File "/ragflow/graphrag/general/extractor.py", line 64, in _chat
2025-03-06 19:32:48     |     raise Exception(response)
2025-03-06 19:32:48     | Exception: **ERROR**: Error code: 429 - {'message': 'Request was rejected due to rate limiting. Details: TPM limit reached.', 'data': None}
2025-03-06 19:32:48     +---------------- 4 ----------------
2025-03-06 19:32:48     | Traceback (most recent call last):
2025-03-06 19:32:48     |   File "/ragflow/graphrag/light/graph_extractor.py", line 108, in _process_single_content
2025-03-06 19:32:48     |     if_loop_result = await trio.to_thread.run_sync(lambda: self._chat(self._if_loop_prompt, history, gen_conf))
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 447, in to_thread_run_sync
2025-03-06 19:32:48     |     return msg_from_thread.unwrap()
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/outcome/_impl.py", line 213, in unwrap
2025-03-06 19:32:48     |     raise captured_error
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 373, in do_release_then_return_result
2025-03-06 19:32:48     |     return result.unwrap()
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/outcome/_impl.py", line 213, in unwrap
2025-03-06 19:32:48     |     raise captured_error
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 392, in worker_fn
2025-03-06 19:32:48     |     ret = context.run(sync_fn, *args)
2025-03-06 19:32:48     |   File "/ragflow/graphrag/light/graph_extractor.py", line 108, in <lambda>
2025-03-06 19:32:48     |     if_loop_result = await trio.to_thread.run_sync(lambda: self._chat(self._if_loop_prompt, history, gen_conf))
2025-03-06 19:32:48     |   File "/ragflow/graphrag/general/extractor.py", line 64, in _chat
2025-03-06 19:32:48     |     raise Exception(response)
2025-03-06 19:32:48     | Exception: **ERROR**: Error code: 429 - {'message': 'Request was rejected due to rate limiting. Details: TPM limit reached.', 'data': None}
2025-03-06 19:32:48     +---------------- 5 ----------------
2025-03-06 19:32:48     | Traceback (most recent call last):
2025-03-06 19:32:48     |   File "/ragflow/graphrag/light/graph_extractor.py", line 100, in _process_single_content
2025-03-06 19:32:48     |     glean_result = await trio.to_thread.run_sync(lambda: self._chat(hint_prompt, history, gen_conf))
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 447, in to_thread_run_sync
2025-03-06 19:32:48     |     return msg_from_thread.unwrap()
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/outcome/_impl.py", line 213, in unwrap
2025-03-06 19:32:48     |     raise captured_error
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 373, in do_release_then_return_result
2025-03-06 19:32:48     |     return result.unwrap()
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/outcome/_impl.py", line 213, in unwrap
2025-03-06 19:32:48     |     raise captured_error
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 392, in worker_fn
2025-03-06 19:32:48     |     ret = context.run(sync_fn, *args)
2025-03-06 19:32:48     |   File "/ragflow/graphrag/light/graph_extractor.py", line 100, in <lambda>
2025-03-06 19:32:48     |     glean_result = await trio.to_thread.run_sync(lambda: self._chat(hint_prompt, history, gen_conf))
2025-03-06 19:32:48     |   File "/ragflow/graphrag/general/extractor.py", line 64, in _chat
2025-03-06 19:32:48     |     raise Exception(response)
2025-03-06 19:32:48     | Exception: **ERROR**: Error code: 429 - {'message': 'Request was rejected due to rate limiting. Details: TPM limit reached.', 'data': None}
2025-03-06 19:32:48     +---------------- 6 ----------------
2025-03-06 19:32:48     | Traceback (most recent call last):
2025-03-06 19:32:48     |   File "/ragflow/graphrag/light/graph_extractor.py", line 108, in _process_single_content
2025-03-06 19:32:48     |     if_loop_result = await trio.to_thread.run_sync(lambda: self._chat(self._if_loop_prompt, history, gen_conf))
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 447, in to_thread_run_sync
2025-03-06 19:32:48     |     return msg_from_thread.unwrap()
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/outcome/_impl.py", line 213, in unwrap
2025-03-06 19:32:48     |     raise captured_error
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 373, in do_release_then_return_result
2025-03-06 19:32:48     |     return result.unwrap()
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/outcome/_impl.py", line 213, in unwrap
2025-03-06 19:32:48     |     raise captured_error
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 392, in worker_fn
2025-03-06 19:32:48     |     ret = context.run(sync_fn, *args)
2025-03-06 19:32:48     |   File "/ragflow/graphrag/light/graph_extractor.py", line 108, in <lambda>
2025-03-06 19:32:48     |     if_loop_result = await trio.to_thread.run_sync(lambda: self._chat(self._if_loop_prompt, history, gen_conf))
2025-03-06 19:32:48     |   File "/ragflow/graphrag/general/extractor.py", line 64, in _chat
2025-03-06 19:32:48     |     raise Exception(response)
2025-03-06 19:32:48     | Exception: **ERROR**: Error code: 429 - {'message': 'Request was rejected due to rate limiting. Details: TPM limit reached.', 'data': None}
2025-03-06 19:32:48     +---------------- 7 ----------------
2025-03-06 19:32:48     | Traceback (most recent call last):
2025-03-06 19:32:48     |   File "/ragflow/graphrag/light/graph_extractor.py", line 108, in _process_single_content
2025-03-06 19:32:48     |     if_loop_result = await trio.to_thread.run_sync(lambda: self._chat(self._if_loop_prompt, history, gen_conf))
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 447, in to_thread_run_sync
2025-03-06 19:32:48     |     return msg_from_thread.unwrap()
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/outcome/_impl.py", line 213, in unwrap
2025-03-06 19:32:48     |     raise captured_error
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 373, in do_release_then_return_result
2025-03-06 19:32:48     |     return result.unwrap()
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/outcome/_impl.py", line 213, in unwrap
2025-03-06 19:32:48     |     raise captured_error
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 392, in worker_fn
2025-03-06 19:32:48     |     ret = context.run(sync_fn, *args)
2025-03-06 19:32:48     |   File "/ragflow/graphrag/light/graph_extractor.py", line 108, in <lambda>
2025-03-06 19:32:48     |     if_loop_result = await trio.to_thread.run_sync(lambda: self._chat(self._if_loop_prompt, history, gen_conf))
2025-03-06 19:32:48     |   File "/ragflow/graphrag/general/extractor.py", line 64, in _chat
2025-03-06 19:32:48     |     raise Exception(response)
2025-03-06 19:32:48     | Exception: **ERROR**: Error code: 429 - {'message': 'Request was rejected due to rate limiting. Details: TPM limit reached.', 'data': None}
2025-03-06 19:32:48     +---------------- 8 ----------------
2025-03-06 19:32:48     | Traceback (most recent call last):
2025-03-06 19:32:48     |   File "/ragflow/graphrag/light/graph_extractor.py", line 108, in _process_single_content
2025-03-06 19:32:48     |     if_loop_result = await trio.to_thread.run_sync(lambda: self._chat(self._if_loop_prompt, history, gen_conf))
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 447, in to_thread_run_sync
2025-03-06 19:32:48     |     return msg_from_thread.unwrap()
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/outcome/_impl.py", line 213, in unwrap
2025-03-06 19:32:48     |     raise captured_error
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 373, in do_release_then_return_result
2025-03-06 19:32:48     |     return result.unwrap()
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/outcome/_impl.py", line 213, in unwrap
2025-03-06 19:32:48     |     raise captured_error
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 392, in worker_fn
2025-03-06 19:32:48     |     ret = context.run(sync_fn, *args)
2025-03-06 19:32:48     |   File "/ragflow/graphrag/light/graph_extractor.py", line 108, in <lambda>
2025-03-06 19:32:48     |     if_loop_result = await trio.to_thread.run_sync(lambda: self._chat(self._if_loop_prompt, history, gen_conf))
2025-03-06 19:32:48     |   File "/ragflow/graphrag/general/extractor.py", line 64, in _chat
2025-03-06 19:32:48     |     raise Exception(response)
2025-03-06 19:32:48     | Exception: **ERROR**: Error code: 429 - {'message': 'Request was rejected due to rate limiting. Details: TPM limit reached.', 'data': None}
2025-03-06 19:32:48     +---------------- 9 ----------------
2025-03-06 19:32:48     | Traceback (most recent call last):
2025-03-06 19:32:48     |   File "/ragflow/graphrag/light/graph_extractor.py", line 100, in _process_single_content
2025-03-06 19:32:48     |     glean_result = await trio.to_thread.run_sync(lambda: self._chat(hint_prompt, history, gen_conf))
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 447, in to_thread_run_sync
2025-03-06 19:32:48     |     return msg_from_thread.unwrap()
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/outcome/_impl.py", line 213, in unwrap
2025-03-06 19:32:48     |     raise captured_error
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 373, in do_release_then_return_result
2025-03-06 19:32:48     |     return result.unwrap()
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/outcome/_impl.py", line 213, in unwrap
2025-03-06 19:32:48     |     raise captured_error
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 392, in worker_fn
2025-03-06 19:32:48     |     ret = context.run(sync_fn, *args)
2025-03-06 19:32:48     |   File "/ragflow/graphrag/light/graph_extractor.py", line 100, in <lambda>
2025-03-06 19:32:48     |     glean_result = await trio.to_thread.run_sync(lambda: self._chat(hint_prompt, history, gen_conf))
2025-03-06 19:32:48     |   File "/ragflow/graphrag/general/extractor.py", line 64, in _chat
2025-03-06 19:32:48     |     raise Exception(response)
2025-03-06 19:32:48     | Exception: **ERROR**: Error code: 429 - {'message': 'Request was rejected due to rate limiting. Details: TPM limit reached.', 'data': None}
2025-03-06 19:32:48     +---------------- 10 ----------------
2025-03-06 19:32:48     | Traceback (most recent call last):
2025-03-06 19:32:48     |   File "/ragflow/graphrag/light/graph_extractor.py", line 108, in _process_single_content
2025-03-06 19:32:48     |     if_loop_result = await trio.to_thread.run_sync(lambda: self._chat(self._if_loop_prompt, history, gen_conf))
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 447, in to_thread_run_sync
2025-03-06 19:32:48     |     return msg_from_thread.unwrap()
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/outcome/_impl.py", line 213, in unwrap
2025-03-06 19:32:48     |     raise captured_error
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 373, in do_release_then_return_result
2025-03-06 19:32:48     |     return result.unwrap()
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/outcome/_impl.py", line 213, in unwrap
2025-03-06 19:32:48     |     raise captured_error
2025-03-06 19:32:48     |   File "/ragflow/.venv/lib/python3.10/site-packages/trio/_threads.py", line 392, in worker_fn
2025-03-06 19:32:48     |     ret = context.run(sync_fn, *args)
2025-03-06 19:32:48     |   File "/ragflow/graphrag/light/graph_extractor.py", line 108, in <lambda>
2025-03-06 19:32:48     |     if_loop_result = await trio.to_thread.run_sync(lambda: self._chat(self._if_loop_prompt, history, gen_conf))
2025-03-06 19:32:48     |   File "/ragflow/graphrag/general/extractor.py", line 64, in _chat
2025-03-06 19:32:48     |     raise Exception(response)
2025-03-06 19:32:48     | Exception: **ERROR**: Error code: 429 - {'message': 'Request was rejected due to rate limiting. Details: TPM limit reached.', 'data': None}
2025-03-06 19:32:48     +------------------------------------
2025-03-06 19:33:16 2025-03-06 19:33:16,854 INFO     19 task_consumer_0 reported heartbeat: {"name": "task_consumer_0", "now": "2025-03-06T19:33:16.853+08:00", "boot_at": "2025-03-06T18:52:04.607+08:00", "pending": 2, "lag": 0, "done": 15, "failed": 11, "current": {}}
2025-03-06 19:33:46 2025-03-06 19:33:46,894 INFO     19 task_consumer_0 reported heartbeat: {"name": "task_consumer_0", "now": "2025-03-06T19:33:46.893+08:00", "boot_at": "2025-03-06T18:52:04.607+08:00", "pending": 2, "lag": 0, "done": 15, "failed": 11, "current": {}}
2025-03-06 19:34:16 2025-03-06 19:34:16,924 INFO     19 task_consumer_0 reported heartbeat: {"name": "task_consumer_0", "now": "2025-03-06T19:34:16.922+08:00", "boot_at": "2025-03-06T18:52:04.607+08:00", "pending": 2, "lag": 0, "done": 15, "failed": 11, "current": {}}
2025-03-06 19:34:29 2025-03-06 19:34:29,041 INFO     52 172.18.0.2 - - [06/Mar/2025 19:34:29] "GET /v1/user/info HTTP/1.1" 200 -
2025-03-06 19:34:29 2025-03-06 19:34:29,100 INFO     52 172.18.0.2 - - [06/Mar/2025 19:34:29] "GET /v1/user/tenant_info HTTP/1.1" 200 -
2025-03-06 19:34:29 2025-03-06 19:34:29,130 INFO     52 172.18.0.2 - - [06/Mar/2025 19:34:29] "GET /v1/kb/detail?kb_id=25e4434afa7c11ef8e8a0242ac120002 HTTP/1.1" 200 -
2025-03-06 19:34:29 2025-03-06 19:34:29,130 INFO     52 172.18.0.2 - - [06/Mar/2025 19:34:29] "GET /v1/document/list?kb_id=25e4434afa7c11ef8e8a0242ac120002&keywords=&page_size=10&page=1 HTTP/1.1" 200 -
2025-03-06 19:34:29 2025-03-06 19:34:29,253 INFO     52 HEAD http://es01:9200/ragflow_50127440fa4311efb83b0242ac120006 [status:200 duration:0.142s]
2025-03-06 19:34:29 2025-03-06 19:34:29,331 INFO     52 POST http://es01:9200/ragflow_50127440fa4311efb83b0242ac120006/_search [status:200 duration:0.005s]
2025-03-06 19:34:29 2025-03-06 19:34:29,340 INFO     52 172.18.0.2 - - [06/Mar/2025 19:34:29] "GET /v1/kb/25e4434afa7c11ef8e8a0242ac120002/knowledge_graph HTTP/1.1" 200 -
2025-03-06 19:34:41 2025-03-06 19:34:41,019 INFO     52 HEAD http://es01:9200/ragflow_50127440fa4311efb83b0242ac120006 [status:200 duration:0.002s]
2025-03-06 19:34:41 2025-03-06 19:34:41,084 INFO     52 POST http://es01:9200/ragflow_50127440fa4311efb83b0242ac120006/_search [status:200 duration:0.005s]
2025-03-06 19:34:41 2025-03-06 19:34:41,093 INFO     52 172.18.0.2 - - [06/Mar/2025 19:34:41] "GET /v1/kb/25e4434afa7c11ef8e8a0242ac120002/knowledge_graph HTTP/1.1" 200 -
2025-03-06 19:34:46 2025-03-06 19:34:46,956 INFO     19 task_consumer_0 reported heartbeat: {"name": "task_consumer_0", "now": "2025-03-06T19:34:46.955+08:00", "boot_at": "2025-03-06T18:52:04.607+08:00", "pending": 2, "lag": 0, "done": 15, "failed": 11, "current": {}}
2025-03-06 19:35:16 2025-03-06 19:35:16,983 INFO     19 task_consumer_0 reported heartbeat: {"name": "task_consumer_0", "now": "2025-03-06T19:35:16.982+08:00", "boot_at": "2025-03-06T18:52:04.607+08:00", "pending": 2, "lag": 0, "done": 15, "failed": 11, "current": {}}
2025-03-06 19:35:24 2025-03-06 19:35:24,079 INFO     52 172.18.0.2 - - [06/Mar/2025 19:35:24] "GET /v1/kb/detail?kb_id=25e4434afa7c11ef8e8a0242ac120002 HTTP/1.1" 200 -
2025-03-06 19:35:24 2025-03-06 19:35:24,079 INFO     52 172.18.0.2 - - [06/Mar/2025 19:35:24] "GET /v1/user/tenant_info HTTP/1.1" 200 -
2025-03-06 19:35:24 2025-03-06 19:35:24,410 INFO     52 172.18.0.2 - - [06/Mar/2025 19:35:24] "GET /v1/kb/list HTTP/1.1" 200 -
2025-03-06 19:35:24 2025-03-06 19:35:24,471 INFO     52 172.18.0.2 - - [06/Mar/2025 19:35:24] "GET /v1/llm/list HTTP/1.1" 200 -
2025-03-06 19:35:47 2025-03-06 19:35:47,008 INFO     19 task_consumer_0 reported heartbeat: {"name": "task_consumer_0", "now": "2025-03-06T19:35:47.007+08:00", "boot_at": "2025-03-06T18:52:04.607+08:00", "pending": 2, "lag": 0, "done": 15, "failed": 11, "current": {}}
2025-03-06 19:36:17 2025-03-06 19:36:17,142 INFO     19 task_consumer_0 reported heartbeat: {"name": "task_consumer_0", "now": "2025-03-06T19:36:17.141+08:00", "boot_at": "2025-03-06T18:52:04.607+08:00", "pending": 2, "lag": 0, "done": 15, "failed": 11, "current": {}}

and the web describe:

Light: (Default) Use prompts provided by github.com/HKUDS/LightRAG to extract entities and relationships. This option consumes fewer tokens, less memory, and fewer computational resources.
General: Use prompts provided by github.com/microsoft/graphrag to extract entities and relationships

Why the Method:light occur the error: 2025-03-06 19:30:29 | File "/ragflow/graphrag/general/extractor.py", line 64, in _chat error? This is using lightRAG;

Is there any place in the code where LightRAG and GraphRAG are confused?(Although I know this error is due to my reaching the API TPM limit.)

Is there anything can do to circumvent TPM restrictions when using the model provider's API?(For example, if you detect a limit, Time.sleep() for a while? --exponential backoff like the package: tenacity and backoff ;

tenacity

from langchain_core.embeddings import Embeddings
from itertools import islice

from tenacity import (
    retry,
    stop_after_attempt,
    wait_random_exponential,
) 

code_success = 200

class SiliconflowEmbeddings(Embeddings):
    def __init__(self, model_name: str):
        self.model_name = model_name
        self.api_url = "https://api.siliconflow.cn/v1/embeddings"
    # A maximum of 12 retries are allowed
    @retry(wait=wait_random_exponential(min=1, max=60), stop=stop_after_attempt(12))
    def _post(self, payload, headers):
        response = requests.post(self.api_url, json=payload, headers=headers)
        if response.status_code != code_success:
            raise Exception(f"Error code: {response.status_code}")
        return response
    
    def embed_documents(self, texts: List[str]) -> List[List[float]]:
        payload = {"model": self.model_name, "input": texts, "encoding_format": "float"}
        headers = {
            "accept": "application/json",
            "content-type": "application/json",
            "authorization": f"Bearer {os.environ['OPENAI_API_KEY']}",
        }

        embeds = []
        for batch in tqdm(batch_list(texts), total=len(texts) // batch_size):
            payload["input"] = batch
            response = self._post(payload, headers)
            embeds.extend([d["embedding"] for d in response.json()["data"]])

        return embeds

    def embed_query(self, text: str) -> List[float]:
        return self.embed_documents([text])[0]

tenacity provided a retry annotation that they could add to the calling API, like encapsulating the requests.post code, checking the status code it returned, and throwing an exception if it was 429, triggering a retry inside the Retry. Here, for simplicity, we throw an exception whenever it's not 200. This allows you to handle the rate limit, noting that if there is no rate limit, the embedding operation normally takes only 30 seconds to complete; When the rate limit is triggered, there will be some sleep in the retry, so the final completion time will be much longer than this 30 seconds, but at least successfully embedded;

or :

backoff

import random
import time

code_success = 200
code_rate_limit = 429


# Custom exception
class ConflictError(Exception):
    status_code: int = 429

   

def retry_with_exponential_backoff(
    func,
    initial_delay: float = 1,
    exponential_base: float = 2,
    jitter: bool = True,
    max_retries: int = 12,
    errors: tuple = (ConflictError,),
):
    def wrapper(*args, **kwargs):
        num_retries = 0
        delay = initial_delay

        # Loop until a successful response or max_retries is reached
        while True:
            try:
                return func(*args, **kwargs)

            # Try again on the specified error:
            except errors as e:
                # Increase retry times
                num_retries += 1

                # Check whether the maximum number of retries has been reached
                if num_retries > max_retries:
                    raise Exception(
                        f"Maximum number of retries ({max_retries}) exceeded."
                    )

                # random() generates a random number between 0 and 1, here to increase randomness
                delay *= exponential_base * (1 + jitter * random.random())
                time.sleep(delay)

            # Throws an exception if it is not specified
            except Exception as e:
                raise e

    return wrapper

Determine the status code, throw ConflictError if it is 429, otherwise return response.

@retry_with_exponential_backoff
def _post(self, payload, headers):
    response = requests.post(self.api_url, json=payload, headers=headers)
    if response.status_code == code_rate_limit:
        raise ConflictError()
    return response

Limiting LLM API speed is better than throwing an error

Image

Image

Image

emocat17 avatar Mar 06 '25 11:03 emocat17