Skip to content

Configuration

The byokg-rag library provides extensive configuration options to customize query processing, retrieval strategies, and LLM (Large Language Model) behavior. Configuration occurs at multiple levels: query engine initialization, retriever setup, entity linking, and LLM parameters.

This document provides complete parameter documentation for all configurable components. Most components provide sensible defaults, allowing you to start with minimal configuration and adjust as needed for your specific use case.

The query engine orchestrates the entire KGQA (Knowledge Graph Question Answering) pipeline, coordinating entity linking, retrieval, and answer generation.

ParameterTypeDefaultDescriptionExample
graph_storeGraphStoreRequiredGraph store instance providing access to knowledge graph dataNeptuneAnalyticsGraphStore(...)
entity_linkerEntityLinkerAuto-createdComponent for linking text mentions to graph entitiesEntityLinker(...)
triplet_retrieverGRetrieverAuto-created when llm_generator providedRetriever for extracting relevant triplets from the graphAgenticRetriever(...)
path_retrieverPathRetrieverAuto-createdRetriever for finding paths between entitiesPathRetriever(...)
graph_query_executorGraphQueryRetrieverAuto-createdExecutor for running structured graph queriesGraphQueryRetriever(...)
llm_generatorBaseGeneratorNoneLanguage model for generating responses. Required for LLM-powered retrieval and response generation.BedrockGenerator(...)
kg_linkerKGLinkerAuto-created when llm_generator providedLinker for multi-strategy retrieval operationsKGLinker(...)
cypher_kg_linkerCypherKGLinkerNoneSpecialized linker for Cypher-based retrievalCypherKGLinker(...)
direct_query_linkingboolFalseEnable direct entity linking using query embeddingsTrue

NOTE: When parameters are not provided, the query engine creates default instances with standard configurations where possible. Components that require an LLM (triplet_retriever, kg_linker) are only auto-created when llm_generator is explicitly provided. Without llm_generator, the engine can still perform graph-only operations (entity linking, path retrieval).

ParameterTypeDefaultDescriptionExample
querystrRequiredThe natural language question to answer”Who won the Nobel Prize in Physics in 1921?”
iterationsint2Number of multi-strategy retrieval iterations3
cypher_iterationsint2Number of Cypher query generation attempts3
user_inputstr""Additional instructions or context for the LLM”Focus on recent discoveries”

Valid Ranges:

  • iterations: 1-10 (higher values increase retrieval coverage but also latency)
  • cypher_iterations: 1-5 (higher values allow more query refinement attempts)

The agentic retriever implements iterative, LLM-guided exploration of the knowledge graph.

ParameterTypeDefaultDescriptionExample
llm_generatorBaseGeneratorRequiredLanguage model for guiding explorationBedrockGenerator(...)
graph_traversalGTraversalRequiredComponent for traversing graph structureGTraversal(graph_store)
graph_verbalizerTripletGVerbalizerRequiredComponent for converting triplets to textTripletGVerbalizer()
pruning_rerankerRerankerNoneOptional reranker for pruning resultsBGEReranker()
max_num_relationsint5Maximum relations to consider per iteration10
max_num_entitiesint3Maximum entities to explore per iteration5
max_num_iterationsint3Maximum exploration iterations5
max_num_tripletsint50Maximum triplets to retain after pruning100

Parameter Guidelines:

  • Increase max_num_relations for broader exploration of relationship types
  • Increase max_num_entities to explore more entity neighborhoods
  • Increase max_num_iterations for complex multi-hop reasoning
  • Increase max_num_triplets to retain more context (at the cost of LLM input length)

The path retriever finds structured paths between entities following metapath patterns.

ParameterTypeDefaultDescriptionExample
graph_traversalGTraversalRequiredComponent for traversing graph structureGTraversal(graph_store)
path_verbalizerPathVerbalizerRequiredComponent for converting paths to textPathVerbalizer()

The path retriever has minimal configuration. Its behavior is primarily controlled by the metapaths provided during retrieval.

The graph query retriever executes structured queries (openCypher) against the graph store.

ParameterTypeDefaultDescriptionExample
graph_storeGraphStoreRequiredGraph store instance for query executionNeptuneAnalyticsGraphStore(...)
block_graph_modificationboolTrueBlock queries that modify the graphTrue

WARNING: Setting block_graph_modification to False allows DELETE, CREATE, and other modification operations. Only disable this in controlled environments where query safety is guaranteed.

The KG linker coordinates LLM-based entity extraction and linking for multi-strategy retrieval.

ParameterTypeDefaultDescriptionExample
llm_generatorBaseGeneratorRequiredLanguage model for entity extractionBedrockGenerator(...)
graph_storeGraphStoreRequiredGraph store for schema and entity informationNeptuneAnalyticsGraphStore(...)
max_input_tokensint32000Maximum tokens allowed in user input and question16000

The max_input_tokens parameter prevents excessively long inputs that could cause LLM errors or high costs.

The Cypher KG linker specializes in generating and executing openCypher queries.

ParameterTypeDefaultDescriptionExample
llm_generatorBaseGeneratorRequiredLanguage model for Cypher generationBedrockGenerator(...)
graph_storeGraphStoreRequiredGraph store supporting openCypher executionNeptuneAnalyticsGraphStore(...)
max_input_tokensint32000Maximum tokens allowed in user input and question16000

NOTE: The graph store must support openCypher query execution. Use Neptune Analytics or Neptune Database graph stores.

