Get hypergraph running with a simple RAG pipeline. No theory — just working code.
Installation
uv add git+https://github.com/gilad-rubin/hypergraph.git
Hypergraph is in alpha. The API may change between releases, but core features (nodes, graphs, runners, routing) are stable.
Build Your First Pipeline
Define your functions
Create three functions for a simple RAG workflow. Use the @node decorator and name the outputs: from hypergraph import Graph, node, SyncRunner
@node ( output_name = "embedding" )
def embed ( text : str ) -> list[ float ]:
# Mock embedding for demo
return [ 0.1 , 0.2 , 0.3 ]
@node ( output_name = "docs" )
def retrieve ( embedding : list[ float ]) -> list[ str ]:
# Mock retrieval
return [ "Doc about RAG" , "Doc about embeddings" ]
@node ( output_name = "answer" )
def generate ( docs : list[ str ], query : str ) -> str :
# Mock generation
context = " \n " .join(docs)
return f "Based on: { context } \n Answer to ' { query } '"
Connect them automatically
Hypergraph infers edges by matching output names to input parameters: # Edges created automatically:
# embed → retrieve (embedding connects them)
# retrieve → generate (docs connects them)
graph = Graph( nodes = [embed, retrieve, generate])
No manual wiring needed — embed produces embedding, which retrieve accepts as a parameter.
Run the pipeline
Execute the graph with your inputs: runner = SyncRunner()
result = runner.run(graph, text = "RAG tutorial" , query = "What is RAG?" )
print (result[ "answer" ])
# Based on: Doc about RAG
# Doc about embeddings
# Answer to 'What is RAG?'
The runner manages execution order automatically based on dependencies.
What Just Happened?
The graph connected your functions using name-based dependency inference :
embed(text) → "embedding"
↓
retrieve(embedding) → "docs"
↓
generate(docs, query) → "answer"
When a function’s parameter name matches another function’s output name, hypergraph creates an edge automatically.
Next Steps
Core Concepts Understand nodes, graphs, and runners
Simple Pipeline Learn the DAG pattern in depth
RAG Example Build a real RAG pipeline with LLMs