skills/43-wentorai-research-plugins/skills/tools/knowledge-graph/openspg-guide/SKILL.md
Ant Group knowledge graph engine with SPG and KAG framework
npx skillsauth add brycewang-stanford/Awesome-Agent-Skills-for-Empirical-Research openspg-guideInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
OpenSPG is Ant Group's open-source knowledge graph engine based on the Semantic-enhanced Programmable Graph (SPG) framework. It combines property graphs with semantic reasoning, enabling knowledge extraction, representation, reasoning, and question answering. The KAG (Knowledge Augmented Generation) module integrates with LLMs for RAG over knowledge graphs. Suited for building domain-specific knowledge bases for research.
# Docker deployment
git clone https://github.com/OpenSPG/openspg.git
cd openspg
docker-compose up -d
# Python SDK
pip install openspg
# Access KG Studio at http://localhost:8887
SPG Framework
├── Schema Layer (define types and relations)
│ ├── Entity types (Person, Paper, Concept)
│ ├── Properties (typed, constrained)
│ └── Relations (directed, typed edges)
├── Knowledge Layer (populate with data)
│ ├── Entity extraction (NER + linking)
│ ├── Relation extraction
│ └── Property filling
├── Reasoning Layer (infer new knowledge)
│ ├── Rule-based reasoning
│ ├── Statistical reasoning
│ └── LLM-augmented reasoning
└── Application Layer (query and use)
├── Graph queries (SPARQL-like)
├── Question answering
└── Knowledge-augmented generation
from openspg import Schema, EntityType, RelationType
# Define a research knowledge graph schema
schema = Schema("research_kg")
# Entity types
paper = EntityType("Paper", properties={
"title": "Text",
"abstract": "Text",
"year": "Integer",
"venue": "Text",
"doi": "Text",
"citation_count": "Integer",
})
author = EntityType("Author", properties={
"name": "Text",
"affiliation": "Text",
"h_index": "Integer",
})
concept = EntityType("Concept", properties={
"name": "Text",
"definition": "Text",
"domain": "Text",
})
# Relations
schema.add_relation(RelationType(
"authored_by", source=paper, target=author
))
schema.add_relation(RelationType(
"cites", source=paper, target=paper
))
schema.add_relation(RelationType(
"discusses", source=paper, target=concept
))
schema.add_relation(RelationType(
"related_to", source=concept, target=concept
))
schema.deploy()
from openspg import KnowledgeBuilder
builder = KnowledgeBuilder(schema="research_kg")
# Add entities
builder.add_entity("Paper", {
"title": "Attention Is All You Need",
"year": 2017,
"venue": "NeurIPS",
"doi": "10.48550/arXiv.1706.03762",
})
# Automatic extraction from text
builder.extract_from_text(
"Vaswani et al. proposed the Transformer architecture "
"which uses self-attention mechanisms to replace "
"recurrence. The model achieved state-of-the-art on "
"WMT 2014 English-to-German translation.",
entity_types=["Paper", "Author", "Concept"],
relation_types=["authored_by", "discusses"],
)
# Batch import from structured data
builder.import_csv(
"papers.csv",
entity_type="Paper",
column_mapping={"title": "title", "year": "year"},
)
builder.commit()
from openspg.kag import KAGPipeline
kag = KAGPipeline(
knowledge_graph="research_kg",
llm_provider="anthropic",
)
# Question answering over knowledge graph
answer = kag.ask(
"What are the key papers on attention mechanisms "
"and how are they related?"
)
print(answer.text)
for source in answer.sources:
print(f" [{source.type}] {source.name}: {source.evidence}")
# The KAG pipeline:
# 1. Parses question to identify relevant entities/relations
# 2. Queries knowledge graph for subgraph
# 3. Augments LLM context with structured knowledge
# 4. Generates grounded answer with provenance
from openspg import GraphQuery
gq = GraphQuery("research_kg")
# Find papers by concept
papers = gq.query("""
MATCH (p:Paper)-[:discusses]->(c:Concept)
WHERE c.name = 'self-attention'
RETURN p.title, p.year, p.citation_count
ORDER BY p.citation_count DESC
LIMIT 10
""")
# Find co-author network
coauthors = gq.query("""
MATCH (a1:Author)<-[:authored_by]-(p:Paper)
-[:authored_by]->(a2:Author)
WHERE a1.name = 'Ashish Vaswani'
RETURN DISTINCT a2.name, COUNT(p) as papers
ORDER BY papers DESC
""")
# Citation chain
chain = gq.query("""
MATCH path = (p1:Paper)-[:cites*1..3]->(p2:Paper)
WHERE p1.title CONTAINS 'GPT-4'
RETURN path
LIMIT 20
""")
development
Conduct rigorous thematic analysis (TA) of qualitative data following Braun and Clarke's (2006) six-phase framework. Use whenever the user mentions 'thematic analysis', 'TA', 'Braun and Clarke', 'qualitative coding', 'identifying themes', or asks for help analysing interviews, focus groups, open-ended survey responses, or transcripts to identify patterns. Also trigger for questions about inductive vs theoretical coding, semantic vs latent themes, essentialist vs constructionist epistemology, building a thematic map, or writing up a qualitative findings section. Covers all six phases, the four upfront analytic decisions, the 15-point quality checklist, and the five common pitfalls. Produces a Word document write-up and an annotated thematic map. Does NOT cover IPA, grounded theory, discourse analysis, conversation analysis, or narrative analysis — use a different method for those.
development
Guide users through writing a systematic literature review (SLR) following the PRISMA 2020 framework. Use this skill whenever the user mentions 'systematic review', 'systematic literature review', 'SLR', 'PRISMA', 'PRISMA 2020', 'PRISMA flow diagram', 'PRISMA checklist', or asks for help writing, structuring, or auditing a literature review that follows reporting guidelines. Also trigger when the user asks about inclusion/exclusion criteria for a review, search strategies for databases like Scopus/WoS/PubMed, study selection processes, risk of bias assessment, or narrative synthesis for a review paper. This skill covers the full PRISMA 2020 checklist (27 items), produces a Word document manuscript in strict journal article format, generates an annotated PRISMA flow diagram, and enforces APA 7th Edition referencing throughout. It does NOT cover meta-analysis or statistical pooling. By Chuah Kee Man.
testing
Performs placebo-in-time sensitivity analysis with hierarchical null model and optional Bayesian assurance. Use when checking model robustness, verifying lack of pre-intervention effects, or estimating study power.
data-ai
Fit, summarize, plot, and interpret a chosen CausalPy experiment. Use after the causal method has been selected, including when configuring PyMC/sklearn models and scale-aware custom priors.