SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2410.05779 · 2024

LightRAG: Simple and Fast Retrieval-Augmented Generation

arXiv · PDF · Open in the Atlas

Code that ran

7 of 8 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 2 honoured the contract we drafted, 1 violated it and 0 have no contract verdict; 4 failures of our instrument; 1 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2410.05779.json · badge: /api/ran/2410.05779.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
hkuds/lightrag canonical (classifier label)
classifier basis: census
7 ran · 1 no recorded run
FunctionStatusWhere it lives
collect_kg_merge_candidates Ran
ran; our contract draft was wrong, not the code
hkuds/lightrag/lightrag/operate.py
code served (permissive licence) · get_code("014de214db1895ca")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

# Construct a minimal chunk_results list
# Each element is a tuple of (maybe_nodes, maybe_edges)
# maybe_nodes is a dict with entity names as keys
# maybe_edges is a dict with edge keys as tuples (source, target)

chunk_results = [
    (
        {
            "entity_alice": {"type": "person"},
            "entity_bob": {"type": "person"},
        },
        {
            ("entity_alice", "entity_bob"): {"relation": "knows"},
            ("entity_bob", "entity_alice"): {"relation": "knows"},
        },
    ),
    (
        {
            "entity_charlie": {"type": "person"},
            "entity_alice": {"type": "person"},
        },
        {
            ("entity_charlie", "entity_alice"): {"relation": "works_with"},
        },
    ),
]

