FalkorDB/FalkorDB

GitHub: FalkorDB/FalkorDB

一款基于 Redis 和稀疏矩阵技术的高性能图数据库,旨在为大模型提供高效的 GraphRAG 知识检索与实时分析能力。

Stars: 3591 | Forks: 283

FalkorDB Logo Square B

FalkorDB

Ultra-fast, Multi-tenant Graph Database

Powering Generative AI, Agent Memory, Cloud Security, and Fraud Detection

FalkorDB%2FFalkorDB | Trendshift
Try Free
Discord Dockerhub Discord codecov Workflow
![FalkorDB GitHub Repo - Video - 640x365](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/8457ba5a8f160101.gif)
## 独特功能 我们的目标是为大语言模型构建高性能的知识图谱,优先考虑超低延迟,以确保通过我们的图数据库实现快速高效的信息传递。 🆕 [FalkorDB](https://www.falkordb.com/) 是第一个**可查询的[属性图](https://github.com/opencypher/openCypher/blob/master/docs/property-graph-model.adoc)数据库,利用稀疏矩阵**来表示图中的[邻接矩阵](https://en.wikipedia.org/wiki/Adjacency_matrix),并使用[线性代数](https://en.wikipedia.org/wiki/Adjacency_matrix)进行查询。 ### 主要特性 * **稀疏矩阵表示**:利用稀疏矩阵表示邻接矩阵,优化存储和性能。 * **线性代数查询**:采用线性代数进行查询执行,提高计算效率。 * **符合属性图模型**:支持带有属性的节点和关系,遵循属性图模型。 * **OpenCypher 支持**:兼容 [OpenCypher](ttps://github.com/opencypher/openCypher/blob/master/docs/property-graph-model.adoc) 查询语言,包括用于高级查询功能的专有扩展。 ## 文档 [官方文档](https://docs.falkordb.com/) | [客户端](https://docs.falkordb.com/clients.html) | [命令](https://docs.falkordb.com/commands/) | 📊 [最新性能基准测试](https://benchmark.falkordb.com/) ### 社区与支持 * **讨论**:加入我们在 [GitHub Discussions](https://github.com/FalkorDB/FalkorDB/discussions) 的社区讨论,提问、分享想法并与其他用户交流。 * **贡献**:我们欢迎贡献!请参阅我们的[贡献指南](https://github.com/FalkorDB/FalkorDB/blob/master/CONTRIBUTING.md)了解更多详情。 * **许可证**:本项目基于 Server Side Public License v1 (SSPLv1) 授权。有关详细信息,请参阅 [LICENSE](https://github.com/FalkorDB/FalkorDB/blob/master/LICENSE.txt) 文件。 ## 开始使用 ### 第 1 步 要快速试用 FalkorDB,请使用 docker 启动一个实例: ``` docker run -p 6379:6379 -p 3000:3000 -it --rm -v ./data:/var/lib/falkordb/data falkordb/falkordb ``` ### 第 2 步 然后,打开浏览器并访问 `http://localhost:3000`。 您也可以使用任何受支持的[客户端库](https://docs.falkordb.com/clients.html)与 FalkorDB 进行交互。 ### MotoGP 联赛示例 在本例中,我们将使用 [FalkorDB Python 客户端](https://pypi.org/project/FalkorDB/)创建一个小型图谱,代表参与 MotoGP 联赛的部分摩托车手和车队。创建图谱后,我们将查询数据以探索其结构和关系。 ``` from falkordb import FalkorDB # 连接 FalkorDB db = FalkorDB(host='localhost', port=6379) # 创建 'MotoGP' 图 g = db.select_graph('MotoGP') g.query("""CREATE (:Rider {name:'Valentino Rossi'})-[:rides]->(:Team {name:'Yamaha'}), (:Rider {name:'Dani Pedrosa'})-[:rides]->(:Team {name:'Honda'}), (:Rider {name:'Andrea Dovizioso'})-[:rides]->(:Team {name:'Ducati'})""") # 查询哪些车手代表 Yamaha? res = g.query("""MATCH (r:Rider)-[:rides]->(t:Team) WHERE t.name = 'Yamaha' RETURN r.name""") for row in res.result_set: print(row[0]) # 输出:"Valentino Rossi" # 查询有多少车手代表 team Ducati? res = g.query("""MATCH (r:Rider)-[:rides]->(t:Team {name:'Ducati'}) RETURN count(r)""") print(res.result_set[0][0]) # 输出:1 ``` ## 开始构建 ### 编译 请确保完成以下要求: 1️⃣ FalkorDB 仓库:`git clone --recurse-submodules -j8 https://github.com/FalkorDB/FalkorDB.git` * Ubuntu,安装:`apt-get install build-essential cmake m4 automake peg libtool autoconf python3 python3-pip` * Alpine,安装:`apk add build-base cmake m4 automake libtool autoconf python3 py3-pip peg git libgomp openssl-dev` * OS X,确认已安装 `homebrew` 并运行:`brew install cmake m4 automake peg libtool autoconf`。 * OS X 工具链附带的 Clang 版本不支持 OpenMP,这是 FalkorDB 的必需项。解决此问题的一种方法是运行 `brew install gcc g++` 并按照屏幕上的说明更新符号链接。请注意,这是系统范围的更改 - 如果不希望这样做,设置 `CC` 和 `CXX` 的环境变量也可以。 2️⃣ 在项目目录中运行 `make` 进行构建。 恭喜!您可以在 `bin//src/falkordb.so` 找到编译好的二进制文件。 ### 运行测试 首先通过在 `tests` 目录中运行 ```pip install -r requirements.txt``` 来安装所需的 Python 包。 ### 在 Docker 中构建 FalkorDB 构建系统在 docker 内运行。有关构建的详细说明,请[参见此处](https://docs.falkordb.com/docker-examples/README.html)。 ## 将 FALKORDB 加载到 REDIS FalkorDB 由 [Redis](https://redis.io) 托管,因此您首先需要将其作为模块加载到 Redis 服务器中。 💡 我们建议通过将以下内容添加到 redis.conf 文件中,让 Redis 在启动时加载 FalkorDB: ``` loadmodule /path/to/module/src/falkordb.so ``` 在上面的行中,将 `/path/to/module/src/falkordb.so` 替换为 FalkorDB 库的实际路径。 如果 Redis 作为服务运行,您必须确保 `redis` 用户(默认)拥有必要的文件/文件夹权限以访问 `falkordb.so`。 或者,您可以使用以下命令行参数语法让 Redis 加载 FalkorDB: ``` ~/$ redis-server --loadmodule /path/to/module/src/falkordb.so ``` 最后,您也可以使用 [`MODULE LOAD`](http://redis.io/commands/module-load) 命令。但请注意,`MODULE LOAD` 是一个危险的命令,出于安全考虑,未来可能会被阻止/弃用。 成功加载 FalkorDB 后,您的 Redis 日志应看到类似于以下内容的行: ``` ... 30707:M 20 Jun 02:08:12.314 * Module 'graph' loaded from /src/falkordb.so ... ``` 如果服务器启动失败并输出类似于以下内容: ``` # 模块 /usr/lib/redis/modules/falkordb.so 加载失败:libgomp.so.1: 无法打开共享对象文件:没有那个文件或目录 # 无法从 /usr/lib/redis/modules/falkordb.so 加载模块:服务器中止 ``` 则系统缺少运行时依赖项 OpenMP。在 Ubuntu 上可以通过 `apt-get install libgomp1` 安装,在 RHEL/CentOS 上通过 `yum install libgomp` 安装,在 OSX 上通过 `brew install libomp` 安装。 ## 使用 FALKORDB 您可以从任何 Redis 客户端调用 FalkorDB 的命令。以下是几种方法: ### 使用 `redis-cli` ``` $ redis-cli 127.0.0.1:6379> GRAPH.QUERY social "CREATE (:person {name: 'roi', age: 33, gender: 'male', status: 'married'})" ``` ### 使用任何其他客户端 您可以使用客户端发送原始 Redis 命令的能力与 FalkorDB 进行交互。 #### 示例:在 Python 客户端中使用 FalkorDB 此代码片段展示了如何在 Python 中使用 [falkordb-py](https://github.com/FalkorDB/falkordb-py) 来使用 FalkorDB: ``` from falkordb import FalkorDB # 连接 FalkorDB db = FalkorDB(host='localhost', port=6379) # 选择 social 图 g = db.select_graph('social') reply = g.query("CREATE (:person {name:'roi', age:33, gender:'male', status:'married'})") ``` ## 客户端库 ### 官方客户端 | Project | Language | License | Author | Stars | Package | Comment | | --------------------------------------------------------- | ---------- | ------- | ------------------------------------------- | ----------------------------------------------------------------- | ------- | ---------- | | [jfalkordb][jfalkordb-url] | Java | BSD | [FalkorDB][falkordb-url] | [![jfalkordb-stars]][jfalkordb-url] | [Maven][jfalkordb-package]|| | [falkordb-py][falkordb-py-url] | Python | MIT | [FalkorDB][falkordb-url] | [![falkordb-py-stars]][falkordb-py-url] | [pypi][falkordb-py-package]|| | [falkordb-ts][falkordb-ts-url] | Node.JS | MIT | [FalkorDB][falkordb-url] | [![falkordb-ts-stars]][falkordb-ts-url] | [npm][falkordb-ts-package]|| | [falkordb-rs][falkordb-rs-url] | Rust | MIT | [FalkorDB][falkordb-url] | [![falkordb-rs-stars]][falkordb-rs-url] | [Crate][falkordb-rs-package]|| | [falkordb-go][falkordb-go-url] | Go | BSD | [FalkorDB][falkordb-url] | [![falkordb-go-stars]][falkordb-go-url] | [GitHub][falkordb-go-url]|| | [NFalkorDB][nfalkordb-url] | C# | Apache-2.0 | [FalkorDB][falkordb-url] | [![nfalkordb-stars]][nfalkordb-url] | [nuget][nfalkordb-package] | | ### 其他客户端 | Project | Language | License | Author | Stars | Package | Comment | | --------------------------------------------------------- | ---------- | ------- | ------------------------------------------- | ----------------------------------------------------------------- | ------- | ---------- | | [nredisstack][nredisstack-url] | .NET | MIT | [Redis][redis-url] | [![nredisstack-stars]][nredisstack-url] | [nuget][nredisstack-package]|| | [redisgraph-rb][redisgraph-rb-url] | Ruby | BSD | [Redis][redisgraph-rb-author] | [![redisgraph-rb-stars]][redisgraph-rb-url] | [GitHub][redisgraph-rb-url] || | [redgraph][redgraph-url] | Ruby | MIT | [pzac][redgraph-author] | [![redgraph-stars]][redgraph-url] | [GitHub][redgraph-url] || | [redisgraph-go][redisgraph-go-url] | Go | BSD | [Redis][redisgraph-go-author] | [![redisgraph-go-stars]][redisgraph-go-url] | [GitHub][redisgraph-go-url]|| | [rueidis][rueidis-url] | Go | Apache 2.0 | [Rueian][rueidis-author] | [![rueidis-stars]][rueidis-url] | [GitHub][rueidis-url] || | [ioredisgraph][ioredisgraph-url] | JavaScript | ISC | [Jonah][ioredisgraph-author] | [![ioredisgraph-stars]][ioredisgraph-url] | [GitHub][ioredisgraph-url] || | [@hydre/rgraph][rgraph-url] | JavaScript | MIT | [Sceat][rgraph-author] | [![rgraph-stars]][rgraph-url] | [GitHub][rgraph-url] || | [php-redis-graph][php-redis-graph-url] | PHP | MIT | [KJDev][php-redis-graph-author] | [![php-redis-graph-stars]][php-redis-graph-url] | [GitHub][php-redis-graph-url] || | [redisgraph_php][redisgraph_php-url] | PHP | MIT | [jpbourbon][redisgraph_php-author] | [![redisgraph_php-stars]][redisgraph_php-url] | [GitHub][redisgraph_php-url] || | [redisgraph-ex][redisgraph-ex-url] | Elixir | MIT | [crflynn][redisgraph-ex-author] | [![redisgraph-ex-stars]][redisgraph-ex-url] | [GitHub][redisgraph-ex-url] || | [redisgraph-rs][redisgraph-rs-url] | Rust | MIT | [malte-v][redisgraph-rs-author] | [![redisgraph-rs-stars]][redisgraph-rs-url] | [GitHub][redisgraph-rs-url] || | [redis_graph][redis_graph-url] | Rust | BSD | [tompro][redis_graph-author] | [![redis_graph-stars]][redis_graph-url] | [GitHub][redis_graph-url] || | [rustis][rustis-url] | Rust | MIT | [Dahomey Technologies][rustis-author] | [![rustis-stars]][rustis-url] | [Crate](https://crates.io/crates/rustis) | [Documentation](https://docs.rs/rustis/latest/rustis/commands/trait.GraphCommands.html) | | [NRedisGraph][NRedisGraph-url] | C# | BSD | [tombatron][NRedisGraph-author] | [![NRedisGraph-stars]][NRedisGraph-url] | [GitHub][NRedisGraph-url] || | [RedisGraph.jl][RedisGraph.jl-url] | Julia | MIT | [xyxel][RedisGraph.jl-author] | [![RedisGraph.jl-stars]][RedisGraph.jl-url] | [GitHub][RedisGraph.jl-url] || ## 许可证 根据 Server Side Public License v1 (SSPLv1) 授权。详见 [LICENSE](LICENSE.txt)。 ### 支持我们的工作 ⭐️ 如果您觉得这个仓库有帮助,请考虑给它点个 Star! ↗️ Graph, graph database, RAG, graphrag, Retrieval-Augmented Generation,Information Retrieval, Natural Language Processing, LLM, Embeddings, Semantic Search
标签:DLL 劫持, Docker, GraphBLAS, GraphRAG, Python客户端, RAG, 低延迟, 向量检索, 图算法, 大语言模型, 安全防御评估, 客户端加密, 客户端加密, 搜索引擎查询, 智能体记忆, 欺诈检测, 生成式AI, 稀疏邻接矩阵, 索引, 请求拦截, 高性能计算