Domain Schemas Reference

Reference for built-in domain schemas and custom schema creation.

Overview

Domain schemas define entity types with descriptions that improve GLiNER zero-shot extraction accuracy. Each schema is optimized for a specific domain.

Available Schemas

poleo

The POLE+O model for investigations and intelligence analysis.

Entity Type Description

PERSON

A person, individual, or named human being

OBJECT

A physical or digital object, item, vehicle, device, or document

LOCATION

A geographic location, address, place, or area

EVENT

An incident, meeting, transaction, or occurrence in time

ORGANIZATION

A company, agency, institution, or group

podcast

Optimized for podcast transcripts and interviews.

Entity Type Description

PERSON

A person mentioned or interviewed

COMPANY

A company, startup, or business organization

PRODUCT

A product, service, or platform

CONCEPT

A concept, methodology, or framework

BOOK

A book, publication, or written work

TECHNOLOGY

A technology, programming language, or technical tool

news

Optimized for news articles.

Entity Type Description

PERSON

A person mentioned in the news

ORGANIZATION

A company, government agency, or institution

LOCATION

A city, country, or geographic location

EVENT

A news event, incident, or occurrence

DATE

A specific date or time reference

scientific

Optimized for research papers and scientific text.

Entity Type Description

AUTHOR

An author or researcher

INSTITUTION

A university, research lab, or institution

METHOD

A methodology, algorithm, or technique

DATASET

A dataset or corpus

METRIC

A performance metric or measurement

TOOL

A software tool or framework

business

Optimized for business documents.

Entity Type Description

COMPANY

A company or corporation

PERSON

A business person, executive, or employee

PRODUCT

A product or service

INDUSTRY

An industry or market sector

FINANCIAL_METRIC

A financial metric, revenue, or valuation

entertainment

Optimized for movies, TV, and entertainment.

Entity Type Description

ACTOR

An actor or performer

DIRECTOR

A director or filmmaker

FILM

A movie or film

TV_SHOW

A television series

CHARACTER

A fictional character

AWARD

An award or recognition

medical

Optimized for healthcare and medical text.

Entity Type Description

DISEASE

A disease, condition, or disorder

DRUG

A medication, drug, or treatment

SYMPTOM

A symptom or clinical sign

PROCEDURE

A medical procedure or surgery

BODY_PART

An anatomical structure or body part

GENE

A gene or genetic marker

Optimized for legal documents.

Entity Type Description

CASE

A legal case or proceeding

PERSON

A party, attorney, or judge

ORGANIZATION

A company, firm, or agency

LAW

A law, statute, or regulation

COURT

A court or jurisdiction

MONETARY_AMOUNT

A monetary amount, fine, or award

Using Schemas

With GLiNEREntityExtractor

from neo4j_agent_memory.extraction import GLiNEREntityExtractor

# Use named schema
extractor = GLiNEREntityExtractor.for_schema("podcast")

# With custom threshold
extractor = GLiNEREntityExtractor.for_schema("medical", threshold=0.6)

With ExtractorBuilder

from neo4j_agent_memory.extraction import ExtractorBuilder

extractor = (
    ExtractorBuilder()
    .with_gliner_schema("news", threshold=0.5)
    .build()
)

Listing Available Schemas

from neo4j_agent_memory.extraction import list_schemas, get_schema

# List all schema names
print(list_schemas())
# ['poleo', 'podcast', 'news', 'scientific', 'business', 'entertainment', 'medical', 'legal']

# Get schema details
schema = get_schema("podcast")
for entity_type, description in schema.entity_types.items():
    print(f"{entity_type}: {description}")

Creating Custom Schemas

DomainSchema Class

from neo4j_agent_memory.extraction.domain_schemas import DomainSchema

real_estate_schema = DomainSchema(
    name="real_estate",
    entity_types={
        "property": "A real estate property, building, or land parcel",
        "agent": "A real estate agent or broker",
        "buyer": "A property buyer or purchaser",
        "seller": "A property seller or owner",
        "price": "A property price, valuation, or asking price",
        "location": "A neighborhood, city, or street address",
    },
)

extractor = GLiNEREntityExtractor(schema=real_estate_schema, threshold=0.5)

Schema Best Practices

  1. Use descriptive names: "A real estate property" is better than "property"

  2. Include synonyms: "A company, startup, or business organization"

  3. Be domain-specific: Tailor descriptions to your use case

  4. Test thresholds: Lower thresholds catch more entities but may reduce precision

Schema Persistence

Store custom schemas in Neo4j for reuse:

from neo4j_agent_memory.schema import SchemaManager, EntitySchemaConfig, EntityTypeConfig

# Create schema config
config = EntitySchemaConfig(
    name="real_estate",
    version="1.0",
    description="Real estate domain schema",
    entity_types=[
        EntityTypeConfig(name="PROPERTY", description="A real estate property"),
        EntityTypeConfig(name="AGENT", description="A real estate agent"),
    ],
)

# Save to Neo4j
manager = SchemaManager(client._client)
stored = await manager.save_schema(config, created_by="admin")

# Load later
schema = await manager.load_schema("real_estate")

Entity Type Mapping

Map schema types to POLE+O for graph storage:

Schema Type POLE+O Type Neo4j Labels

PERSON, ACTOR, AUTHOR

PERSON

:Entity:Person

COMPANY, ORGANIZATION, INSTITUTION

ORGANIZATION

:Entity:Organization

LOCATION, CITY, COUNTRY

LOCATION

:Entity:Location

EVENT, MEETING, INCIDENT

EVENT

:Entity:Event

PRODUCT, OBJECT, VEHICLE

OBJECT

:Entity:Object

Custom types not in POLE+O are stored with :Entity:{CustomType} labels.

See Also