Skip to content
An Econ-ARK project

The roles and the work of a job

Summary

Matsya's work is done by language-model roles, each with a fixed instruction text, a fixed input and a fixed output, called by the program in a fixed order; nothing else in Matsya decides anything about economics. This page names the roles of a job and the cycle in which they run, the role of a turn and the programs that check what the roles return, says what each receives and returns, and then says which command a user, or an assistant working for the user, runs for each kind of request: a question, a build, a reply to a question of matsya-architect, a reading of the result, a stop. The three parts of Matsya and the words session, job, turn, version, label and target are defined in Matsya in three parts.

Relationship with other documents

Builds on — Matsya in three parts, which defines the three parts and the words session, job, turn, version, label and target. Continued by — Working with Matsya from the command line, which follows one piece of work through the commands of §3. Explained for developers in — the Matsya developer guide: What Matsya reads for what each role is given, and The Matsya handlers for the program that calls the roles.

1 The roles of a job

A job of matsya-architect runs the Model-prose-writer and the prose-source-judge once, in preparation. It then writes and elaborates the initial declaration. Each iteration reads the latest elaborated semantic object, writes prose from it, writes and elaborates one new declaration from that prose, and compares the two adjacent elaborated semantic objects. Each language-model role has a fixed instruction text, input and output. The report lists the tokens charged to each role (Matsya in three parts §1).

Role Receives Returns What it is for
Model-prose-writer the source material: the session's text or the submitted file, with the passages of the index that match it and the pages of the reference guides the model prose: the model restated as a paper's model section under fixed headings, first its structure, the model's stages, its periods with the connections between their stages, and how the periods repeat in time, then its states, controls, shocks and their timing, laws of motion, the recursion, the condition that determines the policy and the parameters; or questions when the source leaves a necessary thing unsaid to fix what model is meant before anything is written in the language
prose-source-judge the model prose and the source material for each of ten economic items, from the state space and the timing of information to the terminal condition and the parameters, whether the prose omits, adds or contradicts something the source says, with the sentences quoted; it reads the two texts in both orders to report where the prepared model prose differs from the source, for the user to assess
Prose-to-Bellman-Sym the prepared model prose for the initial declaration, or the prose written from the preceding elaborated semantic object for an iteration, with the language guide and retrieved passages the stage files of the declaration, in Bellman-SYM, each block quoting in a # from: line a sentence of the prose it reads, with a note of what the prose left open; with them the other files of the job's target, as Matsya in three parts §2 lists them to write and repair one declaration from the prose it receives
the elaborator (a program, not a role) the stage files acceptance, or a refusal naming the rule, the line and what to write instead, which goes back to Prose-to-Bellman-Sym for repair to check that the files parse and satisfy the rules of the language
the distribution check the model prose with an income or shock variable whose probability distribution the writer could not write, or an income the prose describes only by a general distribution function, and the reason whether the prose specifies that probability distribution, with the sentences quoted, and otherwise one question for the user to ask the user, before or during writing, for a probability distribution the prose leaves unspecified, instead of letting the writer supply one
Semantics-to-Prose the dossier of the latest elaborated semantic object, the account the program prints of what it states, without the source or prepared model prose the model prose that semantic object states, under the same headings to read the semantic object back without seeing what was intended
prose-roundtrip-judge the prepared model prose and the prose written from the latest elaborated semantic object for each of the same ten items, whether the two agree, with the sentences quoted to report prose differences for the user; this report does not decide convergence
the comparison of elaborated semantic objects (a program, not a role) the elaborated semantic object before an iteration and the one constructed during it whether the two objects represent the same model, up to the names chosen, with the first difference when they do not to decide whether that iteration has reached the semantic fixed point

Preparation runs once. The Model-prose-writer writes the model prose, in up to three attempts when its answer or form needs correction. The prose-source-judge then reports any disagreement with the source. That report remains with the job; disagreement alone neither repeats preparation nor prevents a stage file from being written. A question about a necessary economic fact still goes to the user. The program also checks the structure described in the model prose. A target that holds that structure, or a wider one, is admitted; a narrower target ends the job needs_input with a question naming a suitable target.

The Model-prose-writer should identify the main Bellman problem even when it appears inside a general-equilibrium model, an estimation exercise or a computation using the sequence-space Jacobian method. Several sectors, equations, linked stages or decision branches can belong to one problem. When the source instead offers several distinct Bellman problems and the user has selected none, Matsya should ask “Select a Bellman problem:”, followed by the candidate problems and their sections in the source. For example, a paper with separate retirement, housing-adjustment and housing-with-renting applications requires a choice between those applications; the worker and retiree branches within the retirement application remain together.

A justified selection question is a valid architect response, recorded as needs_input. Writing waits for the user's choice, so no E–E′ comparison exists yet. The optional formulation identifies the chosen problem; target identifies the kind of declaration to return. A user who already supplies a formulation should not be asked to select it again. The reply procedure is in §3.

