Checklist HAIO 2026 Summer National Final · Task 4
Constrained Generation
English title: Korlátozott Generálás
Implement a token-selection rule for Qwen3-0.6B-Base that never produces forbidden words while keeping continuations long, diverse and fluent.
The task
Inspired by lipograms such as Georges Perec's La Disparition, an experimental workshop wants a small language model to continue prompts without ever using forbidden words. For 20 test cases, each with a prompt, a forbidden-word list (from stop words such as "the", "a", "an" to whole thematic word classes) and a maximum number of new tokens, the contestant decides the next token at every generation step.
The contestant implements select_next_token(logits, prompt, forbidden, generated_ids) → int, which receives the model's last-position logits (size vocab_size) and returns a token id; masking, resampling, beam search, top-k/top-p filtering and repetition penalties are all permitted as long as only the given model's logits are used. A word counts as forbidden when it occurs as a separate word, case-insensitively (e.g. "Apple" violates "apple", "pineapple" does not). The notebook supplies the evaluation framework (generate_constrained, score_case, run_tests), a would_violate helper and make_submission().
Abridged by SOTA from the official materials. The official statement has the exact rules, and it wins wherever this summary differs.
In English
Some of this task's files were published only in Hungarian. SOTA translated that file into English on 16 September 2026.
Read the task description (one-pager) in English
Constrained Generation
English translation by SOTA – AI Community of the Hungarian original. Licensed CC BY-NC-SA 4.0, like the original. Organisers who would like this translation removed can email [email protected].
Magyar MI Diákolimpia (Hungarian AI Olympiad)
Task description · Summer National Selection (Nyári Országos Válogató)
May 2026
[Figure: see the original one-pager.]
1. Situation report
In 1969, Georges Perec wrote his novel La Disparition: more than 300 pages without a single letter "e". Such deliberately constrained pieces of writing (lipograms) still fascinate linguists and writers' workshops today.
An experimental workshop would like to automate this. A small language model writes continuations for given prompts while never uttering a single forbidden word. Your task is to implement this constrained decoding. At every step the model proposes a next token (in the form of logits), and you decide which one goes into the output.
You face 20 experiments, each with a prompt on a different theme and a forbidden-word list of varying difficulty: from simple stop words (the, a, an) to bans on thematic word classes (in a detective text the entire vocabulary of violence is forbidden, in a programming description the trivial technical terms). The output must remain long, diverse and natural-sounding while respecting the constraint.
The organisations and events appearing in the task are fictitious (Perec and his work are not).
2. Constrained Generation
Causal language models produce text autoregressively: at every step they determine a probability distribution over the vocabulary (the logits), and then select the next token on the basis of this distribution. By modifying the logits, or by applying an alternative sampling rule or search procedure, the output of the model can be constrained without retraining.
You are given a small pretrained language model and a series of test cases. Each test case consists of an initial prompt, a list of forbidden words and the maximum number of tokens that may be generated. Your task is to determine, for each generation step, the identifier of the next token so that the final output does not contain a single forbidden word, while its length, diversity and naturalness are also preserved.
A word counts as forbidden in the output if it occurs in it as a separate word (delimited by word boundaries), without distinguishing between upper and lower case. For example, if apple is forbidden, then the occurrences apple, Apple, APPLE, apple, and apple. all violate the rule. pineapple, on the other hand, is allowed, since it is not a standalone occurrence of apple.
3. What you receive
A pretrained Qwen/Qwen3-0.6B-Base causal language model, accessed through the Hugging Face Transformers library, together with its tokenizer. During evaluation, the model is loaded with these same weights and package versions, so the output is deterministic across runs.
A function stub to be implemented, with the signature:
select_next_token(logits, prompt, forbidden, generated_ids) -> int
The meaning of the parameters:
logits– the model's output logits for the last position (size:[vocab_size]),prompt– the initial text,forbidden– the list of forbidden words,generated_ids– the list of identifiers of the tokens selected so far.
The return value is the identifier of the next token as an integer, between 0 and vocab_size−1.
The attached notebook provides the complete evaluation framework (generate_constrained, score_case, run_tests), a would_violate helper function that indicates, according to the same rules as the evaluation, whether a given partial result contains a forbidden word, and a make_submission() helper function that produces the submission.csv to be submitted from the completed select_next_token.
The test_cases.json file contains the official test set (currently 20 test cases) in the form of a list, each element of which is a test case with the fields id, prompt, forbidden and max_new_tokens. Scoring is carried out exclusively on this test set. The same file must also be used for generation.
4. What you submit
A single CSV file with the header id,output,fluency,tokens, containing exactly as many data rows as there are test cases in the test_cases.json file. The meaning of the columns:
id– refers to the corresponding entry oftest_cases.json.output– the generated text (without the prompt).fluency– the value from theQwen3-0.6B-Basemodel, computed on the full(prompt + output)text. The notebook'sscore_casefunction computes and fills in this value automatically.tokens– the length oftokenizer.encode(output).
The file follows the standard CSV format (RFC 4180): fields containing a comma, a quotation mark or a line break must be enclosed in quotation marks, and quotation marks must be doubled. Using the attached make_submission() helper function for the submission is recommended. It handles the above rules automatically and writes the output with UTF-8 encoding.
The fluency and tokens fields are computed and filled in by the notebook's make_submission() function. They must not be modified by hand: the evaluator overrides the submitted values.
The output may be produced only with the Qwen/Qwen3-0.6B-Base model specified in the task. Using any other generative model results in immediate disqualification. Any decoding strategy of your own for the model is allowed, provided that it uses only the logits of the given model.
5. Scoring
Let denote the test set and, for a given test case, let be the prompt, the set of forbidden words, the allowed maximum number of tokens, and the generated output text. The score of a test case is determined as follows:
- if contains a forbidden word: 0 points,
- if is empty: 0 points,
- otherwise: , where is the length ratio, is the bigram diversity and is the fluency.
Per-test-case maximum: 1.0 (if ).
Scoring factors. The three factors are defined by the formulas below.
| Factor | Formula |
|---|---|
The power of 1.5 on the length ratio penalises short outputs more strongly, while the upper bound prevents any reward beyond the maximum number of tokens. is computed as the proportion of unique bigrams in the lower-cased output split into words with the pattern \w+, so repeated word sequences lead to a deduction. Fluency is given by the model's own average token log-probability, so unnatural, improbable continuations also reduce the score.
Final score. The average of the per-test-case scores × 100 gives the final result of the submission. The scale is thus [0, 100] for any test-set size.
Public and private subsets. The 20 test cases are divided into two parts: 6 public cases (the score visible during the contest is computed on these) and 14 private cases (revealed only at the end of the contest; these decide the final ranking). submission.csv must contain the outputs of all 20 test cases; the split only affects how the score is displayed. The purpose of the split is to weaken over-tuning to the leaderboard during the contest (leaderboard-grinding).
6. Technical information
To solve the task, the attached .ipynb notebook and the test_cases.json file are available. The notebook contains the loading of the model and the tokenizer, the evaluation framework, and the would_violate and make_submission helper functions. The solver's job is to implement the select_next_token function, run the notebook on the test_cases.json test set, and submit the resulting submission.csv.
Only the designated cell (select_next_token) may be modified. Neither the model, nor the generation loop, nor any function of the scoring framework may be rewritten. The submitted notebook is subject to a post-hoc audit, and any manipulation that circumvents the scoring results in disqualification.
A T4 GPU is recommended. It also runs on a CPU, but considerably more slowly.
7. Useful resources
Translated by SOTA. The Hungarian original is the official version and wins wherever the two differ. Original by the Hungarian AI Olympiad (ELTE Faculty of Informatics), licensed CC BY-NC-SA 4.0; this is a translation of the task one-pager, and the official English notebook of the task is linked on this page. This translation is shared under CC BY-NC-SA 4.0, the licence of the original. If you organise this olympiad and would like the translation removed, email [email protected] and we will take it down.
At a glance
- You get
- The Hugging Face model
Qwen/Qwen3-0.6B-Basewith its tokenizer andtest_cases.json(20 cases with fields id, prompt, forbidden,max_new_tokens; also in the repository folder adatok/korlatozott-generalas). - You submit
submission.csvwith header "id,output,fluency,tokens", one row per test case, UTF-8 and RFC 4180 quoting, produced bymake_submission(); fluency and tokens are recomputed by the evaluator.- Scoring
- Per test case: 0 if the output contains a forbidden word or is empty; otherwise L · √distinct2 · Φ, where L = min(1, (tokens / M)^1.5) with M the token limit, distinct2 = unique word bigrams / all word bigrams of the lower-cased output split with \w+, and Φ = exp(log p_θ / 5) with log p_θ the model's average token log-probability over prompt + output. Final score = mean over test cases × 100. Six cases are public (leaderboard) and fourteen private (final ranking).
- Rules
- Only the
select_next_tokencell may be modified; changing the model, the generation loop or the scoring code leads to disqualification (notebooks are audited). - Any other generative model is forbidden.
- At most 15 uploads; the best submission counts.
- A T4 GPU is recommended.
- Only the provided Windows lab machines may be used; Python is the official language and only the pre-announced list of Python packages is allowed.
- Only the pre-announced whitelist of websites and tools may be used; code-completion and LLM services (e.g. GitHub Copilot, ChatGPT, Claude) are forbidden, except the single AI model named on the whitelist.
- Only computing resources that are completely free at the time of the contest may be used (no paid tiers such as Colab Pro).
- Own notes, books and printed material may be used during the practical part; audio-visual material and all communication are forbidden.
- Mandatory screen recording with OBS Studio.
- Only the
- Format
- Summer National Final (Nyári Országos Válogató), 30 May 2026, ELTE Lágymányos Campus, Budapest. Practical part: three hours on the provided machines after a short briefing; three 100-point tasks (ML, CV, NLP), scored automatically on the DOCK platform.