TrustGraphGet Started

Flows (TrustGraph)

TrustGraph's term for processing pipelines - sequences of operations that transform data as it moves through the system, from ingestion to knowledge graph construction.

TrustGraph Concepts

Flows in TrustGraph are processing pipelines that define how data moves through the system, from raw input to structured knowledge.

Flow Architecture

Input → Stage 1 → Stage 2 → Stage 3 → Output
        ↓         ↓         ↓
      Process   Transform  Store

Example Ingestion Flow

// Define a custom flow
const ingestionFlow = await trustgraph.flows.create({
  name: "document-to-graph",
  stages: [
    {
      name: "extract-text",
      processor: "pdf-extractor",
      config: {
        ocr: true,
        language: "en"
      }
    },
    {
      name: "extract-entities",
      processor: "ner-extractor",
      config: {
        model: "en_core_web_lg",
        entityTypes: ["PERSON", "ORG", "GPE"]
      }
    },
    {
      name: "extract-relationships",
      processor: "relation-extractor",
      config: {
        model: "relation-bert",
        minConfidence: 0.7
      }
    },
    {
      name: "build-graph",
      processor: "graph-builder",
      config: {
        deduplication: true,
        linkingStrategy: "semantic"
      }
    },
    {
      name: "index-vectors",
      processor: "vector-indexer",
      config: {
        embeddingModel: "text-embedding-3-large"
      }
    }
  ]
});

// Execute flow
await ingestionFlow.process({
  source: "documents/report.pdf"
});

Query Flow

// Query flows process user requests
const queryFlow = await trustgraph.flows.create({
  name: "graph-rag-query",
  stages: [
    {
      name: "vector-search",
      processor: "vector-retriever",
      config: { topK: 10 }
    },
    {
      name: "graph-traversal",
      processor: "graph-expander",
      config: { depth: 3 }
    },
    {
      name: "context-fusion",
      processor: "context-assembler",
      config: { strategy: "weighted" }
    },
    {
      name: "llm-generation",
      processor: "llm-generator",
      config: { model: "gpt-4-turbo" }
    }
  ]
});

// Execute query flow
const result = await queryFlow.process({
  query: "How does Company A affect Market B?"
});

Flow Classes

Flows can be grouped into classes for reusability (see Flow Classes).

Benefits

  • Modularity: Reusable pipeline stages
  • Flexibility: Easy to modify or extend
  • Monitoring: Track performance of each stage
  • Parallelization: Stages can run in parallel when possible

See Also

Examples

  • Document ingestion flow: PDF → text extraction → entity extraction → graph insertion
  • Query flow: user query → vector search → graph traversal → context assembly → LLM generation

Related Terms

Learn More