Home / File/ knowledge_triplet_extraction.py — langchain Source File

knowledge_triplet_extraction.py — langchain Source File

Architecture documentation for knowledge_triplet_extraction.py, a python file in the langchain codebase. 1 imports, 0 dependents.

File python 1 imports

Entity Profile

Dependency Diagram

graph LR
  e95b6bbb_4f66_d8f2_38e6_9c8f46ac8f32["knowledge_triplet_extraction.py"]
  4b3dcc0f_d872_0044_39ec_2d289f87f9e6["langchain_core.prompts.prompt"]
  e95b6bbb_4f66_d8f2_38e6_9c8f46ac8f32 --> 4b3dcc0f_d872_0044_39ec_2d289f87f9e6
  style e95b6bbb_4f66_d8f2_38e6_9c8f46ac8f32 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from langchain_core.prompts.prompt import PromptTemplate

KG_TRIPLE_DELIMITER = "<|>"

_DEFAULT_KNOWLEDGE_TRIPLE_EXTRACTION_TEMPLATE = (
    "You are a networked intelligence helping a human track knowledge triples"
    " about all relevant people, things, concepts, etc. and integrating"
    " them with your knowledge stored within your weights"
    " as well as that stored in a knowledge graph."
    " Extract all of the knowledge triples from the text."
    " A knowledge triple is a clause that contains a subject, a predicate,"
    " and an object. The subject is the entity being described,"
    " the predicate is the property of the subject that is being"
    " described, and the object is the value of the property.\n\n"
    "EXAMPLE\n"
    "It's a state in the US. It's also the number 1 producer of gold in the US.\n\n"
    f"Output: (Nevada, is a, state){KG_TRIPLE_DELIMITER}(Nevada, is in, US)"
    f"{KG_TRIPLE_DELIMITER}(Nevada, is the number 1 producer of, gold)\n"
    "END OF EXAMPLE\n\n"
    "EXAMPLE\n"
    "I'm going to the store.\n\n"
    "Output: NONE\n"
    "END OF EXAMPLE\n\n"
    "EXAMPLE\n"
    "Oh huh. I know Descartes likes to drive antique scooters and play the mandolin.\n"
    f"Output: (Descartes, likes to drive, antique scooters){KG_TRIPLE_DELIMITER}(Descartes, plays, mandolin)\n"  # noqa: E501
    "END OF EXAMPLE\n\n"
    "EXAMPLE\n"
    "{text}"
    "Output:"
)

KNOWLEDGE_TRIPLE_EXTRACTION_PROMPT = PromptTemplate(
    input_variables=["text"],
    template=_DEFAULT_KNOWLEDGE_TRIPLE_EXTRACTION_TEMPLATE,
)

Dependencies

  • langchain_core.prompts.prompt

Frequently Asked Questions

What does knowledge_triplet_extraction.py do?
knowledge_triplet_extraction.py is a source file in the langchain codebase, written in python.
What does knowledge_triplet_extraction.py depend on?
knowledge_triplet_extraction.py imports 1 module(s): langchain_core.prompts.prompt.
Where is knowledge_triplet_extraction.py in the architecture?
knowledge_triplet_extraction.py is located at libs/langchain/langchain_classic/indexes/prompts/knowledge_triplet_extraction.py (directory: libs/langchain/langchain_classic/indexes/prompts).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free