Skip to content

Keywords from archival text: statistical, and from the controlled vocabularies

The keyword-extract workflow. Tool: atrium-keyword-extract.

Purpose

Finding an archival document by what it is about needs its keywords, and two kinds answer different questions. In the AMČR pipeline this workflow reads the record that nlp-enrich leaves and adds its statistical keywords to it. Statistical keywords are the phrases that characterise a document or a page against the rest of its text; they need no vocabulary, and each says which method found it, with its score and rank. Controlled keywords are given per line. A language model picks the terms of the AMČR keyword lists or the TEATER thesaurus that describe the line, three by default and at most five, the most relevant first, and can only pick terms that exist in the vocabulary. With the terms come the records behind them, the Czech keywords found in the line with their English translations, and the page and line they came from. The controlled kind is research output: no category has been checked against a reviewed answer yet. On its own, the tool also reads nlp-enrich's CoNLL-U and TEITOK files, line tables and plain text.

At a glance

In the ATRIUM document record that nlp-enrich leaves: the text of its lines and, for the legacy method, each line's lemma and part of speech; or plain text. The statistical kind also reads files, on the command line (keywords.py) and as POST /extract_keywords's file alike: nlp-enrich's CoNLL-U or TEITOK, a line table (CSV) or a .txt. The controlled kind's batch clients read line tables (CSV), TEITOK or records
Out statistical keywords with their method, score and rank, per document and per page; controlled keywords per line (JSON); the run's paradata (JSON). With a record sent: the record with its keywords block (statistical kind) and its enrichment block (controlled kind), side by side. The batch command line writes CSV tables per document and, on request, per page
Runs as an HTTP service image, atrium-keyword-extract-api (POST /extract_keywords, /extract_keywords_text), the production image; a command-line tool for the statistical kind (keywords.py) and its image; batch clients for the controlled kind; a research run on GPUs (llm_run.py) and its image; an Agent Skill
Compute CPU for YAKE and the legacy method; KeyBERT uses a GPU when there is one; the service's controlled kind calls a language-model service and carries no weights; the research run loads a model's weights onto GPUs
Network the Hugging Face Hub for the KeyBERT model, which the service fetches when it starts; for the controlled kind, the language-model service (OpenRouter, or a local Ollama). Only the vocabulary build reaches the AMČR and TEATER sources
Code licence MIT
Component licences KeyBERT (MIT) with its sentence-transformers model (Apache-2.0), YAKE (AGPL-3.0) when chosen, the AMČR and TEATER vocabularies (CC0), and for the controlled kind the language model's own terms; each run lists the ones it used. No licence of an output is computed: Licences and paradata
Record SSH Open Marketplace tool j9fqxo

Steps

# Step What happens In → out Activity
1 Select the text The lines of the record are gathered per document and per page; lines categorised Trash or Empty are left out, and a record without lines gives its content instead. The legacy method counts the lemma nlp-enrich wrote for each line, that of its head word, when the line's part of speech is a noun, a proper noun or an adjective. JSON → text —
2 Statistical keywords KeyBERT (the default) ranks candidate phrases by their similarity to the text's embedding; YAKE ranks them without a model; the legacy method, KER, counts nouns, proper nouns and adjectives by lemma. Twenty keywords of up to three words are kept, for the document and for each page. A long text goes to KeyBERT in overlapping windows of 400 words. Scores differ in meaning per method. text → keywords Extracting
3 Controlled keywords A language model reads each line among its neighbours on the page, with the document's first lines, and the whole vocabulary (4,711 terms) in its prompt. It answers with the term that describes the line, or Nerelevantní (meta-text) for a line that is not about archaeology; the Czech keywords found in it with their English translations; and a confidence. The answer must fit a schema whose allowed categories are the vocabulary's terms. text → JSON Enriching, Content Analysis
4 Record the result Statistical keywords go into the record's keywords block, each with its method, score and rank; controlled keywords into its enrichment block, one item per line with its page. Entities that are vocabulary terms are linked to their AMČR identifiers and AAT matches. A rerun replaces each block whole. The paradata name the method and, for the controlled kind, the backend and the model. → JSON —

Which kind runs. The request chooses: kind=statistical, the default, controlled or both. A kind that ran and failed fails the whole call, with no keywords and no record. The controlled kind runs only where a deployment configures a model service: without one, a request for it, alone or under both, answers 501. The service and the batch clients reach the model through OpenRouter or a local Ollama.

The vocabulary is built once, not per run. The AMČR keyword lists and the TEATER thesaurus are harvested, nested into one term list and reviewed, and each release carries the result as a CC0 asset; a run reads it. That build is its own workflow on Pipelines — W7, keyword-extract's half.

The research run. llm_run.py compares language models for the controlled kind on their local weights, on GPUs, from its own image (-llm), which compose builds locally; releases do not publish it. It is outside the pipeline.

