HKUDS / LightRAG

"LightRAG: Simple and Fast Retrieval-Augmented Generation"
https://arxiv.org/abs/2410.05779
MIT License
8.87k stars 1.07k forks source link

Json mode #287

Open b10902118 opened 3 days ago

b10902118 commented 3 days ago

Currently, the json response for keyword extraction is done by: https://github.com/HKUDS/LightRAG/blob/186cd34a033d13c13317cba356e0076cffc113fe/lightrag/operate.py#L406-L407

But today, most language models already support response in json format. Manual parsing is clumsy and can be unstable. https://github.com/ollama/ollama-python/blob/dc38fe467585037e02a4bc27a100cf6cb10202ff/ollama/_client.py#L277 https://github.com/openai/openai-python?tab=readme-ov-file#nested-params

If this is desired, I can create a pull request. Thanks.

LarFii commented 2 hours ago

Thank you very much! We took this approach because some models do not support JSON responses directly, so we opted for a method that, while clumsy, is more universal. However, we would greatly welcome a pull request to add support for models that do provide JSON responses directly.