The Bedrock generator provides access to foundation models through Amazon Bedrock.

ParameterTypeDefaultDescriptionExample
model_namestr”anthropic.claude-sonnet-4-6”Bedrock model identifier”anthropic.claude-sonnet-4-6”
region_namestr”us-east-1”AWS region for Bedrock service”us-east-1”
max_tokensint4096Maximum tokens to generate in responses8192
max_retriesint10Maximum retry attempts for failed requests5
prefillboolFalseEnable response prefilling (advanced)False
inference_configdictNoneCustom inference configuration{"temperature": 0.7}
reasoning_configdictNoneReasoning configuration for supported modelsNone

Supported Models:

The following models are compatible with byokg-rag. For the latest model availability and lifecycle status, see the Amazon Bedrock model lifecycle documentation.

Active models (recommended):

  • Claude Sonnet 4.6: anthropic.claude-sonnet-4-6
  • Claude Sonnet 4.5: anthropic.claude-sonnet-4-5-20250929-v1:0
  • Claude Sonnet 4: anthropic.claude-sonnet-4-20250514-v1:0
  • Claude Opus 4.6: anthropic.claude-opus-4-6-v1
  • Claude Opus 4.5: anthropic.claude-opus-4-5-20251101-v1:0
  • Claude Opus 4.1: anthropic.claude-opus-4-1-20250805-v1:0
  • Claude Haiku 4.5: anthropic.claude-haiku-4-5-20251001-v1:0

Legacy models (available only to users who have actively used them in the last 15 days; new users are blocked):

  • Claude 3.7 Sonnet: anthropic.claude-3-7-sonnet-20250219-v1:0 (EOL: Apr 28, 2026)
  • Claude 3.5 Sonnet v2: anthropic.claude-3-5-sonnet-20241022-v2:0 (EOL: Jul 30, 2026)
  • Claude 3.5 Sonnet: anthropic.claude-3-5-sonnet-20240620-v1:0 (EOL: Jul 30, 2026)
  • Claude 3.5 Haiku: anthropic.claude-3-5-haiku-20241022-v1:0 (EOL: Jun 19, 2026)
  • Claude 3 Haiku: anthropic.claude-3-haiku-20240307-v1:0 (EOL: Sep 10, 2026)

TIP: Claude Sonnet 4.6 provides the best balance of performance and cost for most KGQA applications.

Inference Configuration:

The inference_config parameter accepts a dictionary with Bedrock inference parameters:

inference_config = {
"temperature": 0.7, # Controls randomness (0.0-1.0)
"topP": 0.9, # Nucleus sampling threshold
"maxTokens": 4096 # Maximum tokens to generate
}

This example shows a fully configured query engine with custom components:

from graphrag_toolkit.byokg_rag.graphstore import NeptuneAnalyticsGraphStore
from graphrag_toolkit.byokg_rag.llm import BedrockGenerator
from graphrag_toolkit.byokg_rag.graph_connectors import KGLinker
from graphrag_toolkit.byokg_rag.graph_retrievers import (
AgenticRetriever,
PathRetriever,
GraphQueryRetriever,
EntityLinker,
GTraversal,
TripletGVerbalizer,
PathVerbalizer
)
from graphrag_toolkit.byokg_rag.indexing import FuzzyStringIndex
from graphrag_toolkit.byokg_rag.byokg_query_engine import ByoKGQueryEngine
# Step 1: Set up graph store
graph_store = NeptuneAnalyticsGraphStore(
graph_identifier="<graph-id>",
region="<region>"
)
# Step 2: Set up LLM
llm_generator = BedrockGenerator(
model_name="anthropic.claude-sonnet-4-6",
region_name="us-east-1",
max_tokens=4096,
max_retries=10
)
# Step 3: Set up entity linking
fuzzy_index = FuzzyStringIndex()
fuzzy_index.add(graph_store.nodes())
entity_matcher = fuzzy_index.as_entity_matcher()
entity_linker = EntityLinker(entity_matcher)
# Step 4: Set up retrievers
graph_traversal = GTraversal(graph_store)
triplet_verbalizer = TripletGVerbalizer()
path_verbalizer = PathVerbalizer()
triplet_retriever = AgenticRetriever(
llm_generator=llm_generator,
graph_traversal=graph_traversal,
graph_verbalizer=triplet_verbalizer,
max_num_relations=5,
max_num_entities=3,
max_num_iterations=3,
max_num_triplets=50
)
path_retriever = PathRetriever(
graph_traversal=graph_traversal,
path_verbalizer=path_verbalizer
)
graph_query_executor = GraphQueryRetriever(
graph_store=graph_store,
block_graph_modification=True
)
# Step 5: Set up KG linker
kg_linker = KGLinker(
llm_generator=llm_generator,
graph_store=graph_store,
max_input_tokens=32000
)
# Step 6: Create query engine
query_engine = ByoKGQueryEngine(
graph_store=graph_store,
entity_linker=entity_linker,
triplet_retriever=triplet_retriever,
path_retriever=path_retriever,
graph_query_executor=graph_query_executor,
llm_generator=llm_generator,
kg_linker=kg_linker,
direct_query_linking=False
)
# Step 7: Execute query
context = query_engine.query(
query="Who won the Nobel Prize in Physics in 1921?",
iterations=2,
user_input=""
)
print("Retrieved context:")
for item in context:
print(f" - {item}")

This example demonstrates explicit configuration of all components. In practice, you can rely on defaults for most parameters and only customize what you need.