A Semantica install fails, the CLI is missing, or your first query returns an empty graph.
Start with the smallest backend and verify install → health check → write → query → restart before adding an external graph database, vector store, or LLM.
This guide is for first-time Semantica users who write Python, teams prototyping conversation or document memory, and platform engineers who need a repeatable deployment path. It is not a production architecture guide yet. It is the controlled first run that gives you evidence before you add more moving parts.
Define the first memory target before installing anything
Your first task is not to build a complete enterprise Knowledge Graph. Choose one small dataset and one query whose answer you can verify manually.
Use a simple example such as:
- Alice works for Acme.
- Acme signed a contract with Beta.
- Alice approved the renewal.
- The source of each fact is recorded in metadata or a separate log.
The first query should be narrow:
Which organization is Alice connected to, and what contract is connected to that organization?
This target tests more than a successful import. It checks whether entities, relationships, identifiers, and traversal behavior match your expectations.
A small target also prevents three common problems:
- You cannot tell whether extraction or storage failed. A large document corpus creates too many possible failure points.
- You confuse vector retrieval with graph traversal. A relevant text result is not proof that the relationship was stored correctly.
- You lose the original input. Without a saved fixture and output log, you cannot reproduce a parsing or deduplication issue.
Semantica is designed as a modular context and intelligence layer. Its official architecture separates ingestion, parsing, extraction, graph construction, storage, provenance, and delivery, so you do not need to activate every layer during the first run. (official getting-started documentation)
Create a clean project directory and keep the sample data beside the script:
mkdir semantica-first-run
cd semantica-first-run
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
On Windows PowerShell, activate the environment with:
.\.venv\Scripts\Activate.ps1
Run these commands from the project directory, not from a random shell location. That makes the virtual environment, saved state, logs, and test fixtures easier to find when you restart the process later.
Install the smallest verified package set
Use the official core installation first:
python -m pip install semantica
The official package repository currently lists the 0.6.0 release uploaded on July 21, 2026. Do not hard-code that version into a long-lived deployment script unless you have tested it in your own environment; for a tutorial reproduction, record the version that your environment actually resolves. (Semantica package listing on PyPI)
Save the resolved package information:
python -m pip show semantica
python --version
python -m pip freeze > requirements-first-run.txt
The package includes a command-line interface. The official repository documents semantica for launching the dashboard, semantica doctor for a health check, and semantica --help for the grouped command reference. (official Semantica repository)
Run the checks before writing Python code:
semantica --help
semantica doctor
A healthy result should identify the Python runtime, the installed Semantica version, available vector-store support, and the configuration status. The exact output can differ by environment, so compare the meaning of each line rather than copying an expected screen output.
If the command is not found, check the executable path:
python -m pip show semantica
python -m site --user-base
which semantica
On Windows, use:
Get-Command semantica
python -m pip show semantica
If pip install completes but semantica doctor fails, do not immediately install the full extras bundle. First capture the complete error:
semantica doctor 2>&1 | tee doctor.log
Typical causes include an inactive virtual environment, a different Python interpreter being used by pip, a missing optional dependency, or a package version that does not match an older tutorial. The official installation guidance separates the core package from optional bundles such as LLM, graph-store, vector-store, and explorer support. (installation and optional dependency guidance)
Do not repair a failed minimal install by adding every optional dependency. That removes the evidence you need to identify the original problem and makes later upgrades harder to reproduce.
Create the first graph with explicit entities and relationships
For the first Agent Memory test, use explicit graph objects instead of beginning with automatic document extraction. This isolates storage and traversal from OCR, parsing, NER, relation extraction, and LLM behavior.
Create first_graph.py:
from semantica.context import ContextGraph
graph = ContextGraph(advanced_analytics=True)
graph.add_node(
"alice",
"Person",
name="Alice",
role="Operations lead",
)
graph.add_node(
"acme",
"Organization",
name="Acme",
)
graph.add_node(
"contract-001",
"Contract",
name="Acme renewal",
status="approved",
)
graph.add_edge(
"alice",
"acme",
edge_type="works_for",
)
graph.add_edge(
"alice",
"contract-001",
edge_type="approved",
)
graph.add_edge(
"acme",
"contract-001",
edge_type="party_to",
)
print("Neighbors of Alice:")
print(graph.get_neighbors("alice", hops=2))
Run it from the same directory:
python first_graph.py | tee graph-output.log
The official repository documents ContextGraph, typed nodes, typed edges, and neighbor traversal as part of the core graph workflow. (ContextGraph examples in the official repository)
At this stage, you are not proving that a document-to-graph pipeline works. You are proving that:
- node identifiers can be created consistently;
- edge direction is understood;
- relationship types are preserved;
- a two-hop traversal returns the expected connected objects;
- output can be saved for later comparison.
Keep identifiers stable. Do not use display names such as "Alice Chen" as the only key if your application may later receive "Alice", "A. Chen", or an external user ID. A stable identifier gives you a place to attach provenance, updates, and conflict handling later.
Build Agent Memory around the graph only after the graph works
Once explicit graph creation succeeds, add the context layer. Semantica’s AgentContext combines memory, retrieval, graph traversal, decisions, and checkpoints. Its documented API includes store, retrieve, save, load, health, and statistics methods. (AgentContext reference)
Create first_memory.py:
from semantica.context import AgentContext, ContextGraph
from semantica.vector_store import VectorStore
context = AgentContext(
vector_store=VectorStore(backend="faiss", dimension=768),
knowledge_graph=ContextGraph(advanced_analytics=True),
)
context.store(
"Alice approved the Acme renewal.",
metadata={
"source": "sample-record-001",
"record_type": "decision",
},
)
context.store(
"Acme is connected to the renewal contract.",
metadata={
"source": "sample-record-002",
"record_type": "relationship",
},
)
print("Health:")
print(context.health())
print("Stats:")
print(context.stats())
results = context.retrieve(
"Who approved the Acme renewal?",
max_results=5,
use_graph=True,
)
for item in results:
print(item)
Run it as follows:
python first_memory.py | tee memory-output.log
Do not judge the result only by whether a list is printed. Compare each returned item with the original records. Check the content, metadata, score, and any source or node reference available in the result.
The documented retrieval parameter is max_results; it is not top_k. The context reference also states that use_graph=True can force GraphRAG-style retrieval when a Knowledge Graph is configured. (retrieval parameter reference)
This distinction matters because an Agent Memory prototype can appear to work while returning only semantically similar text. Your acceptance test should ask whether the answer is supported by the stored relationship and whether the source can be traced.
Verify the first Knowledge Graph query with evidence
Use three separate checks instead of one broad natural-language question.
Check one: exact entity lookup
Verify that the node ID alice exists and that its type is Person.
Check two: direct relationship
Verify that Alice has an outgoing works_for edge to Acme.
Check three: multi-hop traversal
Verify that Alice can reach the renewal contract through the stored relationship path.
For a context-level query, use a narrow prompt:
results = context.retrieve(
"Which organization is connected to Alice and which contract is linked to it?",
max_results=5,
use_graph=True,
)
for result in results:
print(result)
If the result is empty, inspect the graph and memory separately. Possible causes include:
- the text was stored in vector memory but no graph relationship was added;
- the relationship direction is opposite to the query assumption;
- the embedding backend is unavailable;
- the query depends on an extraction step that you have not configured;
- the graph was created in one process but never loaded into the second process.
Semantica’s documentation describes graph retrieval as a combination of vector similarity and graph expansion, with configurable expansion hops and hybrid weighting. Start with the default behavior before tuning those controls. Increasing graph depth can increase the amount of traversal and make it harder to see whether the original relationship is correct. (graph retrieval and hybrid search reference)
Check persistence by saving, stopping, and loading again
A successful in-process query does not prove persistence. The official context reference states that the vector store does not automatically persist merely because an index path exists. Use context.save(path) to write the memory, vector index, and graph, then use context.load(path) in a later process. (save and load reference)
Add persistence to the script:
from semantica.context import AgentContext, ContextGraph
from semantica.vector_store import VectorStore
state_path = "agent-state"
context = AgentContext(
vector_store=VectorStore(backend="faiss", dimension=768),
knowledge_graph=ContextGraph(advanced_analytics=True),
)
context.store(
"Alice approved the Acme renewal.",
metadata={"source": "sample-record-001"},
)
context.save(state_path)
print(f"Saved context to {state_path}")
Run it:
python save_memory.py
Now create load_memory.py:
from semantica.context import AgentContext, ContextGraph
from semantica.vector_store import VectorStore
context = AgentContext(
vector_store=VectorStore(backend="faiss", dimension=768),
knowledge_graph=ContextGraph(advanced_analytics=True),
)
context.load("agent-state")
print(context.health())
print(context.stats())
results = context.retrieve(
"Who approved the Acme renewal?",
max_results=5,
use_graph=True,
)
for result in results:
print(result)
Run the second process after the first one exits:
python load_memory.py | tee reload-output.log
If the result disappears after restart, check the following before changing code:
- Does the
agent-statedirectory exist? - Did the process have write permission?
- Did both scripts use the same vector dimension?
- Did both scripts construct compatible graph and vector backends?
- Did
load()run before retrieval? - Did you accidentally save to a relative path from a different working directory?
Repeat the import of the same sample record. Record whether the result is duplicated, merged, updated, or rejected. Do not assume that semantic similarity automatically means application-level idempotency. Your production ingestion job still needs a source ID, import batch ID, or deterministic record key.
Use this acceptance checklist before expanding the stack:
- [ ] The virtual environment is active.
- [ ]
python -m pip show semanticareports the expected package. - [ ]
semantica --helpruns from the project directory. - [ ]
semantica doctorcompletes and its output is saved. - [ ] One explicit graph contains the expected nodes.
- [ ] At least one directed relationship can be traversed.
- [ ] The first memory query returns a result tied to the sample input.
- [ ] The context state is saved to a known directory.
- [ ] A new process loads the saved state successfully.
- [ ] Re-import behavior has been recorded instead of assumed.
- [ ] The original input and output logs are stored with the test.
Add external graph storage only after the local path passes
Semantica documents graph-store backends for persistent queryable storage, including a unified GraphStore interface and direct store classes. The quickstart shows a persistent graph store being passed into GraphBuilder, allowing the graph to survive process restarts. (official graph-store module documentation)
For a graph backend, install only the extra you need. For example:
python -m pip install "semantica[graph-neo4j]"
Then use the documented pattern:
from semantica.graph_store import Neo4jStore
from semantica.kg import GraphBuilder
store = Neo4jStore(
uri="bolt://localhost:7687",
user="neo4j",
password="replace-with-your-secret",
)
builder = GraphBuilder(
merge_entities=True,
graph_store=store,
)
graph = builder.build(
{
"entities": [
{"id": "alice", "type": "Person", "name": "Alice"},
{"id": "acme", "type": "Organization", "name": "Acme"},
],
"relationships": [
{
"source": "alice",
"target": "acme",
"type": "works_for",
}
],
}
)
Do not copy connection details from an old community article without checking the current official graph-store reference. Constructor names, package extras, and module paths can change. The current documentation lists multiple graph backends and emphasizes that storage is designed to be swappable, but each backend still has its own server, credentials, network, and transaction requirements.
The correct expansion order is:
- Run the local graph and context test.
- Add one external graph backend.
- Re-run the same entity, relationship, query, restart, and duplicate-import tests.
- Add a vector backend only if retrieval scale or search behavior requires it.
- Add an LLM extraction path after deterministic input and storage are stable.
- Add REST, MCP, or an agent framework only after the underlying graph has an independent test.
This keeps each failure domain separate. If the external backend fails, you can compare it against a known-good local fixture instead of debugging the entire AI stack at once.
Choose the next deployment step by failure risk
| Goal | Start with | Add later | Acceptance evidence |
|---|---|---|---|
| Learn the API | Core package and in-memory graph | No external service yet | Nodes, edges, and traversal work |
| Prototype Agent Memory | AgentContext with the documented vector backend |
LLM and richer retrieval | Store, retrieve, save, and load work |
| Persist a growing graph | External graph store extra | Hosted database and backups | Restart and duplicate-import tests pass |
| Extract from documents | Parser, normalizer, and extractors | LLM-assisted extraction | Source records map to verified entities |
| Connect an agent client | MCP or REST interface | Multi-agent orchestration | Query results remain traceable to graph data |
For a deeper cost decision, compare the dependency footprint before you commit to a long-running environment in the Semantica cost analysis guide. If retrieval becomes the bottleneck, use the same fixture and acceptance queries when reviewing performance tests. For broader system design, keep the next stage separate from this first run and review the Agent Memory production architecture direction.
The local-first path is usually the better starting point because it limits network failures, credentials, service startup order, and backend-specific behavior. A fully expanded deployment can be more suitable once you need shared access, larger graph capacity, team-level operations, or external durability.
Your current workstation may still be the weak link. A local setup can contain stale Python packages, conflicting shell paths, restricted write permissions, missing optional libraries, and undocumented changes accumulated across unrelated projects. Those issues are especially costly when you need to reproduce a clean install for a team or compare the core package with a full dependency set.
If you want a resettable environment for this tutorial, a rented Mac from Macstripe can give you a clean machine image for the minimal workflow, then a separate test environment for the graph-store and LLM extras. That does not replace owning hardware for stable, continuous workloads or setups that require local peripherals, but it can be a cleaner choice for short experiments, compatibility checks, and reproducible deployment trials. You can review the available Mac configuration and ordering options when you need a temporary environment rather than another permanent local installation.