graphrag icon indicating copy to clipboard operation
graphrag copied to clipboard

[Bug]: same input,some times report error,somes time not

Open goodmaney opened this issue 1 year ago • 4 comments

Describe the bug

File "/home/xx/graphrag/graphrag/query/structured_search/global_search/search.py", line 194, in _map_response_single_batch processed_response = self.parse_search_response(search_response) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/xx/graphrag/graphrag/query/structured_search/global_search/search.py", line 232, in parse_search_response parsed_elements = json.loads(search_response)["points"] ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/xx/anaconda3/envs/graphrag/lib/python3.11/json/init.py", line 346, in loads return _default_decoder.decode(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/xx/anaconda3/envs/graphrag/lib/python3.11/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/xx/anaconda3/envs/graphrag/lib/python3.11/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 2024-07-10 15:37:06 - Translation file for zh-CN not found. Using default translation en-US.

Steps to reproduce

Not sure how to reproduce,some time it report error. input the same chinese content

Expected Behavior

No response

GraphRAG Config Used

No response

Logs and screenshots

No response

Additional Information

  • GraphRAG Version:
  • Operating System:
  • Python Version:
  • Related Issues:

goodmaney avatar Jul 10 '24 07:07 goodmaney

looks like the report output is not JSON format from LLM. I also meet this issue, and I optimized the prompt with examples to make it stable output JSON.

Can you try this PR to test? https://github.com/microsoft/graphrag/pull/473

KylinMountain avatar Jul 10 '24 10:07 KylinMountain

看起来报告输出不是来自LLM的JSON格式。我也遇到了这个问题,我用示例优化了提示,使其稳定输出JSON。

你可以尝试这个 PR 来测试一下吗?#473

I replace the py by https://github.com/microsoft/graphrag/blob/4f69839606cfaca782d537396c381087e36bfb4f/graphrag/query/structured_search/global_search/map_system_prompt.py.

Report some errors:

Error parsing search response json Traceback (most recent call last): File "/home/xx/graphrag/graphrag/query/structured_search/global_search/search.py", line 194, in _map_response_single_batch processed_response = self.parse_search_response(search_response) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/xx/graphrag/graphrag/query/structured_search/global_search/search.py", line 232, in parse_search_response parsed_elements = json.loads(search_response)["points"] ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/xx/anaconda3/envs/graphrag/lib/python3.11/json/init.py", line 346, in loads return _default_decoder.decode(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/xx/anaconda3/envs/graphrag/lib/python3.11/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/xx/anaconda3/envs/graphrag/lib/python3.11/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

goodmaney avatar Jul 11 '24 13:07 goodmaney

This issue has been marked stale due to inactivity after repo maintainer or community member responses that request more information or suggest a solution. It will be closed after five additional days.

github-actions[bot] avatar Jul 28 '24 01:07 github-actions[bot]

hi i had same issue, but i think it is proved

it just due to json format.

first i found the what is "search_response" so, i added to "print(search_resposns)" on the "parsed_elements = json.loads(search_response)["points"]" (graphrag/query/structured_search/global_search/search.py", line 232)

and search_response is not json format. that has additionally raw text. like "Here is reponse. { 'answer' : ... }"

so i added to this code (2 line) to remove the text in search_response

json_start = search_response.find('{')
search_response = search_response[json_start:]

parsed_elements = json.loads(search_response)["points"] 
...

(graphrag/graphrag/query/structured_search/global_search/search.py", line 232)

There may be other problems as well, but the json problem can be solved with this.

har3408 avatar Aug 06 '24 08:08 har3408