# Adala

> An open-source Python framework from HumanSignal for autonomous data-labeling agents that learn their instructions from a ground-truth dataset, then label new data with an LLM

- Category: Data & Labeling / Labeling & Annotation
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/HumanSignal/Adala
- Website: https://humansignal.github.io/Adala/
- Canonical page: https://ai-tldr.dev/tools/adala/

## In short

Adala — short for Autonomous DAta (Labeling) Agent — is an open-source Python framework from HumanSignal, the team behind Label Studio, for building agents that process and label data. It sits in the Labeling & Annotation category of the Data & Labeling tools and is open-source, written in Python and licensed Apache-2.0.

## Overview

Adala — short for Autonomous DAta (Labeling) Agent — is an open-source Python framework from HumanSignal, the team behind Label Studio, for building agents that process and label data. Instead of hand-tuning a prompt until an LLM classifies your rows correctly, you give an Adala agent a small ground-truth dataset and a first-draft instruction, and the agent iterates on that instruction itself: it predicts, checks its predictions against the ground truth, analyses the errors, and refines the instruction before trying again.

The framework is built from a few named pieces. An environment supplies the data and the feedback — in the simplest case a `StaticEnvironment` wrapping a pandas DataFrame of labelled examples. Skills describe the task: `ClassificationSkill`, summarization, question answering, translation, text generation and ontology creation are among the ready-made ones, each with an instruction plus input and output templates. Runtimes are the LLMs that execute a skill; the README calls a runtime "synonymous with LLM". An agent ties these together, with separate teacher runtimes used during learning so a stronger model can improve the prompts a cheaper model then runs.

In practice the loop is two calls. `agent.learn(learning_iterations=3, accuracy_threshold=0.95)` runs the self-improvement cycle until the accuracy target or the iteration cap is reached, and `agent.run(test_df)` applies the learned skill to unlabelled rows and returns a DataFrame of predictions. Skills can also be chained into skill sets for multi-step processing, and the README shows swapping the OpenAI runtime for any OpenAI-compatible endpoint such as OpenRouter to run Claude, Gemini or other models.

## What it does

- Self-improving skills: `agent.learn()` predicts on a ground-truth set, validates against it, analyses the errors and refines the skill's instructions over a set number of iterations or until an accuracy threshold is met
- Ready-made skills for classification (with or without chain-of-thought), summarization, question answering, translation, text generation and ontology creation, each defined by instructions plus input and output templates
- Controllable output — labels, templates and constraints are configured per skill, so results stay inside the categories you define
- Pluggable runtimes: `OpenAIChatRuntime` out of the box, any OpenAI-compatible endpoint via `base_url`, and separate teacher runtimes for the learning phase
- Skill sets that pass one skill's output to the next for tasks that need several processing steps
- Works natively with pandas DataFrames in notebooks and scripts, with Colab-ready example notebooks for each skill

## Getting started

Adala runs as a Python library, typically inside a notebook. The README's quickstart trains a sentiment classifier from six labelled examples and then labels three new sentences. It uses OpenAI by default; the last step shows the OpenRouter variant for other models.

1. Install the package

   The README recommends installing from GitHub to pick up frequent updates; a Poetry-based developer install is also documented.

```bash
pip install adala
# or, for the development version
pip install git+https://github.com/HumanSignal/Adala.git
```

2. Set your API key

```bash
export OPENAI_API_KEY='your-openai-api-key'
```

3. Define an agent with an environment, a skill and runtimes

   The environment wraps a labelled DataFrame (columns `text` and `sentiment` in the README example); the skill declares the labels and templates.

```python
from adala.agents import Agent
from adala.environments import StaticEnvironment
from adala.skills import ClassificationSkill
from adala.runtimes import OpenAIChatRuntime

agent = Agent(
    environment=StaticEnvironment(df=train_df),
    skills=ClassificationSkill(
        name='sentiment',
        instructions="Label text as positive, negative or neutral.",
        labels=["Positive", "Negative", "Neutral"],
        input_template="Text: {text}",
        output_template="Sentiment: {sentiment}"
    ),
    runtimes={'openai': OpenAIChatRuntime(model='gpt-4o')},
    teacher_runtimes={'default': OpenAIChatRuntime(model='gpt-4o')},
    default_runtime='openai',
)
```

4. Learn, then label new data

   `learn` refines the skill against the ground truth; `run` applies it to unlabelled rows and returns the predictions.

```python
agent.learn(learning_iterations=3, accuracy_threshold=0.95)
predictions = agent.run(test_df)
print(predictions)
```

5. Use another model through an OpenAI-compatible endpoint

   Set `OPENROUTER_API_KEY` and point the runtime at OpenRouter to use Claude, Gemini or other models; use the same kind of runtime under `teacher_runtimes`.

```python
import os

runtimes = {
    'openrouter': OpenAIChatRuntime(
        base_url="https://openrouter.ai/api/v1",
        model="anthropic/claude-3.5-haiku",
        api_key=os.getenv("OPENROUTER_API_KEY"),
        provider="Custom"
    ),
}
```

## When to use it

- Reach for it when you have a few hundred labelled rows and want an LLM to label the rest without hand-tuning the prompt yourself
- Reach for it when a classification or summarization prompt needs to be measured against ground truth rather than judged by eye
- Reach for it when you want a stronger teacher model to improve instructions that a cheaper model then runs across a large DataFrame
- Reach for it when a data-processing task spans several steps that can be expressed as a chain of skills
