GraphRAG-Benchmark icon indicating copy to clipboard operation
GraphRAG-Benchmark copied to clipboard

How to get the Examples to work (LightRAG)

Open Powerkrieger opened this issue 1 year ago • 1 comments

I am a little confused from the README about where to clone LightRAG to (or not clone but move the folder from release 1.2.5) and where to initialize a new environment. I use uv, but that shouldnt be a big problem. (I encourage everyone to switch to uv aswell, it is much easier and faster than conda)

I also had trouble finding the run_lightrag.py, but obviously it was in the Examples folder, just didnt think about it when following the changes needed for LightRAG. Maybe that could be clarified in the README to say: "Then you can run the following command to indexing and inference in `GraphRAG-Benchmark/Examples```

Powerkrieger avatar Sep 24 '25 07:09 Powerkrieger

Alright, with some additional thinking I got it to work with uv and our own ollama server. For anyone interested I will mention the steps involved. I will assume you have uv and git installed. I can only make comments about the ollama version, so I will assume you have an ollama instance running aswell, doesnt have to be on the same machine though. Make a separate folder for everything if you want and from that folder do:

  1. git clone https://github.com/GraphRAG-Bench/GraphRAG-Benchmark.git
  2. cd GrahRAG-Benchmark
  3. uv init --bare --python 3.10
  4. uv python pin 3.10
  5. uv add -r requirements.txt

From Pypi.org download lightrag-hku version 1.2.5 Extract that into the working directory next to the GraphRAG-Benchmark repo or anywhere on your computer. Perform the changes mentioned in the README in this folder. In lightrag/operate.py there is also these two lines:

if cached_response is not None:
    return cached_response

For robustness you should add context as a return value (if cached_response is not None: return cached_response, context) and move the two lines below the introduction of the context variable.

Once all changes are made the package can be installed in uv with 6. uv add ../lightrag_hku-1.2.5 --editable (the package can be updated if you need to make more changes by running the same command again. 7. Then the example can be run with uv run Examples/run_lightrag.py --subset medical --mode ollama --base_dir ./Examples/lightrag_workspace --model_name llama3.3:latest --embed_model bge-large:latest --retrieve_topk 5 --llm_base_url http://<ollama_server_ip>:11434 you can add --sample 10 if you want to try on a couple of questions first 8. In any case there will be Modules missing, from the top of my head I remember pipmaster, transformers, torch, ollama, json5, json_repair, langchain-ollama... Add the one thats missing with uv add <package-name> and run again until you get no further errors. 9. If there is a version missmatch like I know I had with numpy, just remove the version requirement from the requirements.txt (uv remove <package-name> and uv add <package-name>) I think I restricted something to the version that was released at the same time that lightrag 1.2.5 was released (uv remove <package-name> and uv add <package-name>==<version>). If something keeps on saying there is a version missmatch or some error that you dont understand that would be my first go to debugging idea.

For eval I changed to uv run -m Evaluation.generation_eval --mode ollama --model llama3.3:latest --base_url http://<ollama-server-ip>:11434 --embedding_model bge-large:latest --data_file ./results/lightrag/Medical/predictions_Medical.json --output_file ./results/evaluation_results.json --detailed_output or the same with Evaluation.retrieval_eval

Good luck!

Powerkrieger avatar Sep 25 '25 12:09 Powerkrieger