What you get

  • Statistical keywords — the record's keywords block, with the keywords of the document and of each page, each with its method, score and rank. The batch command line writes keywords_summary_{l|y|kb}.csv, one row per document; KW_PER_DOC_*/<doc>_keywords.csv per document; and, unless --no-per-page, KW_PER_PAGE_*/ per page.
  • Controlled keywords — the record's enrichment.items[], one item per line. Each holds its page and line, the Czech keywords and their English translations, the TEATER or AMČR category with the identifiers of the records behind it, and a confidence. Entities in the record that are vocabulary terms get a pid. The batch clients write the same items to <doc_id>_enriched.json.
  • A provenance record — <run_id>-<8 hex>_keyword-extract.json from the command line and the batch clients, or the paradata of the service's answer, with the kind, the method, the backend and the model.

Every output is described in Reference → Outputs, and the service's answer in its runbook's JSON response.

In the AMČR pilot the record goes to the store after the last enrichment step.

Limits

  • Scores mean different things per method. Compare a keyword's score only within one method and one list.
  • The controlled kind is not evaluated. The rubric is decided, but the annotated gold set does not exist yet, so its categories are suggestions and its output is research output.
  • A constrained answer stays in the vocabulary, not on topic. A model that starts a word that is no term is finished as a term sharing its start: zvonice (a bell tower) for Bell Beaker vessels. A valid category can still be wrong.
  • confidence_score is not calibrated. Most lines get one of two values, 0.95 or 0.85: do not rank or filter on it.
  • The controlled kind needs a model service. Neither OpenRouter nor Ollama has a default model, so a deployment names one. The prompt is large, about 40,000 tokens; a model with a smaller window sees only part of the vocabulary, and the paradata record that as sampled.
  • Czech only in the service. The service takes lang=cs; English appears only as the translations of the controlled keywords.
  • The legacy method needs lemmas. A record gives one lemma per line, so KER counts fewer lemmas in a record than in nlp-enrich's CoNLL-U or TEITOK file. A table or a text without lemmas is refused (422).
  • Text and tables are UTF-8. From 2.0.2-beta (on test), a .txt or .csv that is not UTF-8 fails its document (exit 1; 422) instead of being read with replaced characters.
  • YAKE is AGPL-3.0. A run that uses it lists it with that licence.
  • Service limits. An upload over 10 MB a part (MAX_UPLOAD_MB) or 200,000 words (MAX_DOCUMENT_WORDS) is refused with 413, more than 100 keywords with 422, and a third concurrent request with 429 (Limits).
  • The KeyBERT model is fetched at start. It is not in the image and not pinned to a revision; the service answers nothing until it is loaded. Without network access KeyBERT fails, and YAKE still works.

Provenance and licence

Every run records its paradata, which lists the components that ran, each with its licence, as declared in the tool's para_config.txt. The service returns the paradata in its response, as a Process Run Crate CreateAction: the record read and the record written, as AMČR distributions by name and SHA-512. The command-line and batch runs write it as a log, <run_id>-<8 hex>_keyword-extract.json. No component is listed by every run; which ones run depends on the method:

Component Licence Used when
KER, the legacy lemma-frequency method (ker) MIT method=legacy; standard library only
YAKE (yake) AGPL-3.0 method=yake
KeyBERT (keybert) MIT method=keybert, the default
sentence-transformers (sentence_transformers) Apache-2.0 method=keybert
paraphrase-multilingual-MiniLM-L12-v2, KeyBERT's embedding model (keybert_model) Apache-2.0 method=keybert
AMČR keyword lists, the heslář (amcr_vocab) CC0 the controlled kind contributed (service) or ran (batch clients, llm_run.py)
TEATER thesaurus (teater_data) CC0 the same

The language model has no row: its own licence or its provider's terms apply to the controlled kind, and every controlled run records the model's id. Each run lists the components it used, each with its own licence or terms. No licence of an output is computed: the rights in an output follow the source document (Licences and paradata).

In the document record the tool writes the keywords block, the enrichment block and entities[].pid. It writes keywords when the statistical kind ran: the keywords of the document and of each page, every one with its method, score and rank. It writes enrichment and entities[].pid when the controlled kind contributed. An enrichment item names its record line by page and line, the record's line key, and keeps only its page when it cannot name one. The two kinds stay in their own blocks and never share a list, and a rerun replaces each block whole. The record carries no run data.

