LLM Analysis

Classify, summarize, enrich, and deduplicate data using AI models

Overview

Anysite CLI integrates with LLM providers to add AI-powered analysis to dataset pipeline data. Six operations are available: classify, summarize, enrich, generate, match, and deduplicate. Every operation reads records from a dataset source's collected Parquet files — there is no --file input for arbitrary JSON.

Requires the llm extra: pip install "anysite-cli[llm]"

Setup

# Interactive
anysite llm setup

# Non-interactive (CI/agents)
anysite llm setup --provider openai --api-key sk-... --no-test
anysite llm setup --provider anthropic --api-key-env ANTHROPIC_API_KEY

--api-key accepts the key value directly; --api-key-env references an environment variable instead. --model overrides the default model; --no-test skips the connection test.

Supported Providers

Provider Default Model
OpenAI gpt-4.1-mini
Anthropic claude-sonnet-4-5-20250514

Provider settings are stored under llm.providers.<name> in ~/.anysite/config.yaml.

Operations

Every operation shares this set of options: --provider, --model, --parallel/-j (default 5), --rate-limit, --temperature, --max-tokens, --no-cache, --format/-f, --output/ -o, --quiet/-q, --prompt, --prompt-file, and --dry-run (print the built prompt without calling the LLM).

Classify

anysite llm classify dataset.yaml --source profiles \
  --categories "developer,recruiter,executive,other" \
  --fields "name,headline,summary"

If --categories/-c is omitted, the LLM auto-detects 3-7 categories from the first 20 records. --multi allows more than one category per record. --output-column (default category) names the result column.

Summarize

anysite llm summarize dataset.yaml --source profiles \
  --fields "name,headline,summary,experience" \
  --max-length 50 \
  --output-column bio_summary

--max-length (default 100) caps summary length in words.

Enrich

anysite llm enrich dataset.yaml --source profiles \
  --add "seniority:junior/mid/senior/lead" \
  --add "is_technical:boolean" \
  --add "years_experience:number" \
  --add "primary_skill:string"

Supported attribute types in --add name:spec:

Generate

anysite llm generate dataset.yaml --source profiles \
  --prompt "Write a 2-sentence professional intro for {name} who works as {headline}" \
  --temperature 0.7 \
  --output-column intro_text

Either --prompt or --prompt-file is required. --output-column defaults to text. If --temperature is not given, generate defaults to 0.7; every other operation defaults to 0.0.

Match

anysite llm match dataset.yaml \
  --source-a profiles \
  --source-b companies \
  --top-k 3

Field selection for match uses --fields-a and --fields-b (not the shared --fields). --top-k (default 3) caps matches per source-a record; --threshold (default 0.5) is the minimum match score to keep.

Deduplicate

anysite llm deduplicate dataset.yaml --source profiles \
  --key name \
  --threshold 0.8

--key/-k (default name) blocks records before comparison — only records sharing the first three characters of this field (lowercased) are compared, to limit LLM calls on large sources. --threshold (default 0.8) is the minimum confidence to flag a pair as duplicates.

Using LLM in Dataset Pipelines

sources:
  - id: profiles
    endpoint: /api/linkedin/user
    from_file: users.txt
    input_key: user

  - id: profiles_enriched
    type: llm
    dependency:
      from_source: profiles
      field: name
    llm:
      - type: classify
        categories: "developer,recruiter,executive,sales,other"
        output_column: role_type

      - type: enrich
        add:
          - "seniority:junior/mid/senior/lead"
          - "is_technical:boolean"

      - type: summarize
        max_length: 50
        output_column: bio_summary

Multiple LLM steps can be chained within a single LLM source. They execute in order, each adding new columns to the dataset.

Caching

Responses are cached in ~/.anysite/llm_cache.db to avoid repeated API calls:

anysite llm cache-stats
anysite llm cache-clear
anysite llm classify dataset.yaml --source profiles \
  --categories "dev,recruiter,exec" --no-cache

Options Reference

Option Description Applies To
--source, -s Source to process all (except match, which uses --source-a/--source-b)
--fields Fields to include in the LLM prompt (comma-separated) classify, summarize, enrich, deduplicate, generate
--fields-a / --fields-b Fields from each source match
--categories, -c Comma-separated categories classify
--multi Allow multiple categories per record classify
--add Attribute spec name:type_or_values (repeatable) enrich
--prompt / --prompt-file Custom or file-based prompt template all
--temperature LLM temperature (0.0-1.0) all
--max-tokens Max response tokens all
--max-length Max words for the summary summarize
--output-column Name for the result column classify, summarize, generate
--top-k Number of matches per record match
--key, -k Field to block/compare on deduplicate
--threshold Match or duplicate confidence threshold (0.0-1.0) match, deduplicate
--provider / --model Override the configured LLM provider or model all
--dry-run Print the built prompt without calling the LLM all
--no-cache Skip the LLM cache all

Next Steps

SQL Querying

Query and analyze your enriched data with DuckDB SQL

Examples

See complete end-to-end workflow examples