IDEA-FinAI / ToG

This is the official github repo of Think-on-Graph. If you are interested in our work or willing to join our research team in Shenzhen, please feel free to contact us by email (xuchengjin@idea.edu.cn)
413 stars 45 forks source link

Intermittent JSONDecodeError in Relation Extraction #3

Closed FUTUREEEEEE closed 11 months ago

FUTUREEEEEE commented 11 months ago

I am experiencing an intermittent JSONDecodeError while running the relation_search_prune function in the project. This error does not always occur but seems to happen sporadically during different runs of the script.

44%|████▎ | 715/1639 [00:37<00:48, 19.02it/s] Traceback (most recent call last): File "main_freebase.py", line 64, in <module> retrieve_relations_with_scores = relation_search_prune(entity, topic_entity[entity], pre_relations, pre_heads[i], question, args) # best entity triplet, entitiy_id File "/mnt/home/tangxiaqiang/code/gpt/RAG/ToG.new/ToG/utils.py", line 194, in relation_search_prune result = run_llm(prompt, args.temperature_exploration, args.max_length, args.opeani_api_keys, args.LLM_type) File "/mnt/home/tangxiaqiang/code/gpt/RAG/ToG.new/ToG/utils.py", line 143, in run_llm result = json.loads(result)['choices'][0]['message']['content'] File "/mnt/home/tangxiaqiang/miniconda3/envs/tog/lib/python3.8/json/__init__.py", line 357, in loads return _default_decoder.decode(s) File "/mnt/home/tangxiaqiang/miniconda3/envs/tog/lib/python3.8/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/mnt/home/tangxiaqiang/miniconda3/envs/tog/lib/python3.8/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)

Thank you in advance to anyone who can provide insight or assistance in resolving this issue. Your help is greatly appreciated!

GasolSun36 commented 11 months ago

It seems that the input content violates the regulations of openai (such as violence, blood, pornography, etc.). You can simply start from this sample and run it again. If it still doesn't work, it is recommended to skip this sample.