Instructions to use structured-cot-ner/qwen3-8b-structured-cot-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use structured-cot-ner/qwen3-8b-structured-cot-lora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-8B") model = PeftModel.from_pretrained(base_model, "structured-cot-ner/qwen3-8b-structured-cot-lora") - Notebooks
- Google Colab
- Kaggle
Download README.md from structured-cot-ner/qwen3-8b-structured-cot-lora: direct link, hf CLI and curl.
- Browser
- Download file 4.12 kB
-
https://huggingface.co/structured-cot-ner/qwen3-8b-structured-cot-lora/resolve/main/README.md
- Command line
-
hf download hf://structured-cot-ner/qwen3-8b-structured-cot-lora/README.md
-
curl -L -o README.md https://huggingface.co/structured-cot-ner/qwen3-8b-structured-cot-lora/resolve/main/README.md
base_model: Qwen/Qwen3-8B
library_name: peft
tags:
- named-entity-recognition
- chain-of-thought
- lora
language:
- en
pipeline_tag: text-generation
datasets:
- structured-cot-ner/pilener-teacher-cot-agreement-v1
Qwen3-8B 路 Structured Reasoning for NER
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. Code: GreppiFilippo/structured-cot-ner.
Second phase of the project: a teacher reasons twice on the same queries, freely and in a structured format, and
students that differ only in the format of their reasoning are trained on the traces. This is the structured student; the free one is qwen3-8b-free-cot-lora.
Given a text and a list of entity types (some present, some absent), the model reasons inside its <think> block
with three one-line fields: TYPES (which requested types occur), MENTIONS (mentions to extract and candidates rejected) and EDGE (ambiguous boundaries or type assignments), then answers with a JSON object that maps every requested type to the mentions copied verbatim from
the text (an empty list for an absent type).
Training
- Base model:
Qwen/Qwen3-8B. - Data: the
structured_cottraces ofpilener-teacher-cot-agreement-v1(train, 3,822 queries), each with its own prompt (structured_prompt); target: the teacher's answer (answer). The free and structured traces of a query lead to the same answer, so all the students see the same queries and the same targets. - Method: LoRA r 16, alpha 32, dropout 0.05 on the q, k, v, o, gate, up and down projections; lr 1e-4, cosine, warmup 3%; 2 epochs; batch 1 x 8 gradient accumulation; bf16 (no quantization); maximum sequence length 5,120; loss on the assistant turn only; 5% validation, best checkpoint by validation loss; seed 42.
Evaluation
Metric: micro F1 with exact, case-insensitive mention matching per type, over the requested types; reasoning length
in tokens (generated before the end of the thinking block), mean per query. Queries: every gold type plus 1-3 distractors of the same domain, fixed seed
(free-vs-structured-cot-eval). vLLM, T 0.6, top-p 0.95, top-k 20, seed 0, up to 12,288 new tokens.
Base = the same model without fine-tuning, with the free prompt.
CrossNER (full test sets)
| Set | Base F1 | Free F1 | Structured F1 | Base tokens | Free tokens | Structured tokens |
|---|---|---|---|---|---|---|
| AI | 0.630 | 0.702 | 0.661 | 1,296 | 463 | 307 |
| Literature | 0.650 | 0.724 | 0.700 | 1,431 | 536 | 394 |
| Music | 0.752 | 0.785 | 0.779 | 1,511 | 566 | 393 |
| Politics | 0.713 | 0.745 | 0.728 | 1,686 | 614 | 450 |
| Science | 0.737 | 0.761 | 0.752 | 1,452 | 498 | 352 |
| Mean | 0.696 | 0.743 | 0.724 | 1,475 | 535 | 379 |
Pile-NER test split (in-domain, 2,000 queries)
| Set | Base F1 | Free F1 | Structured F1 | Base tokens | Free tokens | Structured tokens |
|---|---|---|---|---|---|---|
| Pile-NER | 0.525 | 0.569 | 0.565 | 1,993 | 988 | 586 |
Biomedical benchmarks (500 sentences each, 465 for JNLPBA-Rare)
| Set | Base F1 | Free F1 | Structured F1 | Base tokens | Free tokens | Structured tokens |
|---|---|---|---|---|---|---|
| NCBI | 0.560 | 0.708 | 0.677 | 569 | 223 | 226 |
| BC5CDR | 0.741 | 0.767 | 0.749 | 792 | 289 | 246 |
| BC2GM | 0.478 | 0.491 | 0.400 | 697 | 249 | 243 |
| BC4CHEMD | 0.509 | 0.607 | 0.588 | 840 | 298 | 322 |
| AnatEM | 0.438 | 0.407 | 0.360 | 645 | 285 | 299 |
| JNLPBA | 0.565 | 0.558 | 0.569 | 990 | 362 | 277 |
| JNLPBA-Rare | 0.482 | 0.443 | 0.477 | 749 | 299 | 229 |
| MedMentions-Rare | 0.503 | 0.563 | 0.574 | 904 | 401 | 284 |
| BioRED | 0.632 | 0.720 | 0.699 | 1,176 | 470 | 311 |
| Mean | 0.545 | 0.585 | 0.566 | 818 | 320 | 271 |
All predictions and metrics: eval-results (free-vs-structured-cot/ and free-vs-structured-cot-bio/).