/\ ATFGraph /docs
README Downloads
Examples / ATFGraph
Framework reference

This article is retained from the existing framework docs. Self-hosting commands and server-admin access differ from the managed CLI workflow. Start with Get started for the installed product.

Semantic & hybrid retrieval

Directory examples/python/features/retrieval

Compare lexical, semantic and hybrid search over one global document collection. The server stores chunks and BM25 citations; SemanticKnowledge embeds chunks and stores vectors as kb:desk:<doc_id>#<ordinal> in scoped memory. Returned semantic hits are checked against current document revisions so stale vectors are excluded.

Agent node label retrieval_desk, version 1.0.0.

Capabilities

CapabilityKindSignatureModuleSummary
asktraversal(question: str, mode: str = 'hybrid', top_k: int = 5, kind: Optional[str] = None) -> Answerexamples/python/features/retrieval/agent.pyRanked passages with citations. ``mode`` is ``hybrid``, ``semantic`` or
forgettraversal(doc_id: str) -> dictexamples/python/features/retrieval/agent.pyDelete one document and its vectors.
ingesttraversal(documents: List[Dict[str, Any]]) -> dictexamples/python/features/retrieval/agent.pyAtomic lexical batch, then indexing. A failed embedding step is reported per
reindextraversal(doc_id: Optional[str] = None) -> dictexamples/python/features/retrieval/agent.pyRebuild vectors for one document or for the whole scope.
statustraversal() -> dictexamples/python/features/retrieval/agent.py

Commands

Taken from this example's own README and module docstrings.

python -m atfgraph.worker --module examples.python.features.retrieval.agent:app
python -m examples.python.features.retrieval.call

Files

  • examples/python/features/retrieval/README.md
  • examples/python/features/retrieval/__init__.py
  • examples/python/features/retrieval/agent.py
  • examples/python/features/retrieval/agentnode.yaml
  • examples/python/features/retrieval/call.py
  • examples/python/features/retrieval/embeddings.py
  • examples/python/features/retrieval/fixtures.py

README

Rendered from examples/python/features/retrieval/README.md; the source file is not modified.

Compare lexical, semantic and hybrid search over one global document collection. The server stores chunks and BM25 citations; SemanticKnowledge embeds chunks and stores vectors as kb:desk:<doc_id>#<ordinal> in scoped memory. Returned semantic hits are checked against current document revisions so stale vectors are excluded.

TraversalSurfaceNotes
ingest(documents)SemanticKnowledge.put_many(strict=False)atomic lexical batch, then bounded-concurrency embedding and memory.vector.set; per-document failures are returned, not raised
ask(question, mode, top_k, kind)SemanticKnowledge.searchhybrid (default) / semantic / lexical; kind filters document metadata on both rankings; passages carry both scores and ranks, stale lists dropped vectors
forget(doc_id)SemanticKnowledge.deletetombstone plus vector removal
reindex(doc_id?)SemanticKnowledge.reindex / reindex_allrepair after an interrupted ingest or a model change
status()SemanticKnowledge.statsknowledge counts plus vectors, indexed documents, model, dimension

Embedding provider

Set ATFGRAPH_EMBEDDING_URL and ATFGRAPH_EMBEDDING_MODEL for an OpenAI-compatible embeddings provider. Without them, embeddings.py uses a deterministic concept lexicon plus token hashing. It deliberately maps terms such as luggage/baggage and charges/fees together. That makes the offline workflow reproducible; it does not measure a learned embedding model's quality.

Run

python -m atfgraph.worker --module examples.python.features.retrieval.agent:app
python -m examples.python.features.retrieval.call

The driver ingests fixtures and queries them in all three modes, showing scores and ranks side by side. It also filters metadata, deletes policy:baggage, checks its removal from results and prints index status.

BM25 and cosine scores use different scales and meanings. Hybrid results retain both rather than treating them as interchangeable. After changing the embedding model or recovering an interrupted ingestion, run reindex.

The semantic-knowledge suite covers request bodies, concurrency, retries, partial failures, stale-vector checks, fake-server execution and real-daemon HTTP behavior. Fixture success does not verify a live embedding endpoint.

ATFGraph documentationHosted workflow · Framework reference