Skip to content

Getting Started

The classifier runs as a set of services with an HTTP API. This page explains how to start the services on your own machine with Docker Compose and how to send a first request. It follows the default branch of the repository as of November 2026.

The Python library that earlier versions of this page described (the inference package with the EntityLinker class) is no longer part of the repository.

The services are built and started with Docker Compose. Python and Poetry are needed only to work on a single service outside Docker.

  • A recent version of git (e.g. ^2.37 )
  • Git LFS
  • Docker with Docker Compose
  • A MongoDB database that the Classify service can reach

This tool uses Git LFS for handling large files. Before using it you need to install and set up Git LFS on your local machine. See https://git-lfs.com/ for installation instructions.

After Git LFS is set up, follow these steps to clone the repository:

Terminal window
git clone https://github.com/tabiya-tech/tabiya-livelihoods-classifier.git

If you already cloned the repository without Git LFS, run:

Terminal window
git lfs pull

The services read their settings from a .env file in the root directory of the repository. Create it from the example file:

Terminal window
cp .env.example .env

Then set the values for your setup. The table lists the main variables as of November 2026. The file .env.example in the repository holds the full, current list with comments.

Variable What it sets
APPLICATION_MONGODB_URI Connection string of the MongoDB database. The Classify service connects to it at startup and stops if the connection fails.
MONGODB_DB_NAME Name of the database that stores API keys, user settings, usage records, and batch jobs.
HF_TOKEN Hugging Face access token for downloading the extraction model. See the note below the table.
TARGET_ENVIRONMENT_TYPE With local, the Classify service accepts requests without an API key. The example file sets local.
TARGET_LANGUAGE Language for requests that name none: en or es. The default is en.
ENABLED_LANGUAGES Languages whose models are loaded at startup. The other registered languages are loaded on the first request that uses them. When the variable is unset, the Compose file loads every registered language at startup.
NER_MODEL, NER_MODEL_<LANG> Extraction model for every language, or for one language.
LINKER_MODEL, LINKER_MODEL_<LANG> Embedding model for linking, for every language or for one language.
NEL_FILES_PATH Directory of the taxonomy label files. Leave it unset to use the files that are stored with the service for each language.
MAX_TEXT_LENGTH, MAX_BATCH_SIZE, MAX_ENTITIES_PER_REQUEST, MAX_TOP_K Limits on the size of a request.
NER_API_URL, NEL_API_URL Addresses at which the Classify service reaches the two other services. The Compose file sets them.
API_KEY_CACHE_TTL Number of seconds for which the Classify service caches the lookup of an API key.

The Compose file does not start a MongoDB database. Use a MongoDB Atlas cluster or any other MongoDB instance that the Classify container can reach. Inside a container, localhost refers to the container itself.

ATTENTION: The .env file should be kept secure and not shared with others as it contains sensitive information.

Start the three services from the root directory of the repository:

Terminal window
docker compose up

The first run builds the images and downloads the language models. It takes longer than later starts. The services listen on these ports:

Service Port
Classify 5001
NER 5002
NEL 5003

Check that the services are ready:

Terminal window
curl http://localhost:5001/v1/health

The response reports the status healthy once the NER and NEL services have loaded their models. Before that, it reports degraded.

Each service is a separate Poetry project with its own pyproject.toml, under backend/ner, backend/nel, and backend/classify. The pyproject.toml in the root directory installs no packages. To work on one service, install its dependencies in its own directory, for example with cd backend/ner && poetry install. The services need Python 3.10 or higher. The Dockerfile of each service shows the command that starts it.

Training and evaluation are separate projects too, in the training/ and evaluation/ directories. See Training.

The Classify service extracts occupations, skills, and qualifications from a job description and matches them to the most similar entries in the taxonomy.

Send the text of a job description to POST /v1/classify:

Terminal window
curl -X POST http://localhost:5001/v1/classify \
-H "content-type: application/json" \
-d '{"text": "We need a head chef who can plan menus."}'

