# Authorship attribution across fandoms ## Goal An authorship research lab needs a method that identifies who wrote a fanfiction excerpt when the subject matter changes. The lab supplies labelled writing from candidate authors and asks you to attribute new excerpts from a fandom absent from their supplied writing. Your method must also reject excerpts written by an author outside the candidate list. The lab evaluates how well attribution works across authors, including when authors have unequal numbers of query excerpts. ## What You Have The lab provides the following workspace: | Path | Contents | |---|---| | `/app/methods/main/` | Your submission, initially the starter, with `run.sh` as its entry point | | `/app/core/` | Shared data interface and metric; `CORE_DIR=/app/core` is set | | `/app/data/` | Practice inputs, with a subdirectory for each instance | | `/app/data-answers/` | Practice answers, in matching instance subdirectories | | `/app/selfcheck.py` | The rehearsal program | Each instance is a separate attribution problem. The lab stores its input in `input.json`, a JSON object containing `classes`, `support`, and `queries`. A support record contains string `id`, integer `label`, integer `group`, and integer-list `sequence`. A query record contains string `id` and integer-list `sequence`. The `classes` field lists the candidate author codes. Author and group codes are local to the instance; the lab assigns them as identifiers, not ordered measurements. Support identifiers begin with r and query identifiers with q; their values do not encode the answers. | File term | Meaning in the lab | |---|---| | `classes` | Candidate authors | | `support` | Excerpts with known authorship | | `queries` | Excerpts to attribute or reject | | `sequence` | Text encoded as Unicode code points | | `label` | Author code or rejection code | | `group` | Fandom of a support excerpt | The lab supplies `/app/core/interface/data.py`: `read` reads an input directory, `as_string` converts a record's sequence back to Unicode text, and `write` writes predictions into an output directory. Converting code points to characters is permitted; the integer magnitudes are not measurements. Methods importing the shared interface must locate it through `os.environ["CORE_DIR"]`. The complete input example is `/app/core/interface/example-input.json`. It is a practice input, so its particular sizes are examples rather than promises about other instances. In each practice answer directory, `target.json` maps query identifiers to true author or rejection codes. These answers support your own validation. The starter assigns every query to the candidate author whose mean character-trigram TF-IDF vector is most similar, and never rejects; you may replace it. ## What You Submit The operator collects only `/app/methods/main/` for execution in a clean grading container. Put your general method and every additional file it needs in that directory. The grading container supplies the same runtime and shared code at `/app/core/`; other files created during your session are not transferred for execution. For each instance, the grader invokes `run.sh `. Your method reads `input.json` from the read-only data directory and writes `predictions.json` into the writable output directory. The method runs as an unprivileged account, the same account used by rehearsal. The lab requires `predictions.json` to be a JSON list of objects. Each object has a string `id` identifying a query and an integer `label`. The declared answer codes are 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. Choose a supplied author code, or zero to reject an unlisted author; rejection is not a trained author class. The evaluator uses the first prediction for each duplicate identifier and ignores extra identifiers. Missing ids are assigned zero, as are integer labels absent from that instance's answer-key class set. An empty list is valid. The evaluator rejects noninteger labels, including booleans, and missing, unreadable, or structurally malformed prediction files. The operator requires every output file to be regular text and at most 64 MB. If `/app/methods/main/build.sh` exists, the operator runs it once offline before grading, allowing 900 seconds. A failed build fails the whole submission. ## Budget The operator gives each grading invocation 30 seconds, 4 CPUs, 8 GB of memory, and no network access. The time limit is exposed as `TASK_BUDGET_SEC`. Set numerical-library and worker thread counts to fit the grading allocation. The grader kills a method that exceeds its deadline and kills any process left behind when the entry script returns; either condition, or a nonzero exit, fails that instance. The solver session has 12 hours, 4 CPUs, 16 GB of memory, and no network access. The session and grading each have 10 GB of storage. ## How It Is Judged The evaluator grades 19 sealed instances. Their inputs and answers are present only in the clean grading container and are absent from your workspace. For each nonzero class represented in an instance's answer key, the evaluator counts true positives TP, false positives FP, and false negatives FN over the query rows. Its class F1 is `2*TP/(2*TP+FP+FN)`, with zero for a zero denominator. Rejected-author queries contribute false positives when assigned to a scored author. The rejection class itself is excluded from the class average, as is a supplied author absent from the answer key. The evaluator takes the mean of these class F1 values and rounds it to three decimals to obtain the instance score. The final score is the arithmetic mean of the sealed instance scores, with no additional rounding. Higher is better. Failed instances receive the failure score -1 and remain in the arithmetic mean. A failed build gives that failure score to every instance. ## Self-check Run the operator's rehearsal command: ```sh python3 /app/selfcheck.py rehearse ``` It builds the method if needed and runs it on every practice instance with the same sandbox, unprivileged account, per-instance limits, and metric as grading. Its final line is a JSON object with `score`, the arithmetic mean of the practice instance scores. Use it as a smoke test and a measure of practice performance; it is not the sealed grade. You can also use practice inputs and answers to construct held-out validation and use support fandom groups to test adaptation to unfamiliar subject matter.