Where it sits

  • After nlp-enrich in the AMČR pipeline, the last enrichment step before the store. It reads the record nlp-enrich leaves, wherever its text came from: a born-digital file, the ATR or both — Pipelines → The route through the pipeline and W1.
  • Before the optional TEITOK projection. nlp-enrich's /project_record reads the keywords and writes them into the TEITOK header, so the chain is nlp-enrich → keyword-extract → nlp-enrich's projection.
  • The source of the translator's vocabulary. Each release's vocabulary asset can be read by the translator instead of a harvest of its own — Pipelines → W7, both halves.
  • Keyword extraction against controlled vocabularies step of the AMČR text workflow 0xSpVP.
  • Also used in W4 (as a service), W5 (from a coding agent) and W6 (the scanned end-to-end lane: the statistical kind, and the controlled kind when the lane has a model service's key).

On other platforms

SSH Open Marketplace. Tool record j9fqxo, "Keyword extraction from archival documents (statistical and vocabulary-controlled)".

Galaxy sheet. The Galaxy wrappers were handed to DARIAH for testing; further Galaxy work is parked during the AMČR pilot. The sheet describes the wrapper as the hub's galaxy/ folder holds it, at 2.0.1-beta+galaxy0.

Workflow inputs a collection of CoNLL-U — tabular; TEITOK — tei or xml; document records — json; line tables — csv; text — txt; optionally the document records to add to — json
Parameters the method (the wrapper's default is yake, the tool's is keybert; keybert, its model downloaded or staged; legacy); how many keywords (20); the longest keyword (3 words); the language of YAKE's stop words; per page too (off)
Workflow outputs the keyword table — csv (document_id, kw-1, score-1, …); keywords per document and per page — lists of csv; document records — a list of json; paradata — json
Container ghcr.io/ufal/atrium-keyword-extract:<version> — the batch image (keywords.py); it runs the job script Galaxy hands it (the hub-canonical container_entrypoint.py). The llm image (the controlled kind, on a GPU) and the service image -api are not used
Galaxy tool atrium_keyword_extract 2.0.1-beta+galaxy0, the statistical kind only, with the data manager ATRIUM Hugging Face models for KeyBERT's model, in the hub's galaxy/ folder with the workflows ATRIUM OCR to keywords and ATRIUM born-digital documents to keywords; a job fails when any of its documents fails. For DARIAH's test Galaxy (https://galaxy.acdh-dev.oeaw.ac.at/galaxy/)
Compute CPU; KeyBERT uses a GPU when the destination has one
Network or reference data yake and legacy need none; keybert downloads paraphrase-multilingual-MiniLM-L12-v2 from the Hugging Face Hub, so a server stages it once
Credentials none for the statistical kind; the controlled kind needs a language-model API key, and its output is still research output, so it is not offered
Test data data_samples/UDP/CTX000000003.conllu, nlp-enrich's data_samples/TEITOK/CTX000000001.teitok.xml, the record ocr-postprocess builds from digital-convert's docproc of its rich.docx, and a table without a text column for the error test
Credit the authors in the tool's CITATION.cff, with their ORCIDs; licence MIT; YAKE, one of the statistical methods, is AGPL-3.0
Closest Galaxy tools none extracts keywords; DARIAH's ATRIUM tools on the instance chain PDF text extraction with vocabulary-driven information extraction (task 4.2.1)

Sources

Read from ufal/atrium-keyword-extract at release v2.0.1-beta (tagged 2 December 2026), from its last pull request, on 2026-12-02; what is marked "from 2.0.2-beta" was read from its test of 3 December 2026 (the v2-beta-d13 pull request). Earlier readings were at v2.0.0-beta (e93cc67, 2026-11-29), of test before that release (2026-11-21), and at v1.6.0-beta (2026-10-29), v1.5.1-beta (2026-10-27) and v1.4.0-beta (2026-10-19). The statistical methods of atrium-nlp-enrich and the controlled kind and vocabulary build of atrium-llm-enrich moved into it on 1 October 2026. The Galaxy sheet (2026-12-02) follows 2.0.1-beta+galaxy0 and the hub's galaxy/ folder. This table records provenance, not a build instruction.

Source What was taken from it
README.md, docs/usage.md, docs/how-it-works.md the two kinds, the record nlp-enrich leaves as the input, the lemma per line, the step's place on the route
service/README.md §§ The methods, The controlled kind, JSON response, Errors, Limits, Partial results, Known limits; service/api.py the service, the kinds and their failures, the record's blocks, the paradata, the limits
keywords.py, kw_inputs.py, kw_config.txt the three statistical methods, their defaults and scores, the batch command line's inputs and outputs
llm_client_shared.py, openrouter_client.py, ollama_client.py, llm_run.py, llm_config.txt the controlled kind, its context and schema, its paradata, the research run
vocab_build.py, vocab_manager.py, data_samples/vocab/RUNBOOK.md, .github/workflows/release.yml the vocabulary build, the entity links, the release asset
para_config.txt, docs/reference/licences.md the licence components and when each is listed; YAKE's licence as its LICENSE file states it
atrium_document.py the blocks the tool may write
docs/reference/outputs.md the batch command line's files
CITATION.cff, .github/production-image.json, .github/workflows/docker.yml the release and its date; the images
SSH Open Marketplace j9fqxo the record identifier and title
the hub's galaxy/tools/atrium_keyword_extract/ and galaxy/workflows/atrium_ufal/ (workflows 0.5.0) the Galaxy sheet
DARIAH-ERIC/atrium-galaxy-tools the Galaxy analogue