Qwen3.5-27B Legal SFT ES v1 Merged

Merged full model derived from a LoRA fine-tuning on Qwen/Qwen3.5-27B, specialized for conservative Spanish legal assistant behavior over statutes and case law.

This repository contains merged weights and can be served directly as a standalone model.

Intended behavior

The fine-tuning objective was behavioral, not encyclopedic. The target model should:

  • cite only what is visible in the provided material;
  • avoid converting an old judicial citation into a statement of current positive law;
  • explicitly recognize when the available text is partial or insufficient;
  • write in a more prudent, structured, professional Spanish legal style.

The model is meant for RAG-style systems over Spanish legal sources, especially where the retrieved context may include:

  • anonymized Spanish Supreme Court judgments;
  • partial extracts of judgments;
  • visible statutory fragments;
  • mixed legal bundles where caution matters.

What was trained

The training corpus was built from anonymized Spanish Supreme Court judgments and transformed into chat-format SFT examples focused on:

  • sentence analysis;
  • prudent legal analysis;
  • legal drafting style;
  • autocontention and explicit limits;
  • separation between facts, allegations, prior rulings, legal reasoning, and operative part;
  • temporal normative caution when a judgment cites legal provisions.

The dataset was designed to reduce these failure modes:

  • inventing articles, dates, ECLI, ROJ, or holdings not visible in the prompt;
  • treating a provision cited inside an old judgment as if it were necessarily the current wording in force;
  • overstating what can be concluded from partial context.

Training details

  • Base model: Qwen/Qwen3.5-27B
  • Training method: supervised fine-tuning with LoRA
  • Training stack: Unsloth + TRL + PEFT
  • Training profile: gold_plus_reviewed_behavior_27b_v1
  • Train samples: 5684
  • Validation samples: 293
  • Runtime: 23384.78 seconds
  • Final train loss: 3.5116
  • Final eval loss: 0.436
  • Thinking mode during training: disabled

LoRA configuration before merge

  • Rank r: 32
  • Alpha: 32
  • Dropout: 0.0
  • Bias: none
  • Target modules:
    • q_proj
    • k_proj
    • v_proj
    • o_proj
    • gate_proj
    • up_proj
    • down_proj

Recommended use

Best fit:

  • Spanish legal RAG over statutes and case law;
  • systems that pass visible source excerpts to the model;
  • structured legal summarization with explicit limits.

Recommended guardrails:

  • instruct the model to answer only from retrieved material;
  • distinguish between "norm cited by the judgment" and "currently visible statutory text";
  • require explicit statements like no consta when the context is partial;
  • prefer deterministic decoding for legal production workflows.

Not a full legal authority

This model is not a substitute for:

  • legal source validation;
  • current-law verification;
  • professional legal review.

It should not be used to assert current legal validity unless the current statutory text is explicitly present in the retrieved context.

Usage with Transformers

from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

model_id = "Abogatic/qwen35-27b-legal-sft-es-v1-merged"

tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    trust_remote_code=True,
    torch_dtype=torch.bfloat16,
    device_map="auto",
)
model.eval()

Usage with vLLM

vllm serve Abogatic/qwen35-27b-legal-sft-es-v1-merged \
  --trust-remote-code \
  --generation-config vllm \
  --default-chat-template-kwargs '{"enable_thinking": false}'

Languages

  • Spanish

Source and licensing notes

This merged model was trained from anonymized judicial material transformed into behavioral SFT examples. Review the legal and organizational requirements applicable to the source corpus before redistribution or downstream commercial use.

Use remains subject to the base model license and the legal constraints of the training corpus.

Downloads last month
11
Safetensors
Model size
27B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Abogatic/qwen35-27b-legal-sft-es-v1-merged

Base model

Qwen/Qwen3.5-27B
Finetuned
(290)
this model