--- license: other language: [en] tags: [ner, chain-of-thought, distillation, sft, open-vocabulary] pretty_name: Type-Conditioned SFT Data (First Phase) --- # Type-Conditioned SFT Data (First Phase) Part of the code, data and models of the bachelor thesis *Structuring Universal Chain-of-thought for Named Entity Recognition* (Department of Computer Science and Engineering, University of Bologna, 2026). All the repositories cited by name belong to the same organization. Training sets for fine-tuning Qwen3 (thinking mode) on **open-vocabulary NER**: the entity types to extract are given in the prompt, and the target is the original Pile-NER annotation. Built from Pile-NER rows that have a teacher Chain-of-Thought (Qwen3-32B, open-schema), filtered by a jury of three LLM judges (see `jury`). ## Format One JSON object per line: `{"id", "messages", "meta"}`. - **system + user**: exactly the prompt the baseline receives at evaluation time (same text as `bioner-eval-subset`), with the list of `ENTITY TYPES` to extract. - **assistant**: `\n{teacher reasoning}\n\n\n{JSON}`, where the JSON has one key per requested type and the Pile-NER gold spans (de-duplicated per type) as values; absent types are answered with `[]`. - **meta**: agreement between the teacher reasoning and the gold that now follows it (`n_gold_spans`, `gold_in_teacher_entities`, `gold_rejected_by_teacher`, `gold_mentioned_in_reasoning`, `teacher_entities_not_in_gold`, `reasoning_mentions_old_format`, `reasoning_source`). The teacher reasoning was generated for the *open-schema* task, so it does not always agree with the gold: on the 6,895 jury-accepted rows, the teacher explicitly rejects a gold entity in 41.5% of the examples and 30.4% of the traces discuss the old output format. ## Files (one change at a time) | File | Rows | What changes | |---|---|---| | `openvocab_train_v3_qwen.jsonl` | 3,131 | Jury-accepted rows; removes examples whose reasoning rejects a gold entity or discusses the old output format; each prompt adds 2 absent "distractor" types (answered `[]`); a few examples request no present type. | | `openvocab_train_v3_medgemma.jsonl` | 3,131 | Same examples as v3, in MedGemma's reasoning format (`thought … `). | | `openvocab_train_v4_qwen.jsonl` | 3,131 | v3, but each example requests only a random non-empty **subset** of the types present (with v3 the model put every entity it found under whatever type was requested, e.g. genes as `DISEASE` on NCBI). | | `openvocab_train_v4_labelonly.jsonl` | 3,131 | Identical to v4 with an **empty** `` block: the control that isolates the effect of the reasoning. | | `openvocab_train_v4_rejected.jsonl` | 3,131 | v4 recipe applied to CoTs **rejected** by the jury (same size as v4). | | `openvocab_train_v4_all.jsonl` | 10,901 | v4 recipe on **all** usable CoTs, without the jury (3,131 accepted + 7,770 rejected). | | `openvocab_train_v5_teacher_qwen_3131.jsonl` | 3,131 | **v5**: v4 recipe, but the answer is the teacher's OWN entities (produced at the end of the same reasoning, as in ReasoningNER), so reasoning and answer never contradict each other; requested types = the teacher's labels in UPPER_SNAKE (e.g. `MEDICAL_CONDITION`); rows with a teacher entity not verbatim in the text are dropped. | | `openvocab_train_v5_teacher_medgemma_3131.jsonl` | 3,131 | Same examples as v5 qwen, in MedGemma's reasoning format. | | `openvocab_train_v5_teacher_qwen_A_strict08.jsonl` | 427 | v5 recipe on the outputs accepted with the jury threshold raised from 0.6 to 0.8: the stricter-jury ablation (Qwen3-1.7B). | | `openvocab_train_v5_teacher_qwen_B_random.jsonl` | 427 | 427 examples drawn at random from the same pool of v5 examples accepted at 0.6: the control of the stricter-jury ablation. | No file contains rows of the in-domain test set `pilener-eval-subset`. ## Main results Exact typed F1 (the metric of the thesis), mean over each group of test sets: a predicted mention is correct only if it equals a reference mention of the same type, ignoring case; only the requested types are scored. Every run is in `eval-results`. In the thesis, the versions v3, v4 and v5 of these files are called v1, v2 and v3. – = not evaluated. | Model | Biomedical (9) | Pile-NER | CrossNER (5) | |---|---|---|---| | Qwen3-4B base (thinking) | 0.505 | 0.462 | 0.660 | | Qwen3-4B SFT v4 | 0.435 | 0.486 | 0.570 | | Qwen3-4B SFT v4 label-only | 0.398 | 0.524 | 0.531 | | Qwen3-4B SFT v5 | 0.445 | 0.359 | 0.601 | | MedGemma-1.5-4B base | 0.422 | 0.360 | 0.598 | | MedGemma-1.5-4B SFT v5 | 0.426 | 0.364 | 0.627 | | Qwen3-1.7B base (thinking) | 0.461 | 0.384 | 0.604 | | Qwen3-1.7B SFT v3 | 0.395 | – | 0.522 | | Qwen3-1.7B SFT v4 | 0.394 | 0.450 | 0.565 | | Qwen3-1.7B SFT v4 label-only | 0.392 | 0.489 | 0.515 | | Qwen3-1.7B SFT v4, 1 epoch | 0.399 | 0.431 | 0.574 | | Qwen3-1.7B SFT v4 rejected | 0.382 | 0.472 | 0.445 | | Qwen3-1.7B SFT v4 all | 0.373 | 0.505 | 0.437 | | Qwen3-1.7B SFT v5 | 0.389 | – | 0.596 | | Qwen3-1.7B SFT v5, threshold 0.8 (A) | 0.368 | – | 0.595 | | Qwen3-1.7B SFT v5, random 427 (B) | 0.378 | – | 0.588 | No Qwen3 student outperforms its base model on the biomedical benchmarks or on CrossNER; MedGemma v5 improves its base on CrossNER (0.627 against 0.598). Adapters: the `*-lora` adapters of this organization. Training: LoRA r=16, alpha=32, lr 1e-4, 2 epochs (unless noted), loss on the assistant turn only. Derived from [Pile-NER](https://huggingface.co/datasets/Universal-NER/Pile-NER-type): check its license before reuse beyond this project.