Spectre.Training.Dataset (Spectre v0.3.0)

Copy Markdown View Source

Builds classifier datasets from Spectre agent routing metadata.

Training examples live in configured dataset sources. Rows must carry a label or intent, and this module exports only labels that exist on the agent's routes or policy branches.

{:ok, rows} =
  Spectre.Training.Dataset.from_agent(MyApp.Agent,
    source: "training/raw_intents.jsonl"
  )

Summary

Functions

Collects classifier rows from labeled dataset sources for the agent's known route and policy labels.

Types

row()

@type row() :: %{text: String.t(), label: String.t()}

Functions

from_agent(agent, opts \\ [])

@spec from_agent(
  module(),
  keyword()
) :: {:ok, [row()]} | {:error, term()}

Collects classifier rows from labeled dataset sources for the agent's known route and policy labels.

Supported dataset files:

  • .json files - list of objects with text and label/intent.
  • .jsonl files - one JSON object per line with text and label/intent.
{:ok, rows} = Spectre.Training.Dataset.from_agent(MyApp.Agent)