HKUDS / LightRAG

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

Hangs on larger docs/smaller chunks #315

Closed nihirv closed 18 hours ago

nihirv commented 1 day ago

If this is being run on a lengthy doc (few hundred pages) and with a small-ish chunk size (e.g. 600), we reach a point where the entity and relationship labelling just hangs.

Small snippet:

INFO:httpx:HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK"
⠼ Processed 384 chunks, 6433 entities(duplicated), 4017 relations(duplicated)
INFO:httpx:HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK"
INFO:httpx:HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 200 OK"
⠴ Processed 385 chunks, 6443 entities(duplicated), 4022 relations(duplicated)

(And the processing does not continue despite there being another few hundred chunks to continue parsing).

Any reason why this could be the case? I've tested against a couple of different docs.

As far as models go, this occurs with 4o-mini and 4o. However, 4o-mini seems to be able to process more chunks before the hanging starts

nihirv commented 1 day ago

I was trying to use the following code as a workaround:

            loader = PyPDFLoader(doc)
            docs = loader.load()
            [rag.insert(x.page_content) for x in docs] 

Surprisingly this also seems to hang after we reach a certain size of graph. I'm wondering if there's a quadratic operation within the code somewhere based on the number of nodes in the graph already that is causing it to freeze?

nihirv commented 19 hours ago

I replaced the NanoVectorDb with a HNSWVectorDb but this also does not seem to be the root of the issue

nihirv commented 18 hours ago

Seems like this might be an issue with executing this code in a notebook environment on a VPN.

If you're running into the issue, would recommend disabling the VPN and running the code either in a regular python script or in a debugger