With TARGET_ENVIRONMENT_TYPE=local, the service needs no API key. A deployment that checks API keys expects the key in the x-api-key header.

The request body takes these fields:

Field Meaning
text The job text. Send either text, or title and description.
title, description Job title and job description. The service joins them when text is absent.
options.extract_entities Entity types to extract: occupation, skill, qualification. The default is all three.
options.top_k Maximum number of taxonomy matches per entity, from 1 to 50. The default is 5.
options.min_similarity Minimum cosine similarity of a match, from 0.0 to 1.0. The default is 0.0.
options.language Language of the text: en or es. See Languages.

The response is a JSON object with two parts:

  • classification holds the result. classification.entities lists the entities found. Each entity has an entity_type, a surface_form (the text as it appears in the input), a span with the start and end character positions, and linked_entities, the taxonomy matches in descending order of similarity_score. Every match has a label. A match for an occupation also has a code and a uri, a match for a skill has a uri, and a match for a qualification has an eqf_level. classification.entity_counts gives the number of entities per type.
  • metadata records the classifier version, the extraction model, the linking model, the processing time, a hash of the input text, the language, and the locale of the taxonomy labels.

The fields are defined in backend/classify/classify/models.py and backend/nel/nel/models.py. A running Classify service also serves an interactive API reference (Swagger UI) at /docs, for example at http://localhost:5001/docs.

Endpoint Service Purpose
POST /v1/classify/batch Classify Accepts a list of jobs, answers at once with a batch_id, and processes the jobs in the background.
GET /v1/batch/{batch_id}/status Classify Reports how many jobs of a batch have been processed.
GET /v1/batch/{batch_id}/results Classify Returns the results of a batch.
POST /v1/ner NER Runs the extraction step alone.
POST /v1/nel NEL Runs the linking step alone, on entities that the caller supplies.
GET /v1/health, GET /v1/version Classify Report the status and the version of the service.

The repository also contains a second version of the linking and Classify services, with endpoints under /v2/. They are not part of the Compose file, and this page does not cover them.

As of November 2026, the classifier has two registered languages: English (en) and Spanish (es). One deployment serves both. The language is an input of each request:

Terminal window
curl -X POST http://localhost:5001/v1/classify \
-H "content-type: application/json" \
-d '{"text": "Se busca cocinero con experiencia en cocina.", "options": {"language": "es"}}'

The service determines the language of a request in this order: options.language, then the language configured for the API key, then TARGET_LANGUAGE, then English. A language that is not registered falls back to the default language, and the service logs a warning. The field metadata.language in the response records the language that was used.

Linking for Spanish uses Spanish taxonomy labels and, by default, a multilingual embedding model. A NER_MODEL or LINKER_MODEL value without a language suffix applies to every language, and the example .env file sets both. Before you send Spanish requests, remove the LINKER_MODEL line from your .env file or uncomment its LINKER_MODEL_ES line.

The French linker that earlier versions of this page described is not part of the current code. The repository README explains how to add a language.

The evaluation code is a separate Poetry project in the evaluation/ directory of the repository. Its runner evaluates the linking step for one entity type:

Terminal window
python -m evaluation.run --entity-type Skill --files-dir <files-dir>

--entity-type takes Occupation, Skill, or Qualification. --files-dir is a directory that holds the taxonomy label files, their embedding caches, and, in a subdirectory eval/, the annotated evaluation files. --output-json <file> also writes the metrics to a file.

Install the project first with poetry install in the evaluation/ directory. The evaluator imports the linker as backend.nel.nel.linker. The root directory of the repository must therefore be on the Python path, for example through the PYTHONPATH environment variable.

As of November 2026, the default branch of the repository does not contain the annotated evaluation files. The tagged release v0.0.1 holds them, as Git LFS files, in inference/files/eval/. Datasets describes the evaluation datasets and their sources.

The repository states no minimum hardware requirement. The service images install a CPU-only build of PyTorch, and the services run without a GPU.