4a19d70af1
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (python) (push) Waiting to run
Tests / database-integration-tests (push) Waiting to run
MCP Server Tests / live-mcp-tests (push) Waiting to run
Server Tests / live-server-tests (push) Waiting to run
Pyright Type Check / pyright (push) Waiting to run
Tests / unit-tests (push) Waiting to run
Lint with Ruff / ruff (push) Has been cancelled
GLiNER2 Hybrid LLM Client Example (Experimental)
Note: The
GLiNER2Clientis experimental and may change in future releases.
This example demonstrates using GLiNER2 as a hybrid LLM client for Graphiti. GLiNER2 handles entity extraction (NER) locally on CPU, while a general-purpose LLM client handles edge/fact extraction, deduplication, summarization, and other reasoning tasks.
- Paper: GLiNER2: An Efficient Multi-Task Information Extraction System with Schema-Driven Interface
- Models on HuggingFace:
- fastino/gliner2-base-v1 (205M params)
- fastino/gliner2-large-v1 (340M params)
- fastino/gliner2-multi-v1 (multilingual)
Prerequisites
- Python 3.11+
- Neo4j 5.26+ (Neo4j Desktop or Docker)
- An LLM provider API key (Google, OpenAI, Anthropic, etc.)
Setup
# Install graphiti with the gliner2 extra
pip install graphiti-core[gliner2]
# Copy and configure environment variables
cp .env.example .env
The GLiNER2 model weights are downloaded automatically on first run.
LLM and Embedding Providers
The example uses Google Gemini (gemini-2.5-flash-lite) for the LLM and embeddings, but GLiNER2Client accepts any Graphiti LLMClient. To swap providers, replace GeminiClient and GeminiEmbedder with the equivalent from another provider:
graphiti_core.llm_client.openai_client.OpenAIClientgraphiti_core.llm_client.anthropic_client.AnthropicClientgraphiti_core.llm_client.groq_client.GroqClientgraphiti_core.embedder.openai.OpenAIEmbeddergraphiti_core.embedder.voyage.VoyageAIEmbedder
Configuration
| Parameter | Description | Default |
|---|---|---|
threshold |
GLiNER2 confidence threshold (0.0-1.0). Higher values reduce spurious extractions. | 0.5 |
GLINER2_MODEL |
HuggingFace model ID | fastino/gliner2-large-v1 |
Running
python gliner2_neo4j.py