# iryna-kondr/scikit-llm architecture

> Architecture diagram of the GitHub repository iryna-kondr/scikit-llm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/iryna-kondr/scikit-llm
- Repository: https://github.com/iryna-kondr/scikit-llm

## Overview

Scikit-LLM exposes scikit-learn-style estimators that turn text into classifications, labels, summaries, translations, and vectors using language-model providers. The principal workflow is to configure credentials, load text and optional labels, fit an estimator, build prompts, call a provider, and return predictions. Few-shot classification can additionally embed examples and retrieve neighbors from an in-memory index. The graph preserves provider and task branches documented by the source tree; some unsampled implementations are represented at their existing directories, and their unverified links are omitted.

Main entry points: [`skllm/models`](https://github.com/iryna-kondr/scikit-llm/tree/main/skllm/models) (Classification estimators), [`skllm/llm/gpt/mixin.py`](https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/llm/gpt/mixin.py) (GPT adapter), [`skllm/llm/anthropic/mixin.py`](https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/llm/anthropic/mixin.py) (Anthropic adapter), [`skllm/llm/base.py`](https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/llm/base.py) (Provider interfaces)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_tasks["Text tasks"]
  node_classify["Classification estimators"]
  node_transform["Text transforms"]
  node_tag["Entity tagging"]
  node_vectorizer["GPT vectorizer<br/>[vectorization.py]"]
end

subgraph group_providers["Model providers"]
  node_gpt["GPT adapter<br/>[mixin.py]"]
  node_anthropic["Anthropic adapter<br/>[mixin.py]"]
  node_vertex["Vertex adapter<br/>[mixin.py]"]
  node_openaiembed["OpenAI embeddings<br/>[embedding.py]"]
end

subgraph group_shared["Shared runtime"]
  node_baseclf["Classifier runtime<br/>[classifier.py]"]
  node_basetext["Text task runtime<br/>[text2text.py]"]
  node_basetag["Tagging runtime<br/>[tagger.py]"]
  node_basevec["Vectorizer runtime<br/>[vectorizer.py]"]
  node_prompts["Prompt builders<br/>[builders.py]"]
  node_templates["Prompt templates<br/>[templates.py]"]
  node_llmbase["Provider interfaces<br/>[base.py]"]
end

subgraph group_examples["Examples and memory"]
  node_memory[("Similarity indexes")]
end

subgraph group_setup["Configuration and data"]
  node_config["Credentials config<br/>[config.py]"]
  node_datasets["Task datasets"]
  node_constants["Model defaults<br/>[model_constants.py]"]
end

node_user(("Estimator user"))
node_provider(("LLM services"))

node_user -->|"fits and predicts"| node_classify
node_user -->|"loads examples"| node_datasets
node_classify -.->|"uses runtime"| node_baseclf
node_transform -.->|"uses runtime"| node_basetext
node_tag -.->|"uses runtime"| node_basetag
node_vectorizer -->|"extends"| node_basevec
node_baseclf -->|"implements interface"| node_llmbase
node_basevec -->|"implements interface"| node_llmbase
node_baseclf -->|"builds prompts"| node_prompts
node_prompts -->|"uses templates"| node_templates
node_classify -->|"mixes in"| node_gpt
node_classify -->|"mixes in"| node_anthropic
node_classify -->|"mixes in"| node_vertex
node_transform -->|"mixes in"| node_gpt
node_transform -->|"mixes in"| node_vertex
node_tag -.->|"mixes in"| node_gpt
node_tag -.->|"mixes in"| node_anthropic
node_gpt -->|"implements interface"| node_llmbase
node_anthropic -->|"implements interface"| node_llmbase
node_vertex -->|"implements interface"| node_llmbase
node_gpt -->|"reads credentials"| node_config
node_anthropic -->|"reads credentials"| node_config
node_gpt -->|"requests completions"| node_provider
node_vertex -->|"requests completions"| node_provider
node_anthropic -->|"requests completions"| node_provider
node_gpt -->|"requests embeddings"| node_openaiembed
node_vectorizer -->|"gets embeddings"| node_gpt
node_classify -->|"embeds examples"| node_vectorizer
node_classify -->|"retrieves neighbors"| node_memory
node_classify -->|"uses defaults"| node_constants
node_transform -.->|"uses defaults"| node_constants

click node_classify "https://github.com/iryna-kondr/scikit-llm/tree/main/skllm/models"
click node_transform "https://github.com/iryna-kondr/scikit-llm/tree/main/skllm/models"
click node_tag "https://github.com/iryna-kondr/scikit-llm/tree/main/skllm/models"
click node_vectorizer "https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/models/gpt/vectorization.py"
click node_baseclf "https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/models/_base/classifier.py"
click node_basetext "https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/models/_base/text2text.py"
click node_basetag "https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/models/_base/tagger.py"
click node_basevec "https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/models/_base/vectorizer.py"
click node_prompts "https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/prompts/builders.py"
click node_templates "https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/prompts/templates.py"
click node_llmbase "https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/llm/base.py"
click node_gpt "https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/llm/gpt/mixin.py"
click node_anthropic "https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/llm/anthropic/mixin.py"
click node_vertex "https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/llm/vertex/mixin.py"
click node_openaiembed "https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/llm/gpt/clients/openai/embedding.py"
click node_config "https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/config.py"
click node_datasets "https://github.com/iryna-kondr/scikit-llm/tree/main/skllm/datasets"
click node_memory "https://github.com/iryna-kondr/scikit-llm/tree/main/skllm/memory"
click node_constants "https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/model_constants.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_classify,node_transform,node_tag,node_vectorizer,node_user toneBlue
class node_gpt,node_anthropic,node_vertex,node_openaiembed toneAmber
class node_baseclf,node_basetext,node_basetag,node_basevec,node_prompts,node_templates,node_llmbase toneMint
class node_memory toneRose
class node_config,node_datasets,node_constants,node_provider toneIndigo
```

## Components

### Text tasks

- [Classification estimators](https://github.com/iryna-kondr/scikit-llm/tree/main/skllm/models): `skllm/models`
- [Text transforms](https://github.com/iryna-kondr/scikit-llm/tree/main/skllm/models): `skllm/models`
- [Entity tagging](https://github.com/iryna-kondr/scikit-llm/tree/main/skllm/models): `skllm/models`
- [GPT vectorizer](https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/models/gpt/vectorization.py): `skllm/models/gpt/vectorization.py`

### Model providers

- [GPT adapter](https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/llm/gpt/mixin.py): `skllm/llm/gpt/mixin.py`
- [Anthropic adapter](https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/llm/anthropic/mixin.py): `skllm/llm/anthropic/mixin.py`
- [Vertex adapter](https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/llm/vertex/mixin.py): `skllm/llm/vertex/mixin.py`
- [OpenAI embeddings](https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/llm/gpt/clients/openai/embedding.py): `skllm/llm/gpt/clients/openai/embedding.py`

### Shared runtime

- [Classifier runtime](https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/models/_base/classifier.py): `skllm/models/_base/classifier.py`
- [Text task runtime](https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/models/_base/text2text.py): `skllm/models/_base/text2text.py`
- [Tagging runtime](https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/models/_base/tagger.py): `skllm/models/_base/tagger.py`
- [Vectorizer runtime](https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/models/_base/vectorizer.py): `skllm/models/_base/vectorizer.py`
- [Prompt builders](https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/prompts/builders.py): `skllm/prompts/builders.py`
- [Prompt templates](https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/prompts/templates.py): `skllm/prompts/templates.py`
- [Provider interfaces](https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/llm/base.py): `skllm/llm/base.py`

### Examples and memory

- [Similarity indexes](https://github.com/iryna-kondr/scikit-llm/tree/main/skllm/memory): `skllm/memory`

### Configuration and data

- [Credentials config](https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/config.py): `skllm/config.py`
- [Task datasets](https://github.com/iryna-kondr/scikit-llm/tree/main/skllm/datasets): `skllm/datasets`
- [Model defaults](https://github.com/iryna-kondr/scikit-llm/blob/main/skllm/model_constants.py): `skllm/model_constants.py`

### Other components

- **Estimator user**
- **LLM services**

## Connections

- Estimator user → Classification estimators: fits and predicts (evidence: `README.md`)
- Estimator user → Task datasets: loads examples (evidence: `README.md`)
- Classification estimators → Classifier runtime: uses runtime (evidence: `skllm/models/gpt/classification/few_shot.py`)
- Text transforms → Text task runtime: uses runtime (evidence: `skllm/models/gpt/text2text/tunable.py`)
- Entity tagging → Tagging runtime: uses runtime
- GPT vectorizer → Vectorizer runtime: extends (evidence: `skllm/models/gpt/vectorization.py`)
- Classifier runtime → Provider interfaces: implements interface (evidence: `skllm/models/_base/classifier.py`)
- Vectorizer runtime → Provider interfaces: implements interface (evidence: `skllm/models/_base/vectorizer.py`)
- Classifier runtime → Prompt builders: builds prompts (evidence: `skllm/models/_base/classifier.py`)
- Prompt builders → Prompt templates: uses templates (evidence: `skllm/prompts/builders.py`)
- Classification estimators → GPT adapter: mixes in (evidence: `skllm/models/gpt/classification/few_shot.py`)
- Classification estimators → Anthropic adapter: mixes in (evidence: `skllm/models/anthropic/classification/few_shot.py`)
- Classification estimators → Vertex adapter: mixes in (evidence: `skllm/models/vertex/classification/zero_shot.py`)
- Text transforms → GPT adapter: mixes in (evidence: `skllm/models/gpt/text2text/summarization.py`)
- Text transforms → Vertex adapter: mixes in (evidence: `skllm/models/vertex/text2text/tunable.py`)
- Entity tagging → GPT adapter: mixes in (evidence: `skllm/models/gpt/classification/few_shot.py`)
- Entity tagging → Anthropic adapter: mixes in (evidence: `skllm/models/anthropic/classification/few_shot.py`)
- GPT adapter → Provider interfaces: implements interface (evidence: `skllm/llm/gpt/mixin.py`)
- Anthropic adapter → Provider interfaces: implements interface (evidence: `skllm/llm/anthropic/mixin.py`)
- Vertex adapter → Provider interfaces: implements interface (evidence: `skllm/llm/vertex/mixin.py`)
- GPT adapter → Credentials config: reads credentials (evidence: `skllm/llm/gpt/mixin.py`)
- Anthropic adapter → Credentials config: reads credentials (evidence: `skllm/llm/anthropic/mixin.py`)
- GPT adapter → LLM services: requests completions (evidence: `skllm/llm/gpt/mixin.py`)
- Vertex adapter → LLM services: requests completions (evidence: `skllm/llm/vertex/mixin.py`)
- Anthropic adapter → LLM services: requests completions (evidence: `skllm/llm/anthropic/mixin.py`)
- GPT adapter → OpenAI embeddings: requests embeddings
- GPT vectorizer → GPT adapter: gets embeddings (evidence: `skllm/models/gpt/vectorization.py`)
- Classification estimators → GPT vectorizer: embeds examples (evidence: `skllm/models/gpt/classification/few_shot.py`)
- Classification estimators → Similarity indexes: retrieves neighbors (evidence: `skllm/models/gpt/classification/few_shot.py`)
- Classification estimators → Model defaults: uses defaults (evidence: `skllm/models/gpt/classification/few_shot.py`)
- Text transforms → Model defaults: uses defaults (evidence: `skllm/models/gpt/classification/few_shot.py`)