The prepared prose M produces the initial declaration D and its elaborated semantic object E. Iteration 1 reads E to produce M′, then writes D′ and elaborates it to E′; the program compares E with E′. If they differ, iteration 2 reads E′ to produce M′′, then writes D′′ and elaborates it to E′′; the program compares E′ with E′′. Iteration 2 does not write another declaration from M or produce E′′′. The job ends converged only when adjacent elaborated semantic objects are equivalent: one stage for a stage target, or the stages and their joins for a period, trellis or recipe target. The prose judges, the quotations and the writer's note remain in the record for the user to assess; none decides convergence. If the permitted iterations end with differing elaborated semantic objects, the job ends not_converged with the reason cycle_limit_reached. If a declaration cannot be elaborated, there is no comparison for that iteration. Agreement between adjacent elaborated semantic objects does not establish agreement with the source.

A job also ends not_converged before its cycles are spent when the elaborator still refuses the stage files after the writer's attempts (stage_file_refused), when a role has used up its requests for more pages or passages (request_rounds_exhausted), or when a call would pass a ceiling of language-model tokens (token_ceiling_reached); the report's section Status names the reason. A job that stopped at a question, the Model-prose-writer's, the question of a narrower target or the distribution check's, ends needs_input; the questions stand in the session for the user to answer when the job has a session and the user added no entry to it while the job ran, and otherwise in the job's record alone, where bellman-matsya job status <job> prints them.

For a model of several stages, the comparison reads the connections Bellman selected between their fields, including connections between periods. A connection that names no unique field, has incompatible fields, or cannot carry the required continuation values is returned for correction; it cannot count as an equivalent elaborated semantic object. For a recipe, the comparison also reads the parameter values that its periods supply. If a $fill slot leaves one period without a value, the dossier names that period and any values other periods state. The elaborated semantic objects of two recipes can compare equivalent while that value remains unbound.

2 The role of a turn

matsya-master has one role of its own, the conversation role; when a question names a stage file that the elaborator accepts, it also calls Semantics-to-Prose, to describe that file. The conversation role receives the question, pages of the reference guides, the passages of the index that match the question, the session's text, the outputs of the job it discusses, the selected job or the latest job that Matsya in three parts §3 names, and, when the question names a stage file, the dossier of that file once the elaborator accepts it, with Semantics-to-Prose's account of it, or the elaborator's refusal; it may ask the program for more pages, more passages, the outputs of the session's other jobs or a job's stage files a bounded number of times. It returns an answer with citations, each a quoted sentence of what it read, and the program accepts no citation it cannot find in that material. It writes no stage file. When the user asks it to build or to submit, it sets one field of its reply and the program starts a job from the session; it starts no job otherwise.

3 Which command for which request

The request What runs The command
a question about a model, about the language, about why a judge disagreed, about what a job produced one turn of the conversation role, a few calls of a language model, taking less time and costing less than a job bellman-matsya ask <session> "…"
build a declaration from a description one job of all the roles of §1, several minutes, charged by the language-model tokens of every call bellman-matsya job submit model.md --target stage (a session is created for the file; the target, which Matsya in three parts §2 defines, names what the job returns, a stage, a period, a trellis or a recipe)
rebuild it after an edit of the description a new job, as above, in the same session: the edited text is appended to the session, and the job reads the session's whole text, the earlier description included bellman-matsya job submit model.md --session <session> --target stage; a second bellman-matsya job submit model.md --target stage would create a second session
build from the discussion so far the same job, started by the conversation role from the session's text bellman-matsya ask <session> "Submit this as a job."
answer a question of matsya-architect the reply appended to the session; the first reply to the job's questions starts the next job with the reply in its text, unless a later job of the session has started bellman-matsya session add <session> reply.md --replies-to <entry>
read what a job produced, or its report of what did not match nothing on the server; the client writes the folder and the report bellman-matsya job files <job> <folder>
see the jobs of a model, their labels and the selected job, when one is selected; with none selected, the listing does not name the job the conversation discusses, which Matsya in three parts §3 defines nothing on the server; a listing bellman-matsya session show <session>
make the conversation discuss another job of the session, one that holds a record a mark on the session bellman-matsya session select <session> <job>
stop a job that is queued or running a queued job is cancelled at once; a running job ends before its next call, and a call already sent is charged bellman-matsya job cancel <job>
search the documentation, and the literature your Matsya token may read, without a question the index alone, no role bellman-matsya search "…", and bellman-matsya search "…" --collections literature for the literature

Two rules follow for an assistant acting for a user. A job costs money and minutes and is started only when the user asks to build; a question costs little and is the way to understand a result before building again. And a job's questions are answered in the session, all of them in one reply file, not by editing the files: the next job reads the session's text, and the first reply starts it at once. A later reply to the same questions starts nothing, and one that arrives while that job runs is not in its text, so the job ends marked built from an earlier version and appends no question to the session.