- 01-Combined Extract and Build – An example of performing continuous ingest using the
LexicalGraphIndex.extract_and_build()
method. - 02-Separate Extract and Build – An example of running the extract and build stages separately, with intermediate chunks persisted to the local filesystem using a
FileBasedChunks
object. - 03-Advanced Construction – An example of advanced graph construction.
- 04-Querying – Examples of querying the graph using the
LexicalGraphQueryEngine
with either theTraversalBasedRetriever
orSemanticGuidedRetriever
.
The notebooks assume that the graph store and vector store connections are stored in GRAPH_STORE
and VECTOR_STORE
environment variables.
If you are running these notebooks via the Cloudformation template below, a .env
file containing these variables will already have been installed in the Amazon SageMaker environment. If you are running these notebooks in a separate environment, you will need to populate these two environment variables.
graphrag-toolkit-stack.json
creates a graphrag-toolkit environment:
- Amazon VPC with three private subnets, one public subnet, and an internet gateway
- Amazon Neptune Database cluster with a single Neptune serverless instance
- Amazon OpenSearch Serverless collection with a public endpoint
- Amazon SageMaker notebook
Charges apply.
The SageMaker notebook's IAM role policy includes permissions that allow the following models to be invoked:
anthropic.claude-3-sonnet-20240229-v1:0
cohere.embed-english-v3
You must run the CloudFormation stack in a region containing these models, and must enable access to these models before running the notebook examples.
The CloudFormation stack includes an input parameter, IamPolicyArn
, that allows you to add an additional IAM policy to the GraphRAG client IAM role created by the stack. Use this parameter to add a custom policy containing permissions to additional resources that you want to use, such as specific Amazon S3 buckets, or additional Amazon Bedrock foundation models.
The CloudFormation stack includes an input parameter, ExampleNotebooksURL
that specifies the URL of a zip file containing the graphrag-toolkit example notebooks. By default this parameter is set to:
https://github.com/awslabs/graphrag-toolkit/releases/latest/download/graphrag-toolkit-examples.zip
Set this parameter blank if you do not want to install the notebooks in your environment.