Downloads · 30 days
62
61% of all-time downloads
oshyshatskyi/ukr-council-extractor-qwen2.5-0.5b
ukr-council-extractor-qwen2.5-0.5b is a text generation model from oshyshatskyi. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
A QLoRA adapter that extracts five header/signature fields from the text of a Ukrainian local-council decision (рішення) and returns them as strict JSON. It is a distillation target: a frontier teacher (Claude Opus, c…
Downloads · 30 days
62
61% of all-time downloads
All-time downloads
102
Public
Repo size
46.7 MB
Likes
0
Public
Click a slice to open those files.
.safetensors35.2 MB · 69%
From the Hugging Face model README
Qwen/Qwen2.5-0.5B-InstructA QLoRA adapter that extracts five header/signature fields from the text of a Ukrainian local-council decision (рішення) and returns them as strict JSON. It is a distillation target: a frontier teacher (Claude Opus, cross-checked) labelled a few hundred decisions once, and this small model was trained to reproduce those labels cheaply at corpus scale.
This is the Qwen2.5-0.5B-Instruct variant — best value — smallest and cheapest to serve (~$0.05 per 1,000 documents on an H100).
decision_no · date (ISO YYYY-MM-DD) · title · signatory · council_name
Evaluated on 10 councils held out entirely from training (none of their documents were seen), so the
number measures generalization to unseen councils, not memorization. The metric is strict macro
all-fields-exact (afe): the fraction of documents where all five fields match the gold exactly (text
fields lower-cased + punctuation-folded, then exact; decision_no space-insensitive exact; date ISO
exact), averaged per council so large councils can't dominate.
| all-fields-exact | decision_no | date | title | signatory | council_name | |
|---|---|---|---|---|---|---|
| this adapter (seed 1) | 0.889 | 0.984 | 0.997 | 0.991 | 0.948 | 0.963 |
| base, zero-shot | 0.000 | — | — | — | — | — |
import json, torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
BASE = "Qwen/Qwen2.5-0.5B-Instruct"
ADAPTER = "oshyshatskyi/ukr-council-extractor-qwen2.5-0.5b"
tok = AutoTokenizer.from_pretrained(BASE)
model = AutoModelForCausalLM.from_pretrained(BASE, torch_dtype=torch.bfloat16, device_map="auto")
model = PeftModel.from_pretrained(model, ADAPTER).eval()
SYSTEM = "Ти витягуєш дані з шапки та підпису РІШЕННЯ місцевої ради України. Поверни СТРОГО JSON з рівно такими полями: decision_no, date, title, signatory, council_name. Використовуй null, якщо поле відсутнє у тексті.\n- decision_no: номер рішення БЕЗ префікса «№» і без слова «№». Напр. «№ 4227» → «4227»; «№62-2275/2025» → «62-2275/2025». Зберігай складений формат (дефіси, косі риски, роки). null, якщо у шапці немає номера.\n- date: дата ухвалення у форматі ISO РРРР-ММ-ДД. Перетвори з української: «23 грудня 2025 року» → «2025-12-23»; «24.12.2025р.» → «2025-12-24».\n- title: заголовок «Про …» (повністю, без номера).\n- signatory: ПІБ особи, що підписала (зазвичай голова/секретар ради), зазвичай в кінці. null, якщо не видно.\n- council_name: повна назва ради з шапки."
def head_tail(text, head=2200, tail=800):
# feed the model the same header+signature window it trained on; elide the middle
return text if len(text) <= head + tail else text[:head] + "\n…\n" + text[-tail:]
def extract(document_text):
msgs = [{"role": "system", "content": SYSTEM},
{"role": "user", "content": head_tail(document_text)}]
prompt = tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True)
ids = tok(prompt, return_tensors="pt").to(model.device)
out = model.generate(**ids, max_new_tokens=256, do_sample=False)
return json.loads(tok.decode(out[0][ids.input_ids.shape[1]:], skip_special_tokens=True))
# print(extract(open("some_decision.txt", encoding="utf-8").read()))
signatory and by verbatim title/council_name phrasing.Adapter weights: apache-2.0. You must also comply with the base model's license.