Find answers from the community

Updated 3 months ago

how can i change the kg_triple_extract_template in KnowledgeGraphIndex index=KnowledgeGra

how can i change the kg_triple_extract_template in KnowledgeGraphIndex
index=KnowledgeGraphIndex.from_documents(
documents,
max_triplets_per_chunk=3,
service_context=service_context,
include_embeddings=True
)
k
2 comments
Please stand by @RUPP as I search the knowledge base. I normally take about 20 seconds or so. :wave:
----------------------
The kg_triple_extract_template is a parameter that you can pass when creating an instance of KnowledgeGraphIndex. This parameter is used to specify the prompt for extracting triplets.

You can modify your code to include this parameter as shown below:

Plain Text
kg_triple_extract_template = BasePromptTemplate(...)  # replace ... with your template

index = KnowledgeGraphIndex.from_documents(
    documents,
    kg_triple_extract_template=kg_triple_extract_template,
    max_triplets_per_chunk=3,
    service_context=service_context,
    include_embeddings=True
)


Please replace BasePromptTemplate(...) with your actual template.

For more details, you can refer to the LlamaIndex documentation ().
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Add a reply
Sign up and join the conversation on Discord