graph_extraction: template: > # Context {document_summary} # Goal Given both a document summary and full text, identify all entities and their entity types, along with all relationships among the identified entities. # Steps 1. Identify all entities given the full text, grounding and contextualizing them based on the summary. For each identified entity, extract: - entity: Name of the entity, capitalized - entity_type: Type of the entity (constrained to {entity_types} if provided, otherwise all types) - entity_description: Comprehensive description incorporating context from both summary and full text Format each Entity in XML tags as follows: entity_typeentity_description Note: Generate additional entities from descriptions if they contain named entities for relationship mapping. 2. From the identified entities, identify all related entity pairs, using both summary and full text context: - source_entity: name of the source entity - target_entity: name of the target entity - relation: relationship type (constrained to {relation_types} if provided) - relationship_description: justification based on both summary and full text context - relationship_weight: strength score 0-10 Format each relationship in XML tags as follows: source_entitytarget_entityrelationrelationship_descriptionrelationship_weight 3. Coverage Requirements: - Each entity must have at least one relationship - Create intermediate entities if needed to establish relationships - Verify relationships against both summary and full text - Resolve any discrepancies between sources Example 1: If the list is empty, extract all entities and relations. Entity_types: Relation_types: Text: San Francisco is a city in California. It is known for the Golden Gate Bridge, cable cars, and steep hills. The city is surrounded by the Pacific Ocean and the San Francisco Bay. ###################### Output: CitySan Francisco is a city in California known for the Golden Gate Bridge, cable cars, and steep hills. It is surrounded by the Pacific Ocean and the San Francisco Bay. StateCalifornia is a state in the United States. LandmarkThe Golden Gate Bridge is a famous bridge in San Francisco. Body of WaterThe Pacific Ocean is a large body of water that surrounds San Francisco. Body of WaterThe San Francisco Bay is a body of water that surrounds San Francisco. San FranciscoCaliforniaLocated InSan Francisco is a city located in California.8 San FranciscoGolden Gate BridgeFeaturesSan Francisco features the Golden Gate Bridge.9 San FranciscoPacific OceanSurrounded BySan Francisco is surrounded by the Pacific Ocean.7 San FranciscoSan Francisco BaySurrounded BySan Francisco is surrounded by the San Francisco Bay.7 CaliforniaSan FranciscoContainsCalifornia contains the city of San Francisco.8 Golden Gate BridgeSan FranciscoLocated InThe Golden Gate Bridge is located in San Francisco.8 Pacific OceanSan FranciscoSurroundsThe Pacific Ocean surrounds San Francisco.7 San Francisco BaySan FranciscoSurroundsThe San Francisco Bay surrounds San Francisco.7 ###################### Example 2: If the list is empty, extract all entities and relations. Entity_types: Organization, Person Relation_types: Located In, Features Text: The Green Bay Packers are a professional American football team based in Green Bay, Wisconsin. The team was established in 1919 by Earl "Curly" Lambeau and George Calhoun. The Packers are the third-oldest franchise in the NFL and have won 13 league championships, including four Super Bowls. The team's home games are played at Lambeau Field, which is named after Curly Lambeau. ###################### Output: OrganizationThe Green Bay Packers are a professional American football team based in Green Bay, Wisconsin. The team was established in 1919 by Earl "Curly" Lambeau and George Calhoun. The Packers are the third-oldest franchise in the NFL and have won 13 league championships, including four Super Bowls. The team's home games are played at Lambeau Field, which is named after Curly Lambeau. CityGreen Bay is a city in Wisconsin. StateWisconsin is a state in the United States. PersonEarl "Curly" Lambeau was a co-founder of the Green Bay Packers. PersonGeorge Calhoun was a co-founder of the Green Bay Packers. OrganizationThe NFL is the National Football League. EventThe Super Bowl is the championship game of the NFL. StadiumLambeau Field is the home stadium of the Green Bay Packers. Green Bay PackersGreen BayLocated InThe Green Bay Packers are based in Green Bay, Wisconsin.8 Green BayWisconsinLocated InGreen Bay is located in Wisconsin.8 Green Bay PackersEarl "Curly" LambeauFounded ByThe Green Bay Packers were established by Earl "Curly" Lambeau.9 Green Bay PackersGeorge CalhounFounded ByThe Green Bay Packers were established by George Calhoun.9 Green Bay PackersNFLLeagueThe Green Bay Packers are a franchise in the NFL.8 Green Bay PackersSuper BowlChampionshipsThe Green Bay Packers have won four Super Bowls.9 -Real Data- ###################### If the list is empty, extract all entities and relations. Entity_types: {entity_types} Relation_types: {relation_types} Document Summary: {document_summary} Full Text: {input} ###################### Output: input_types: document_summary: str max_knowledge_relationships: int input: str entity_types: list[str] relation_types: list[str] overwrite_on_diff: true