Amazon Neptune with SPARQL
Amazon Neptune is a high-performance graph analytics and serverless database for superior scalability and availability.
This example shows the QA chain that queries Resource Description Framework (RDF) data in an
Amazon Neptunegraph database using theSPARQLquery language and returns a human-readable response.SPARQL is a standard query language for
RDFgraphs.
This example uses a NeptuneRdfGraph class that connects with the Neptune database and loads its schema.
The NeptuneSparqlQAChain is used to connect the graph and LLM to ask natural language questions.
This notebook demonstrates an example using organizational data.
Requirements for running this notebook:
- Neptune 1.2.x cluster accessible from this notebook
- Kernel with Python 3.9 or higher
- For Bedrock access, ensure IAM role has this policy
{
"Action": [
"bedrock:ListFoundationModels",
"bedrock:InvokeModel"
],
"Resource": "*",
"Effect": "Allow"
}
- S3 bucket for staging sample data. The bucket should be in the same account/region as Neptune.