Overview
Each pipeline function corresponds to a CLI command but takes explicit parameters instead of reading from config files. Use these from Jupyter notebooks, web apps, or anywhere you want sift-kg as a library.run_pipeline
Signature
Parameters
Path
required
Directory containing documents (PDF, text, HTML, 75+ formats)
str
required
LLM model string (e.g.
"openai/gpt-4o-mini", "anthropic/claude-3-5-sonnet-20241022")DomainConfig
required
Domain configuration object loaded via
load_domain()Path
required
Output directory for all artifacts (extractions, graph, narratives)
float | None
default:"None"
Budget cap in USD. Pipeline stops if cost exceeds this limit.
bool
default:"True"
Whether to generate narrative summary at the end
Returns
Path
Path to output directory containing all pipeline artifacts
Example
run_extract
Signature
Parameters
Path
required
Directory containing documents to extract from
str
required
LLM model string (e.g.
"openai/gpt-4o-mini")DomainConfig
required
Domain configuration
Path
required
Where to save extraction JSON files
float | None
default:"None"
Budget cap in USD
int
default:"4"
Concurrent LLM calls per document
int
default:"10000"
Characters per text chunk. Larger = fewer API calls but longer context.
bool
default:"False"
Re-extract all documents, ignoring cached results
str
default:"kreuzberg"
Extraction backend —
"kreuzberg" (default) or "pdfplumber"bool
default:"False"
Enable OCR for scanned documents
str
default:"tesseract"
OCR engine —
"tesseract", "easyocr", "paddleocr", or "gcv"str
default:"eng"
OCR language code (ISO 639-3, e.g.
"eng", "spa", "fra")int
default:"40"
Max requests per minute for rate limiting
Returns
list[DocumentExtraction]
List of extraction results, one per document
Example
run_build
Signature
Parameters
Path
required
Directory with extraction JSON files (from
run_extract)DomainConfig
required
Domain configuration (used for review_required types)
float
default:"0.7"
Flag relations below this confidence for human review
bool
default:"True"
Whether to remove redundant edges during graph construction
Returns
KnowledgeGraph
Populated knowledge graph saved to
output_dir/graph_data.jsonExample
run_resolve
Signature
Parameters
Path
required
Directory with
graph_data.jsonstr
required
LLM model string for entity comparison
DomainConfig | None
default:"None"
Domain configuration (provides system context for smarter resolution)
bool
default:"False"
Use semantic clustering for batching candidates (requires
sift-kg[embeddings])int
default:"4"
Concurrent LLM calls
int
default:"40"
Max requests per minute
Returns
MergeFile
Merge file with DRAFT proposals saved to
output_dir/merge_proposals.yamlExample
run_apply_merges
Signature
Parameters
Path
required
Directory with
graph_data.json and review files (merge_proposals.yaml, relation_review.yaml)Returns
dict
Stats dict with keys:
merges_applied(int): Number of entity merges appliedrejected_count(int): Number of relations rejected
Example
run_narrate
Signature
Parameters
Path
required
Directory with
graph_data.jsonstr
required
LLM model string
str
default:""
Optional domain context injected into LLM prompts
bool
default:"True"
Generate per-entity descriptions (more expensive)
float | None
default:"None"
Budget cap in USD
bool
default:"False"
Only regenerate community labels (~$0.01 cost)
Returns
Path
Path to generated
narrative.md or communities.jsonExample
run_view
Signature
Parameters
Path
required
Directory with
graph_data.jsonPath | None
default:"None"
Output HTML path (default:
output_dir/graph.html)bool
default:"True"
Whether to open the visualization in a browser automatically
int | None
default:"None"
Show only top N entities by degree (useful for large graphs)
float | None
default:"None"
Hide nodes/edges below this confidence threshold
str | None
default:"None"
Show only entities from this document
str | None
default:"None"
Center visualization on entity ID (e.g.
"person:alice")int
default:"1"
Number of hops for neighborhood filter (used with
neighborhood)str | None
default:"None"
Focus on a specific community label
Returns
Path
Path to generated interactive HTML file
Example
run_export
Signature
Parameters
Path
required
Directory with
graph_data.jsonstr
default:"json"
Export format —
"json", "graphml", "gexf", "csv", or "sqlite"Path | None
default:"None"
Where to write output (default:
output_dir/graph.{fmt})Returns
Path
Path to the exported file or directory (for CSV format)