ARGS = {
    "chunk_results": chunk_results,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
find_target_span Ran
ran, honoured the contract we drafted
hkuds/lightrag/lightrag/multimodal_context.py
code served (permissive licence) · get_code("1729c5aef344cc43")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import re

# Test case 1: drawing with simple ID
kind_1 = "drawings"
item_id_1 = "fig_001"
block_content_1 = '<drawing id="fig_001" src="image.png"/>'

# Test case 2: table with complex formatting
kind_2 = "tables"
item_id_2 = "tbl_42"
block_content_2 = '<table id="tbl_42" class="data-table"><tr><td>Cell</td></tr></table>'

# Test case 3: equation with nested content
kind_3 = "equations"
item_id_3 = "eq_alpha"
block_content_3 = '<equation id="eq_alpha" type="display">E=mc^2</equation>'

# Test case 4: ID with special regex characters that need escaping
kind_4 = "drawings"
item_id_4 = "fig_[special]"
block_content_4 = '<drawing id="fig_[special]" data-src="test.svg"/>'

# Test case 5: Not found case
kind_5 = "tables"
item_id_5 = "missing_id"
block_content_5 = '<table id="other_id"><tr><td>Data</td></tr></table>'

# Test case 6: Invalid kind (should return None)
kind_6 = "invalid_kind"
item_id_6 = "any_id"
block_content_6 = '<drawing id="any_id"/>'

ARGS = {
    "kind": "drawings",
    "item_id": "fig_001",
    "block_content": '<drawing id="fig_001" src="image.png"/>'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family int — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
is_namespace Ran
ran, violated the contract we drafted
hkuds/lightrag/lightrag/namespace.py
code served (permissive licence) · get_code("cad2192dedaa609f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned bool, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np
from typing import Iterable

def is_namespace(namespace: str, base_namespace: str | Iterable[str]):
    if isinstance(base_namespace, str):
        return namespace.endswith(base_namespace)
    return any((is_namespace(namespace, ns) for ns in base_namespace))

# Test case 1: namespace is a string, base_namespace is a string
namespace_1 = "model.layer.weight"
base_namespace_1 = "weight"

# Test case 2: namespace is a string, base_namespace is an iterable of strings
namespace_2 = "model.layer.bias"
base_namespace_2 = ["weight", "bias", "norm"]

ARGS = {
    "namespace": namespace_1,
    "base_namespace": base_namespace_1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type bool, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_content_rows_by_blockid Ran
ran; our contract draft was wrong, not the code
hkuds/lightrag/lightrag/multimodal_context.py
code served (permissive licence) · get_code("c629108e63d2245a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import json
import tempfile
from pathlib import Path

# Create a temporary blocks.jsonl file with test data
temp_dir = tempfile.mkdtemp()
blocks_path = Path(temp_dir) / "blocks.jsonl"

# Write test JSONL data
test_data = [
    {"type": "content", "blockid": "block1", "content": "This is content for block 1"},
    {"type": "content", "blockid": "block2", "content": "This is content for block 2"},
    {"type": "other", "blockid": "block3", "content": "This should be ignored"},
    {"type": "content", "blockid": "block1", "content": "Duplicate block1, should be ignored"},
    {"type": "content", "blockid": "block4", "content": "Content for block 4"},
    {"type": "content", "blockid": "", "content": "Empty blockid, should be ignored"},
    {"type": "content", "blockid": "block5"},  # Missing content
    "not a dict",  # Invalid JSON object
    '{"type": "content", "blockid": "block6", "content": "Block 6 content"}',
]

with blocks_path.open('w', encoding='utf-8') as f:
    for item in test_data:
        if isinstance(item, dict):
            f.write(json.dumps(item) + '\n')
        else:
            f.write(item + '\n')

ARGS = {
    "blocks_path": str(blocks_path)
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
normalize_chunk_heading Ran
ran; our contract draft was wrong, not the code
hkuds/lightrag/lightrag/chunk_schema.py
code served (permissive licence) · get_code("245793d97f7a353f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# Test case 1: nested dict format with all fields
dp_nested_full = {
    'heading': {
        'level': 2,
        'heading': 'Introduction',
        'parent_headings': ['Chapter 1', 'Section A']
    }
}

# Test case 2: legacy flat format
dp_legacy_flat = {
    'heading': 'Methods',
    'level': 1,
    'parent_headings': ['Background']
}

# Test case 3: empty/missing inputs should return None
dp_empty = {
    'heading': '',
    'level': 0,
    'parent_headings': []
}

# Test case 4: nested dict with some empty fields
dp_nested_partial = {
    'heading': {
        'level': 3,
        'heading': 'Subsection',
        'parent_headings': None
    }
}

# Test case 5: legacy format with missing parent_headings
dp_legacy_minimal = {
    'heading': 'Results',
    'level': 2
}

# Use one of the test cases as the main argument
ARGS = {
    'dp': dp_nested_full
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
normalize_kv_create_time Ran
ran, honoured the contract we drafted
hkuds/lightrag/lightrag/base.py
code served (permissive licence) · get_code("65781232be7b3546")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned int, ndim 0, dtype family int, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import logging
from typing import Any

# Setup logger since the function uses it
logger = logging.getLogger(__name__)
logger.setLevel(logging.WARNING)

# Test cases covering the main branches:
# 1. None input
# 2. Boolean input (special case)
# 3. Valid int
# 4. Valid float that can be coerced to int
# 5. String that can be coerced to int
# 6. Invalid type that cannot be coerced

ARGS = {
    "value": 1609459200
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type int, ndim 0, dtype family int, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
tmp_path_for Ran
ran; our contract draft was wrong, not the code
hkuds/lightrag/lightrag/file_atomic.py
code served (permissive licence) · get_code("851727a852a7d324")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import threading
import time

ARGS = {
    "file_name": "model_checkpoint.pt"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
flush_may_have_lost_reference Not yet run
unverified (harvested, no recorded run)
hkuds/lightrag/lightrag/exceptions.py
code served (permissive licence) · get_code("07fbfec7874e6a96")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 8 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 8 later) and 0 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
is_namespace 2 other papers
2 later
2025.findings-emnlp.290 (2025 (year only))
ReGraphRAG: Reorganizing Fragmented Knowledge Graphs for Multi-Perspective Retrieval-Augmented Generation
2602.20459 (2026-02)
PRESCIENCE: A Dataset and Benchmark for Scientific Forecasting
collect_kg_merge_candidates 1 other paper
1 later
2602.20459 (2026-02)
PRESCIENCE: A Dataset and Benchmark for Scientific Forecasting
find_target_span 1 other paper
1 later
2602.20459 (2026-02)
PRESCIENCE: A Dataset and Benchmark for Scientific Forecasting
flush_may_have_lost_reference 1 other paper
1 later
2602.20459 (2026-02)
PRESCIENCE: A Dataset and Benchmark for Scientific Forecasting
load_content_rows_by_blockid 1 other paper
1 later
2602.20459 (2026-02)
PRESCIENCE: A Dataset and Benchmark for Scientific Forecasting
normalize_chunk_heading 1 other paper
1 later
2602.20459 (2026-02)
PRESCIENCE: A Dataset and Benchmark for Scientific Forecasting
normalize_kv_create_time 1 other paper
1 later
2602.20459 (2026-02)
PRESCIENCE: A Dataset and Benchmark for Scientific Forecasting
tmp_path_for 1 other paper
1 later
2602.20459 (2026-02)
PRESCIENCE: A Dataset and Benchmark for Scientific Forecasting

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Retrieval-Augmented Generation (RAG) systems enhance large language models (LLMs) by integrating external knowledge sources, enabling more accurate and contextually relevant responses tailored to user needs. However, existing RAG systems have significant limitations, including reliance on flat data representations and inadequate contextual awareness, which can lead to fragmented answers that fail to capture complex inter-dependencies. To address these challenges, we propose LightRAG, which incorporates graph structures into text indexing and retrieval processes. This innovative framework employs a dual-level retrieval system that enhances comprehensive information retrieval from both low-level and high-level knowledge discovery. Additionally, the integration of graph structures with vector representations facilitates efficient retrieval of related entities and their relationships, significantly improving response times while maintaining contextual relevance. This capability is further enhanced by an incremental update algorithm that ensures the timely integration of new data, allowing the system to remain effective and responsive in rapidly changing data environments. Extensive experimental validation demonstrates considerable improvements in retrieval accuracy and efficiency compared to existing approaches. We have made our LightRAG open-source and available at the link: https://github.com/HKUDS/LightRAG

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2410.05779")
get_code_for_paper("2410.05779")
have("2410.05779")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2410.05779.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2410.05779.svg)](https://syntology.ai/paper/2410.05779)

Connect an agent — have() is free.