CoolFace
Modelpublic

diegogs1451/qwen2.5-7B-Instruct-dUO-finetuned-20260706-3epochs

sourceHugging Facemitupdated 3mo agoView on Hugging Face
1likes109downloads
Model Card

Qwen2.5-7B-Instruct LoRA — dUO Administrative Title Summarization

This model is a LoRA adapter fine-tuned from Qwen2.5-7B-Instruct for generating summarization titles from administrative and legal texts published in Spanish/European official journals.

Model Details

Model Description

The model takes Spanish administrative/legal texts from official journals and produces concise, formal titles ready for publication. It is specialized in the three official journals that make up the dUO acronym:

  • —DOUE — Diario Oficial de la Unión Europea (Official Journal of the European Union)
  • —BOE — Boletín Oficial del Estado (Spanish Official State Bulletin)
  • —BOPA — Boletín Oficial del Principado de Asturias (Official Bulletin of Asturias)
  • —Developed by: Diego Gonzalez Suarez
  • —Shared by: diegogs1451
  • —Funded by: University of Oviedo
  • —Model type: Qwen2ForCausalLM (decoder-only causal language model with LoRA adapters)
  • —Language(s) (NLP): Spanish
  • —License: MIT
  • —Finetuned from model: Qwen/Qwen2.5-7B-Instruct

Model Sources [optional]

  • —Repository: <https://huggingface.co/diegogs1451/qwen2.5-7B-Instruct-dUO-finetuned-20260706-3epochs>
  • —Contact: <gonzalezsdiego@uniovi.es>

Uses

Direct Use

The model is designed to generate summarization titles for administrative and legal texts from official journals (BOE, DOUE, BOPA). Given a Spanish administrative/legal text as input, it outputs a concise, clear, formal title preserving the essential administrative meaning while eliminating unnecessary details and redundancies.

Out-of-Scope Use

This model is specialized for Spanish administrative text summarization and may not perform well on general text summarization tasks, other languages, or informal content.

How to Get Started with the Model

python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

base_model_name = "Qwen/Qwen2.5-7B-Instruct"
adapter_path = "diegogs1451/qwen2.5-7B-Instruct-dUO-finetuned-20260706-3epochs"

tokenizer = AutoTokenizer.from_pretrained(base_model_name)
model = AutoModelForCausalLM.from_pretrained(
    base_model_name,
    torch_dtype=torch.bfloat16,
    device_map="auto"
)
model = PeftModel.from_pretrained(model, adapter_path)

system_prompt = (
    "Eres un asistente experto en resumir textos oficiales administrativos y jurídicos "
    "del DOUE (Diario Oficial de la Unión Europea), del BOE (Boletín Oficial del Estado) "
    "y del BOPA (Boletín Oficial del Principado de Asturias) en títulos breves, claros, "
    "formales y listos para publicación. Conserva el significado administrativo esencial "
    "eliminando detalles innecesarios y redundancias."
)

def generate_title(text):
    messages = [
        {"role": "system", "content": system_prompt},
        {"role": "user", "content": text},
    ]
    inputs = tokenizer.apply_chat_template(
        messages, add_generation_prompt=True, return_tensors="pt"
    ).to(model.device)
    outputs = model.generate(inputs, max_new_tokens=128, temperature=0.1)
    return tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True)

Training Details

Training Data

Fine-tuned on a custom dataset of approximately 200 examples (~86k tokens) sourced from:

  • —DOUE (Diario Oficial de la Unión Europea)
  • —BOE (Boletín Oficial del Estado)
  • —BOPA (Boletín Oficial del Principado de Asturias)

The dataset field used for training is text, paired with a system prompt instructing the model to summarize administrative texts into formal titles.

Training Procedure

Training Hyperparameters
ParameterValue
LoRA rank (r)16
LoRA alpha32
LoRA dropout0.05
Target modulesqproj, kproj, vproj, oproj, gateproj, upproj, down_proj
Per device batch size2
Max steps174
Num epochs3
Learning rate2e-5
LR schedulerLinear
OptimizerAdamW
Max sequence length512 tokens
Precisionbfloat16 mixed precision
Training regimebf16 mixed precision

Speeds, Sizes, Times [optional]

  • —Total FLOPs: 1.466e16

Evaluation

Testing Data, Factors & Metrics

Testing Data

A held-out portion of the DOUE/BOE/BOPA dataset was used for evaluation.

Metrics
  • —eval_loss — Cross-entropy loss on the evaluation set
  • —eval_mean_token_accuracy — Mean token-level accuracy

Results

StepEpochTrain LossTrain Token Acc.Eval LossEval Token Acc.Learning Rate
5810.153896.4%0.118296.4%1.44e-5
11620.117396.0%0.115296.7%7.47e-6
17430.081297.8%0.110896.8%5.75e-7
Summary

The model achieves eval loss of 0.1108 and token accuracy of 96.8% on the held-out set after 3 epochs of fine-tuning, with consistent improvement in training metrics and stable evaluation performance across checkpoints.

Environmental Impact

  • —Hardware Type: Single GPU (T4, 16GB)
  • —Hours used: Not specified
  • —Cloud Provider: Not specified
  • —Compute Region: Not specified

Technical Specifications [optional]

Model Architecture and Objective

  • —Base architecture: Qwen2.5-7B-Instruct
  • —Hidden size: 3584
  • —Intermediate size: 18944
  • —Hidden layers: 28
  • —Attention heads: 28
  • —KV heads: 4 (Grouped-Query Attention)
  • —Max position embeddings: 32768
  • —Vocabulary size: 152064
  • —Activation function: SiLU
  • —Normalization: RMSNorm
  • —Objective: Causal language modeling (next-token prediction)

Framework versions

  • —PEFT 0.15.2
  • —Transformers (via TRL)
  • —TRL (SFTConfig / SFTTrainer)
  • —bitsandbytes (4-bit NF4 quantization)
  • —TensorBoard