Output formats

Output formats

Every result is written from the job database, with the user’s corrections applied, into the formats chosen for the job. Each source also gets a provenance.json. In comparison mode, file names carry the set-up’s label: letter.gemini-3.8-flash.txt. Two sources that would share a name in one folder (scan.pdf and scan.tif, or two scan.pdf sent to one folder) keep apart: the later ones in the job are numbered, scan (2).txt, regardless of case. A numbered name is kept too: a later scan (2).pdf in the same folder becomes scan (2) (2).txt.

Images read as the pages of one document (#52) give one result, as a PDF does: one .txt, .md, .docx, .json, .xlsx and .csv, its pages numbered in the document’s order (--- Page 3 ---), named after the document and written in the folder of its first page (Box 3.txt, Box 3.provenance.json). The images themselves are never copied, moved or changed.

A page or segment that could not be read after its retries does not keep the rest from disk: it stands as [Not read: reason] in the text formats and the CSV, with a failed reason in JSON, and provenance.json lists it under failed. Retrying it writes the files again.

In the CSV files a cell that begins with =, +, -, @, a tab or a carriage return, and is not simply a number, is written with an apostrophe before it ('- Oui), so a spreadsheet shows it as text instead of computing it as a formula. The JSON beside it keeps the text exactly. A table written through an export profile is the exception: its cells are written as they are, since another tool’s import would take the apostrophe as part of the value (decision).

Every table written as CSV is also offered as an Excel workbook (.xlsx) with the same headings, rows and cells, for a spreadsheet: it opens by double-click whatever language the spreadsheet is set to, where a CSV’s commas may all land in one column. It has one sheet named Table, the heading row in bold and frozen, columns as wide as their longest line (8 to 60 characters) and long text wrapped. Every cell is text exactly as written, so nothing is guarded with an apostrophe and nothing is read as a number, a date or a formula; Excel is told not to flag numbers held as text. A cell longer than the 32,767 characters a workbook’s cell holds is cut and ends with a note saying so; the CSV and JSON keep the whole text. The workbook’s dates are fixed, so the same table gives the same file (decision). The workbooks written beside a JSON export (descriptions, export profiles, the review manifest, the dictionary, a table of contents’ items) are named as their CSV, with .xlsx.

Text, Markdown and Word

Searchable PDF (.searchable.pdf)

The original PDF, unchanged, with an invisible text layer so it can be searched and its text copied. Only models that report where text sits on the page can feed it: Tesseract, which places every line and word, and Mistral OCR and LightOnOCR-3, whose block boxes are kept with each page. Text is set invisibly (render mode 3) in a glyph-less Unicode font, so any script stays searchable: each of Tesseract’s lines over its own box, and each of Mistral’s or LightOnOCR’s blocks spread over the lines that fit its box; every line is stretched to its box’s width. A corrected page keeps its words’ places where the engine placed each word (see ALTO below); otherwise it is set as one block over the page. Only PDF sources get one, not images, a document of images included; it is written as <name>.searchable.pdf, never replacing the source. New job says before a job whether it will have one: the format is offered, and the task’s diagram draws ALTO XML and the searchable PDF as a second result, only when a chosen model reports where text sits; under any other model, the diagram notes that it gives text only.

ALTO XML (.alto.xml)

ALTO version 4, as digital libraries, eScriptorium and Transkribus read it: one file per document, a Page per page, then TextBlock, TextLine and String for each word, with SP between words. Positions are in pixels (MeasurementUnit pixel): those of the image for an image source, those of the page as it was drawn for a PDF (as Tesseract reads it: at 300 dpi, or less for a page whose longest side would pass 7,000 pixels, the resolution its result records; a result that records none, read by 1.7.0 or earlier, is measured at 300), the page’s own WIDTH and HEIGHT given; for a document of images, each page measured in its own image, the file named after the document. A word carries the engine’s confidence (WC, 0 to 1) where it gave one. Description names the source file, the date, Kalamu’s version and, in processingStepSettings, the provider and model, the resolution PDF pages are measured at (naming the pages drawn at less than 300 dpi), and says when positions are estimated. A page split into halves is put back together on the whole page.

Offered only from models that report where text sits. Tesseract places every word. Mistral OCR and LightOnOCR-3 place blocks only: a paragraph the model wrote on one line is wrapped into as many lines as its block holds on the page (taking characters about half as wide as they are tall, and lines 1.2 times their height apart), a line the model broke itself is kept, the lines share the block’s height and their words each line’s width by their length, as the review draws them; the file says these positions are estimated. A corrected page keeps its words’ places, as iwac-ai-pipelines’ ALTO correction does: the researcher’s text is matched to the words the engine read, a word kept or changed staying in its box, words added sharing the box before them, words removed leaving theirs; the engine’s confidence is kept only for words left as it read them.

PAGE XML (.pNNNN.page.xml)

PAGE content, the 2019-07-15 schema, as Transkribus, eScriptorium and Aletheia read it: one file per page, <name>.p0001.page.xml, <name>.p0002.page.xml and on (four digits at least), beside the ALTO file and from the same places. Offered when ALTO is, and the same pages are written: every page of a PDF, one read without text and one that failed included (an empty Page, the failure in Comments), and each page of images that has regions.

Page gives imageWidth and imageHeight in the pixels ALTO measures in and, for a PDF page, the resolution it was drawn at (imageXResolution, imageYResolution, in PPI). imageFilename is the image file’s name; a PDF page has no image file, so it names <file>.pdf#page=N. ReadingOrder lists the regions in the engine’s order. Each block is a TextRegion, its lines TextLine, and its words Word only where the engine placed each word (Tesseract); Coords are rectangles as four points, in whole pixels kept within the page. TextEquiv/Unicode holds the corrected text at every level, a corrected page keeping its words’ places as in ALTO; a word carries the engine’s confidence (conf, 0 to 1) where it gave one. No baselines and no region types are written, the engines giving none.

A block Mistral OCR or LightOnOCR-3 placed whole gets the lines ALTO estimates, each saying its position is estimated, and no words: a word’s place would be a guess within a guess. ALTO writes those estimated words; this is the one difference between the two.

Metadata names Kalamu’s version, the provider and model, and in Comments the resolution, whether lines are estimated and whether the text was corrected. Created is when the page was read and LastChange when it was last corrected, never when the file was written, so writing the files again gives the same bytes.

The researcher’s regions in the searchable PDF, ALTO and PAGE XML

These three write the corrected view of where the text sits: the model’s regions with the boxes the researcher gave them in the review, and the regions the researcher drew that have text. A file with none of either is byte for byte what it was.

Both XML formats were checked by hand against the official schemas (ALTO 4.4, PAGE 2019-07-15); no test does it. Not yet in the files: the reading’s own identifier, which provenance.json gives for each region.

Analyses

Written as <name>.analysis.txt (and .md, .docx, .json, .xlsx, .csv) beside the source, so an analysis of interview.txt never replaces it. The researcher’s corrected answers replace the model’s where there are any.

An analysis that quotes its text

An analysis whose fields include entries that quote the text (the default Interview: themes and quotations) keeps, for each quotation, where Kalamu found it in the text it read. Only quotations found word for word are written; the researcher’s removals are applied.

Records

An analysis whose fields are one repeating group (One row per entry) is read page by page, and its files hold one row per entry, from the corrected rows.

Tables of contents

Written as <name>.contents.md (and .docx, .xlsx, .csv, .txt, .json) beside the source. Only the combined entries are written, with the researcher’s corrections; what the first step read on each page stays in the job, for the review.

Items

The items made from a table of contents (#50) are exported, when the researcher selects some and chooses Export, into a folder they choose, never replacing a file already there (a new one is numbered, (2)):

A job that read an item’s pages writes its results beside the source under the item’s name, and its provenance.json names the item under source.derived_from.unit.

Corrected text

Written as <name>.corrected.txt (and .md, .docx, .json, .xlsx, .csv), so a text file is never replaced by its correction. Pages keep their --- Page N --- markers; passages of a text without pages carry none, as the cut means nothing to a reader, and are numbered §1, §2 in the CSV.

Translated text

Written as <name>.translated.<code>.txt (and .md, .docx, .json, .xlsx, .csv), <code> being the language translated into (gallica.translated.en.txt), so a text is never replaced by its translation and translations into two languages do not replace each other. Pages and passages are kept as for corrected text, and the CSV has the same columns.

A transcript translated with its times (frozen from a transcript whose every part had them) is also written as .srt and .vtt, cut and timed exactly as a transcript’s, each cue holding the translation of the line it times, under that line’s speaker. Each part of its JSON result has segments: the transcript’s lines with their times and speakers, the text translated. Its provenance.json may carry lines_changed: the passages whose correction no longer has one paragraph per line, whose times were therefore lost; no subtitles are written while it lists any. A translation of any other text has no subtitles.

Subtitles and spreadsheets

JSON (kalamu-result, version 1)

{
  "schema": "kalamu-result",
  "schema_version": 1,
  "task": "text_extraction",
  "source": { "file_name": "lettre.pdf", "sha256": "…", "size_bytes": 1024 },
  "setup": { "label": "gemini-3.8-flash", "provider": "gemini", "model": "gemini-3.8-flash", "prompt": "Printed or typed document" },
  "parts": [
    {
      "piece": { "kind": "page", "number": 1 },
      "label": "1",
      "text": "Bamako, le 3 mai 1957 …",
      "segments": [],
      "corrected": false,
      "reviewed": true
    }
  ],
  "provenance": { "…": "as below" }
}

provenance.json (schema version 1)

Modelled on zmo-ai-pipelines’ provenance record:

Field Meaning
generator { "name": "Kalamu", "version": "…" }
created_at Milliseconds since 1970, UTC
task, engine text_extraction, audio_transcription, analysis, contents, text_correction or translation; cloud or offline
source File name, SHA-256 and size of the original; for a YouTube video, its title with the id (<title> [<id>], or youtube-<id> when the title could not be read), the SHA-256 of its id, its url, title and read_at, when the provider first read it; for text frozen from an earlier result (Use this text in a new job, or a workflow step reading an earlier one), the frozen text’s name, SHA-256 and size, and derived_from: that result’s job_id, setup_id, source_id and task, the original_path, when it was frozen (frozen_at), how many pieces it holds and how many were reviewed and corrected, and the pieces missing from it; for an item’s pages cut from a table of contents’ source, the same with task contents, its pages as the pieces (reviewed counting those marked in the table of contents), and unit: the item’s id, title, revision and pages as the original numbers them; for a document of images, the document’s name, the SHA-256 of its pages’ hashes in their order and their total size, and pages: each file in the order read, with page (the document’s page it begins), its id (the same wherever the page is moved), file_name, path, sha256, size_bytes, modified_ms, frames (pages the file holds, more than one for a multi-page TIFF) and the researcher’s label, if any
documents The project documents the source is, in each project whose document it is: project_id, project_name, document_id, title, and description, each part of the source’s description as it stood when the file was written (repository, fonds, series, file, shelfmark, creator, date, url, citation, rights) as { "value", "from" }, from being document or project; parts with no value are left out. Supplied by the researcher, never by a model. Absent for a job tied to no project
provider, model As requested
model_versions The versions the provider reported, when they differ from model (including a fallback model)
request What the requests carried besides the prompt, each as { "name", "value" } named by its path in the request (output_config.effort, generationConfig.maxOutputTokens, beam_size): reasoning effort, output limit, media resolution; for Whisper, vad (whether silences were skipped with the voice-activity model, used when it is downloaded) and vad_model; for Tesseract, engine (Tesseract 5.5.2), language_data (tessdata_best@e12c65a), ocr_engine_mode (lstm), page_segmentation (auto) and, for a PDF, page_resolution (300 dpi: what the page was drawn at). For pages read several at a time, pages names the pages that went in one call (5-8). Recorded with each piece’s result when it was sent, so a later version of Kalamu never rewrites it; a name listed twice means pieces were read with different values. Absent for results stored by 0.4.0 and earlier
prompt Preset id and name, the full instructions and per-page request sent, and their SHA-256
merge For a table of contents, the model and prompt that combined the pages: provider, model, model_versions, request, prompt, and that step’s usage and cost_usd, its share of the totals below
languages, detected_languages What the user chose, and what the model reported
options Diarization, timestamps, speaker count, and the reasoning level chosen or suggested for the set-up (reasoning, absent for a model that does not reason)
pieces, corrected, reviewed Number of pages or segments, and which were corrected or reviewed
failed Pages or segments that could not be read after their retries, marked in the files. Absent when none was
truncated Pages or segments whose answer stopped before its end, at the model’s output limit or for another reason the provider gave, so their end may be missing; for a table of contents, the pages read and the combined entries alike. Absent when none was
cut_by_filter Those of truncated that a provider’s filter (safety, a blocked term) stopped, rather than the output limit. Absent when none was
preprocessing Fixes applied to working copies (split_spreads, even_out_volume, sample_first_3_pages): only those made, so split_spreads only where a spread was found, and a sample only of a document longer than it
renamed_speakers The model’s speaker labels the researcher gave names, which replace them in every file. The names are in the files, not here, so the record can be shared without them. Absent when none was
usage, cost_usd Tokens, audio seconds or pages billed, the input read from or written to the provider’s prompt cache (cached_input_tokens, cache_write_tokens, parts of input_tokens), whether the calls went through a batch service (batch), and the cost from catalogue prices with those discounts, for the results kept
refused Answers the provider billed but nothing was kept from: analysis answers that broke the fields and were asked for again, or several pages read together whose page marks could not be used (each page then read again alone). answers, their usage and cost_usd, not included above. Absent when none was
workflow For a result read by a workflow step: the run (run_id), the workflow (workflow_id, name) and its version when the run started, this step of steps and its step_name, the step it reads (numbered from 1; absent when it read the files, and source.derived_from names the snapshot), and the researcher’s approval of that step (at, and partial when they went on although some pieces were not read). Absent for a job run on its own

Added on 18 November 2026 without a new version, both absent when empty: listed_by_hand, the items of an analysis’s list answers that the researcher wrote (added, or renamed from the model’s form) and the model’s own answer did not hold, each with its part, field and items; and passages, the passages a model corrected at the researcher’s request from the review and that they accepted, each with its piece, provider, model, prompt, request settings, character counts, whether the proposal was edited, its cost and when it was asked and accepted. Their cost is not in usage or cost_usd, which count the job’s own pieces.

Added later the same day, also absent when empty: regions, the regions the researcher drew over the scan or whose box they adjusted, each with its id, page (and half of a split spread), its box in fractions of the page or half (x, y, width, height), its origin (manual), what it adjusts (the stored result’s cache key and the region’s id there, such as r1_l2), whether it has_text (the text itself is not recorded), and when it was created and updated. A set-up’s file lists those drawn on the source, those adjusting its own readings and those adjusting a reading no set-up shows any more. ALTO, PAGE XML and the searchable PDF write the same regions (above). A model’s region is named there as PAGE XML names it (r1, r1_l2, r1_l2_w3), except on a split spread, whose halves the review numbers each on its own and PAGE XML across the whole page.

And region_readings, the regions a model read again at the researcher’s request and whose reading they used, each with its page (and half), the region’s id and box, the provider, model, prompt and request settings, where it went (went_to: region, the text of a region the researcher drew, or text, in place of the region’s words in the page’s text), whether it was edited first, its cost and when it was asked and accepted; never the text. A reading that went to a drawn region is listed in every set-up’s file, one that went into the text in that set-up’s alone. Their cost is not in usage or cost_usd.

The search index (search.sqlite)

Not an output: a file in the app’s data folder that project search reads, made only from the job database (decision). Each passage is one piece of one result: the text as the review shows it, or an analysis’s answers and reasons as separate parts, kept as JSON beside the folded text in an FTS5 table (trigram tokenizer, contentless). A stamp records what the passage was made from, and PRAGMA user_version the layout; a file of another version, or one that cannot be read, is emptied and made again. Nothing outside Kalamu should rely on its layout.

The search by meaning’s numbers (vectors.sqlite)

Not an output either: a file in the app’s data folder, made only from the results (decision). One row for each stretch of text: the model (provider, id and length), the piece it is of, its number in that piece, the piece’s stamp and a hash of its text, where the stretch stands in the text, and its numbers as little-endian 32-bit floats of length 1. Losing the file loses only what preparing again costs. The job database keeps, for each project, the model chosen and the consent given (meaning_spaces) and each preparation with its cost (meaning_runs). Nothing outside Kalamu should rely on its layout.

The review manifest (kalamu-review-manifest, version 1)

Written by Export the list in a project’s What to check, where the researcher chooses: a JSON file with an Excel workbook and a CSV beside it, every item of the list in the scope shown (the project, a collection or a selection), whatever the filters show, the pages drawn at random included. The workbook has the same columns as the CSV.

The JSON holds format, version, project, project_name, scope (project, collection:<id> or documents:<digest of the selection>), exported_at, the scope’s counts, the sample (its seed, size, when it was drawn, how many pages it was drawn from, how many were drawn and how many of them are reviewed; null without one), set_aside and items. set_aside lists the results the researcher set aside from the list in that scope, which the items and the sample leave out: each with its job_id, job_name, task, setup_id, setup_label, model and documents; an empty list when there are none. It was added on 18 November 2026 without a new version, a reader of version 1 ignoring it.

The CSV has one row per item, in these columns: document_id, document, source_id, job_id, job_name, task, setup_id, setup_label, model, preferred, piece, place, position, revision, answered_at, reasons, reason_details, flagged, processing, sample, sample_seed, reviewed, corrected, decided_at, open, kept_aside, kept_note, kept_at, listed_for. piece is the piece as Kalamu names it (result for a whole result), place as exports label it, position counted from 1, and revision the answer the row is about. reasons joins the kinds with ; and reason_details what each found. Yes-or-no columns read yes or no, kept_aside also for an earlier answer; listed_for reads processing, flagged, not_reviewed or sample. Times are in UTC.

A page is drawn by ranking every page nothing flags by the SHA-256 of <seed>:<identity>, the identity being <document id>/<task>/<piece>, and taking the lowest: the manifest’s seed and identities are enough to check a draw.

The screening table

Written by Export the whole table in a project’s table of documents, while the table is filtered by an answer: an Excel workbook and a CSV beside it, with the same columns, one row per document the analysis read, in title order, whatever the filter shows. A question asked again of documents added since is written with every analysis that asked it alike, a document’s newest answer counting; one asked under a prompt edited since is a table of its own (decision).

The columns are document (its title) and file, then one column per field of the analysis under the label it froze, a <field> (reason) column after each field that asks for a reason (a field that quotes the text as its quotations, one per line, with where each stands), then:

Cells a model wrote that a spreadsheet would read as a formula start with an apostrophe in the CSV.

The project file (.kalamu)

Written by Save to a file… in a project, where the researcher chooses, and read by Open a project file… on the list of projects (decision, #213). One SQLite database, the same on Windows and macOS. It has the job database’s own tables, at the schema its PRAGMA user_version gives (the number of the store’s migrations the saving Kalamu had), holding one project’s rows only, and three tables of its own.

kalamu_project_file, one row:

kalamu_files, one row for each file the project’s documents and jobs name, each once:

kalamu_file_chunks: the bytes of each carried file, in chunks of at most 4 MiB: file_id (its kalamu_files.id), seq (from 0) and data.

The job database’s tables hold, for the project:

Every other table of the schema is there and empty: workflow runs, batches, the files marked out of date, the search by meaning’s model and costs. No key, setting, prompt library or derived index is in the file. Opened, every identifier is given a new one and the project comes in beside the others; the carried originals are written into the data folder’s originals/<project id>/, a folder for each folder they shared, each under its own name made safe for this system (one an earlier file of its folder took, regardless of case, numbered: draft_ (2).pdf), and the paths that named them pointed there; deleting the project removes that folder, and a folder whose project no longer exists is removed at launch. A file saved by an older Kalamu is brought up to date on a copy in the data folder’s project-file-scratch/, deleted when done and emptied at launch. Nothing outside Kalamu should rely on more than the manifest and the files’ tables.