FalkorDB

0

A super fast Graph Database uses GraphBLAS under the hood for its sparse adjacency matrix graph representation. Our goal is to provide the best Knowledge Graph for LLM (GraphRAG).

Databases

cloud-database
database-as-a-service
knowledge-graph
graph-database

Dockerhub Discord Workflow

FalkorDB

Try Free

Our objective is to create an outstanding Knowledge Graph specifically for Large Language Models (LLM) that boasts exceptionally low latency, ensuring swift delivery of information through our Graph Database, known as KG-RAG.

FalkorDB is the first queryable Property Graph database to use sparse matrices to represent the adjacency matrix in graphs and linear algebra to query the graph.

Primary features:

  • Adopting the Property Graph Model
    • Nodes (vertices) and Relationships (edges) that may have attributes
    • Nodes can have multiple labels
    • Relationships have a relationship type
  • Graphs represented as sparse adjacency matrices
  • OpenCypher with proprietary extensions as a query language
    • Queries are translated into linear algebra expressions

To see FalkorDB in action, visit Demos.

Quickstart

  1. Trying FalkorDB
  2. Build
  3. Start
  4. Use from any client
  5. Documentation

Give it a try

To quickly try out FalkorDB, launch an instance using docker:

docker run -p 6379:6379 -it --rm -v ./data:/data falkordb/falkordb:edge

Or, to use the built-in browser-based interface, run:

docker run -p 6379:6379 -p 3000:3000 -it --rm -v ./data:/data falkordb/falkordb:edge

Then, open your browser and navigate to http://localhost:3000.

You can also interact with FalkorDB using any of the supported client libraries

Here we'll use FalkorDB Python client to create a small graph representing a subset of motorcycle riders and teams taking part in the MotoGP league, once created we'll start querying our data.

from falkordb import FalkorDB

# Connect to FalkorDB
db = FalkorDB(host='localhost', port=6379)

# Create the 'MotoGP' graph
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'})""")

# Query which riders represents 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])

# Prints: "Valentino Rossi"

# Query how many riders represent team Ducati ?
res = g.query("""MATCH (r:Rider)-[:rides]->(t:Team {name:'Ducati'})
                 RETURN count(r)""")

print(res.result_set[0][0])
# Prints: 1

Building

Compiling

Requirements:

  • The FalkorDB repository: git clone --recurse-submodules -j8 https://github.com/FalkorDB/FalkorDB.git

  • On Ubuntu Linux, run: apt-get install build-essential cmake m4 automake peg libtool autoconf python3 python3-pip

  • On OS X, verify that homebrew is installed and run: brew install cmake m4 automake peg libtool autoconf.

    • The version of Clang that ships with the OS X toolchain does not support OpenMP, which is a requirement for FalkorDB. One way to resolve this is to run brew install gcc g++ and follow the on-screen instructions to update the symbolic links. Note that this is a system-wide change - setting the environment variables for CC and CXX will work if that is not an option.

To build, run make in the project's directory.

Congratulations! You can find the compiled binary at bin/<arch>/src/falkordb.so.

Running tests

First, install required Python packages by running pip install -r requirements.txt from the tests directory.

If you've got redis-server in PATH, just invoke make test.

Otherwise, invoke REDIS_SERVER=<redis-server-location> make test.

For more verbose output, run make test V=1.

Building in a docker

The FalkorDB build system runs within docker. For detailed instructions on building, please see here.

Loading FalkorDB into Redis

FalkorDB is hosted by Redis, so you'll first have to load it as a Module to a Redis server. Redis 6.2 is required for FalkorDB 2.12.

We recommend having Redis load FalkorDB during startup by adding the following to your redis.conf file:

loadmodule /path/to/module/src/falkordb.so

In the line above, replace /path/to/module/src/falkordb.so with the actual path to FalkorDB's library. If Redis is running as a service, you must ensure that the redis user (default) has the necessary file/folder permissions to access falkordb.so.

Alternatively, you can have Redis load FalkorDB using the following command line argument syntax:

~/$ redis-server --loadmodule /path/to/module/src/falkordb.so

Lastly, you can also use the MODULE LOAD command. Note, however, that MODULE LOAD is a dangerous command and may be blocked/deprecated in the future due to security considerations.

Once you've successfully loaded FalkorDB your Redis log should see lines similar to:

...
30707:M 20 Jun 02:08:12.314 * Module 'graph' loaded from <redacted>/src/falkordb.so
...

If the server fails to launch with output similar to:

# Module /usr/lib/redis/modules/falkordb.so failed to load: libgomp.so.1: cannot open shared object file: No such file or directory
# Can't load module from /usr/lib/redis/modules/falkordb.so: server aborting

The system is missing the run-time dependency OpenMP. This can be installed on Ubuntu with apt-get install libgomp1, on RHEL/CentOS with yum install libgomp, and on OSX with brew install libomp.

Using FalkorDB

You can call FalkorDB's commands from any Redis client.

With redis-cli

$ redis-cli
127.0.0.1:6379> GRAPH.QUERY social "CREATE (:person {name: 'roi', age: 33, gender: 'male', status: 'married'})"

With any other client

You can interact with FalkorDB using your client's ability to send raw Redis commands.

Depending on your client of choice, the exact method for doing that may vary.

Python example

This code snippet shows how to use FalkorDB with from Python using falkordb-py:

from falkordb import FalkorDB

# Connect to FalkorDB
db = FalkorDB(host='localhost', port=6379)

# Select the social graph
g = db.select_graph('social')

reply = g.query("CREATE (:person {name:'roi', age:33, gender:'male', status:'married'})")

Client libraries

Some languages have client libraries that provide support for FalkorDB's commands:

ProjectLanguageLicenseAuthorStarsPackageComment
jfalkordbJavaBSDFalkorDBStarsMaven
falkordb-pyPythonMITFalkorDBStarspypi
falkordb-tsNode.JSMITFalkorDBStarsnpm
nredisstack.NETMITRedisStarsnuget
redisgraph-rbRubyBSDRedisredisgraph-rb-starsGitHub
redgraphRubyMITpzacredgraph-starsGitHub
redisgraph-goGoBSDRedisredisgraph-go-starsGitHub
rueidisGoApache 2.0Rueianrueidis-starsGitHub
ioredisgraphJavaScriptISCJonahioredisgraph-starsGitHub
@hydre/rgraphJavaScriptMITSceatrgraph-starsGitHub
php-redis-graphPHPMITKJDevphp-redis-graph-starsGitHub
redisgraph_phpPHPMITjpbourbonredisgraph_php-starsGitHub
redisgraph-exElixirMITcrflynnredisgraph-ex-starsGitHub
redisgraph-rsRustMITmalte-vredisgraph-rs-starsGitHub
redis_graphRustBSDtomproredis_graph-starsGitHub
rustisRustMITDahomey Technologiesrustis-starsCrateDocumentation
NRedisGraphC#BSDtombatronNRedisGraph-starsGitHub
RedisGraph.jlJuliaMITxyxelRedisGraph.jl-starsGitHub

License

Licensed under the Server Side Public License v1 (SSPLv1). See LICENSE.