@@ -16,6 +16,7 @@ Memgraph's officially supported integrations:
16
16
- [ LangChain] ( #langchain )
17
17
- [ Cognee] ( #cognee )
18
18
- [ Mem0] ( #mem0 )
19
+ - [ LightRAG] ( #lightrag )
19
20
20
21
21
22
## Model Context Protocol (MCP)
@@ -910,6 +911,142 @@ the official [Mem0
910
911
docs ](https://docs.mem0 .ai/open-source /graph_memory/overview#initialize-memgraph ).
911
912
912
913
914
+ ## LightRAG
915
+
916
+ <SocialCards>
917
+ <SocialCard
918
+ icon={<GitHub />}
919
+ title="LightRAG integration"
920
+ href="https://github.com/HKUDS/LightRAG"
921
+ is_external={true }
922
+ />
923
+ </SocialCards>
924
+
925
+ LightRAG is a simple and fast retrieval-augmented generation framework that
926
+ combines the power of graph databases with large language models. It provides
927
+ efficient graph-based knowledge representation and retrieval capabilities,
928
+ making it ideal for building RAG applications that require sophisticated
929
+ understanding of entity relationships and context.
930
+
931
+ LightRAG supports [Memgraph as a graph storage
932
+ backend ](https://github.com/HKUDS/LightRAG/blob/main/lightrag/kg/memgraph_impl.py ),
933
+ offering high-performance in-memory graph operations with full compatibility
934
+ with the Neo4j Bolt protocol.
935
+
936
+ {<h 3 className ="custom-header ">Installation </h 3>}
937
+
938
+ To use LightRAG with Memgraph, you need to install LightRAG from source since
939
+ Memgraph support is not yet available in the PyPI release:
940
+
941
+ ```shell
942
+ # Clone the LightRAG repository
943
+ git clone https://github.com/HKUDS/LightRAG.git
944
+ cd LightRAG
945
+
946
+ # Install from source
947
+ pip install -e .
948
+ ```
949
+
950
+ {<h 3 className ="custom-header ">Environment setup </h 3>}
951
+
952
+ Before getting started, ensure you have [Memgraph ](/getting-started ) running.
953
+ You can quickly start Memgraph using Docker:
954
+
955
+ ```bash
956
+ docker run -p 7687:7687 memgraph/memgraph:latest
957
+ ```
958
+
959
+ Configure your environment variables for Memgraph connection:
960
+
961
+ ```bash
962
+ export MEMGRAPH_URI="bolt://localhost:7687"
963
+ export MEMGRAPH_USERNAME="" # Default is empty
964
+ export MEMGRAPH_PASSWORD="" # Default is empty
965
+ export MEMGRAPH_DATABASE="memgraph" # Default database name
966
+ ```
967
+
968
+ {<h 3 className ="custom-header ">Basic usage </h 3>}
969
+
970
+ Here's a simple example of using LightRAG with Memgraph:
971
+
972
+ Export your `OPENAI_API_KEY` environment variable before running the script .
973
+
974
+ ```python
975
+ import os
976
+ import asyncio
977
+ from lightrag import LightRAG, QueryParam
978
+ from lightrag.llm.openai import gpt_4o_mini_complete, gpt_4o_complete, openai_embed
979
+ from lightrag.kg.shared_storage import initialize_pipeline_status
980
+ from lightrag.utils import setup_logger
981
+
982
+ setup_logger("lightrag", level="INFO")
983
+
984
+ WORKING_DIR = "./rag_storage "
985
+ if not os.path .exists(WORKING_DIR):
986
+ os.mkdir(WORKING_DIR)
987
+
988
+ async def initialize_rag():
989
+ rag = LightRAG(
990
+ working_dir=WORKING_DIR,
991
+ embedding_func=openai_embed,
992
+ llm_model_func=gpt_4o_mini_complete,
993
+ graph_storage="MemgraphStorage", #<-----------override KG default
994
+ )
995
+ # IMPORTANT: Both initialization calls are required!
996
+ await rag.initialize_storages() # Initialize storage backends
997
+ await initialize_pipeline_status() # Initialize processing pipeline
998
+ return rag
999
+
1000
+ async def main():
1001
+ try:
1002
+ # Initialize RAG instance
1003
+ rag = await initialize_rag()
1004
+ rag.insert("Your text")
1005
+
1006
+ # Perform hybrid search
1007
+ mode = "hybrid"
1008
+ print(
1009
+ await rag.query(
1010
+ "What are the top themes in this story?",
1011
+ param=QueryParam(mode=mode)
1012
+ )
1013
+ )
1014
+
1015
+ except Exception as e:
1016
+ print(f"An error occurred: {e }")
1017
+ finally:
1018
+ if rag:
1019
+ await rag.finalize_storages()
1020
+
1021
+ if __name__ == "__main__":
1022
+ asyncio.run(main())
1023
+ ```
1024
+
1025
+ { <h3 className = " custom-header" >Advanced configuration</h3 >}
1026
+
1027
+ LightRAG provides several configuration options for working with Memgraph:
1028
+
1029
+ ** Workspace isolation** : Use the ` MEMGRAPH_WORKSPACE ` environment variable to
1030
+ isolate data between different LightRAG instances:
1031
+
1032
+ ``` bash
1033
+ export MEMGRAPH_WORKSPACE=" project_a"
1034
+ ```
1035
+
1036
+ ** Custom connection parameters** : You can also configure connection parameters
1037
+ through a ` config.ini ` file:
1038
+
1039
+ ``` ini
1040
+ [memgraph]
1041
+ uri = bolt://localhost:7687
1042
+ username =
1043
+ password =
1044
+ database = memgraph
1045
+ ```
1046
+
1047
+ For more information about LightRAG's advanced configurations, features, and
1048
+ usage examples with Memgraph, visit the [ LightRAG GitHub
1049
+ repository] ( https://github.com/HKUDS/LightRAG ) .
913
1050
914
1051
915
1052
<CommunityLinks />
0 commit comments