# Core concepts

> Organizations, continuous models and their production and preview versions, names, base models, custom projects, datasets, runs, evaluations and futures.

Part of the Endor docs. Index of every page: https://endor.thetokencompany.com/llms.txt. HTML version: https://endor.thetokencompany.com/docs/concepts.

```text
organization
├─ continuous models   each learns by itself on one base model: "tickets"
│  └─ versions         v1, v2, ...: the one in production is "tickets", a newer one waiting "tickets:preview"
└─ custom projects     models you train with the SDK, "router-2"
   └─ for training them: datasets, runs and evaluations
```

## Organization

An organization owns all resources. An API key (`edk_...`) belongs to one organization. Create keys in the dashboard.

## Continuous model

A continuous model answers your decisions and learns by itself from them; feedback on them is optional. It has one base model, from the [catalog](https://endor.thetokencompany.com/docs/base-models), chosen when you create it. The base model never changes. See [Continuous models](https://endor.thetokencompany.com/docs/continuous-learning).

> **Invited organizations only.** Continuous models are only available to invited organizations (email rasmus@thetokencompany.com to ask). Until then, calls to continuous models fail with `403 continuous_learning_not_enabled`. Use [custom projects](https://endor.thetokencompany.com/docs/training) instead.

```python
import endor

client = endor.EndorClient()
project = client.projects.create("tickets", base_model="mapika/decider-2b")
```

## Versions

A continuous model gets better in versions: `v1`, `v2`, and so on. Two of them can be called:

| `model` | Answers with |
|---|---|
| `tickets` | The **production** version. Before the first version, the base model. |
| `tickets:preview` | The **preview**: the newest version, while it isn't in production (with auto-promote off). Otherwise `404 no_preview`. |

With **auto-promote** on (the default for a new continuous model), each new version goes to production at once. Turn it off and a new version waits as the preview until you promote it. You can promote any version to production, and promoting an older one is a rollback. See [Production and preview](https://endor.thetokencompany.com/docs/continuous-learning#production-and-preview).

## Names

Continuous models and the models of custom projects share one list of names in an organization, so a continuous model and a saved model can't have the same name. Names use lowercase letters, digits, `.`, `_` and `-` (63 characters maximum), and can't be a base model's name (the part of its id after `owner/`). `:` separates a continuous model from its version, as in `tickets:preview`.

## Base model

A base model is an open decision model from the [catalog](https://endor.thetokencompany.com/docs/base-models). Its id is `owner/model`, as on Hugging Face: `mapika/decider-2b`. You choose one when you create a continuous model or a custom project, or call it directly with its id as `model`.

## Contract

Each base model has a contract: how Endor turns the state and a question into the model's input, and how it reads the probabilities. The contract decides which parts of a question the model reads, so the same question can need other wording on another base model. For example, this yes/no question puts its meaning in a `true` description:

```json
{"type": "noul", "instructions": "Is it urgent?", "criteria": {"true": "The customer needs an answer today"}}
```

`mapika/decider-2b` reads the description. `autotrust/gev-26b` reads a `noul` from its `instructions` only, so there the question fails with `422 invalid_options`. Written as `{"type": "noul", "instructions": "Does the customer need an answer today?"}`, it works on both. See [Rules for each base model](https://endor.thetokencompany.com/docs/base-models#rules-for-each-base-model).

## Custom project

In a custom project, you train a model yourself with the SDK: a LoRA adapter on a base model, saved under a name. A saved model is **archived**: you can download and evaluate it, but decisions can't call it. Promote it to **production** to call it by its name, for example `router-2`. An organization can have 3 models from custom projects in production; ask for more. Each save is a new model. See [Custom projects](https://endor.thetokencompany.com/docs/training).

## Dataset

A dataset is a named list of [decision rows](https://endor.thetokencompany.com/docs/data-format), 50,000 rows maximum, for evaluating your trained models and base models. You cannot change a dataset. To change the data, upload a new dataset with a different name.

Training calls do not use datasets: they send the data in the request.

## Run

A run trains a custom project's model on one base model, on a GPU that it shares with other runs of that base model. Each call of a run runs alone. You send training calls to the run (see [Custom projects](https://endor.thetokencompany.com/docs/training#the-loop)).

| Status | Meaning |
|---|---|
| `provisioning` | The run waits for a GPU and loads. On a GPU that runs the base model already, this takes seconds; when a GPU has to start, a few minutes. |
| `ready` | The run is on a GPU and accepts training calls. |
| `idle` | No calls for 2 minutes. Endor saved the state and freed the GPU. The next call resumes the run in seconds. |
| `closing` | The run accepts no new calls. Accepted calls finish. |
| `closed` | The run is done. Saved models stay. |
| `failed` | The GPU stopped. `failure` gives the cause. |

## Evaluation

An evaluation scores a model from a custom project (in production or archived) or a base model on a dataset, or on rows sent with the call. It gives accuracy, NLL, Brier score, ECE, mean confidence and selective accuracy: for all questions, for each question type and for each question. Rows without labels are answered, not scored.

- `client.evaluations.create(model, dataset)` (or `rows=...`) runs on the server. Endor bills it as decisions.
- `client.predict(model, rows)` is an evaluation of rows without labels: it returns the answers for each row, in order.
- `run.log_eval(model, results, step=..., name=...)` records results that you calculated. It is free.

## Future

Slow operations return a future immediately: run start, `forward`, `forward_backward`, `optim_step`, `save_checkpoint` and server evaluations. The status of a future is `pending`, `running`, `completed`, `failed` or `cancelled`.

Call `.result()` to wait for one future. Call `endor.gather(...)` to wait for many futures. In a training loop, `endor.Steps` sends the next step before you read the results of the last one (see [Custom projects](https://endor.thetokencompany.com/docs/training#the-loop)).

## Other pages

- [Overview](https://endor.thetokencompany.com/docs/index.md): What Endor does: you train decision models on your labeled data in custom projects with the SDK, Endor runs the GPUs, and you call them by name. Continuous models are for invited organizations.
- [Quickstart](https://endor.thetokencompany.com/docs/quickstart.md): Start here: install the SDK, measure base models on your data, train a model in a custom project, evaluate it, promote it and call it.
- [Custom projects](https://endor.thetokencompany.com/docs/training.md): Custom projects (custom_models in the SDK and API): train a model with the SDK, save, promote to production, call, download; the training loop in detail.
- [Continuous models](https://endor.thetokencompany.com/docs/continuous-learning.md): Continuous models (projects in the SDK and API), only available to invited organizations: create one, call its production version or its preview, auto-promote, promote and roll back versions, feedback, price.
- [Decisions](https://endor.thetokencompany.com/docs/decisions.md): Decisions with the SDK and over HTTP, model names, giving feedback on them, TypeSafe clients, cold starts, errors.
- [Base models](https://endor.thetokencompany.com/docs/base-models.md): The 18 base models: limits, rules, prices and cold starts.
- [Billing & limits](https://endor.thetokencompany.com/docs/billing.md): Prices, the prepaid balance, usage and limits.
- [Data format](https://endor.thetokencompany.com/docs/data-format.md): Decision rows, question types, hard and soft labels, datums and limits: the data for custom projects.
- [API reference](https://endor.thetokencompany.com/docs/api.md): Each /v1 endpoint: method, path, body fields, response fields and errors.
- [Python SDK](https://endor.thetokencompany.com/docs/sdk.md): The Python SDK (0.9.0): client, continuous models (client.projects) and versions, custom projects (client.custom_models), datasets, runs, evaluations, futures, data helpers, recipes, errors, CLI.
- [Updates](https://endor.thetokencompany.com/docs/updates.md): Changes to the API and SDK, newest first, and when old names and endpoints stop working.
- [Index](https://endor.thetokencompany.com/llms.txt): every page and the API schema.
