General Templates¶
Base types and common extraction tasks.
Overview¶
General templates provide fundamental extraction capabilities suitable for a wide range of documents.
Base Types¶
base_model¶
Purpose: Basic structured data extraction
Output: Single structured object
Use for: Simple summaries, form-like data
Output Schema:
base_list¶
Purpose: Ordered collection extraction
Output: List of items
Use for: Sequences, rankings
Output Schema:
base_set¶
Purpose: Unique collection extraction
Output: Set of unique items
Use for: Tags, categories, keywords
Output Schema:
base_graph¶
Purpose: Basic entity-relationship extraction
Output: Graph with entities and relations
Use for: Knowledge graphs, networks
Output Schema:
{
"entities": [
{"name": "Entity1", "type": "type1"},
{"name": "Entity2", "type": "type2"}
],
"relations": [
{"source": "Entity1", "target": "Entity2", "type": "relates_to"}
]
}
Specialized Templates¶
biography_graph¶
Type: temporal_graph
Purpose: Extract person's life events and timeline
Best for: Biographies, profiles, memoirs
ka = Template.create("general/biography_graph", "en")
result = ka.parse(biography_text)
# Build index for interactive features
result.build_index()
# Visualize life events (with search/chat capabilities)
result.show()
# Ask questions
response = result.chat("What were the major achievements?")
print(response.content)
Features: - Extracts people, places, events - Captures temporal relationships - Timeline visualization
Example Output:
{
"entities": [
{"name": "Nikola Tesla", "type": "person"},
{"name": "AC Motor", "type": "invention"}
],
"relations": [
{
"source": "Nikola Tesla",
"target": "AC Motor",
"type": "invented",
"time": "1888"
}
]
}
concept_graph¶
Type: graph
Purpose: Extract concepts and their relationships
Best for: Research papers, technical documents, articles
Features: - Concept identification - Relationship mapping - Hierarchical structures
doc_structure¶
Type: model
Purpose: Extract document structure and outline
Best for: Long documents, reports, books
Features: - Section identification - Heading hierarchy - Key points per section
workflow_graph¶
Type: graph
Purpose: Extract process workflows
Best for: Procedures, processes, workflows
Features: - Step identification - Flow relationships - Decision points
When to Use General Templates¶
Use When:¶
- Document doesn't fit specific domain
- Need basic extraction
- Exploring/document type unknown
- Building custom workflows
Don't Use When:¶
- Domain-specific template available (use that instead)
- Need specialized fields (create custom template)
Examples¶
Example 1: Simple Summary¶
from hyperextract import Template
ka = Template.create("general/model", "en")
result = ka.parse("""
Meeting Notes:
Date: January 15, 2024
Attendees: Alice, Bob, Carol
Topic: Q1 Planning
Decision: Launch product in March
""")
print(result.data)
Example 2: Biography Analysis¶
ka = Template.create("general/biography_graph", "en")
result = ka.parse(biography_text)
# Build index for interactive features
result.build_index()
# Visualize life events (with search/chat capabilities)
result.show()
# Ask questions
response = result.chat("What were the major achievements?")
print(response.content)
Example 3: Research Paper¶
ka = Template.create("general/concept_graph", "en")
result = ka.parse(paper_text)
# Get concept map
for node in result.nodes:
print(f"Concept: {node.name}")
for edge in result.edges:
print(f"{edge.source} β {edge.target}")