Instructions to use GLLhJpFfYB/claim-gate-mdeberta with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use GLLhJpFfYB/claim-gate-mdeberta with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="GLLhJpFfYB/claim-gate-mdeberta")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("GLLhJpFfYB/claim-gate-mdeberta") model = AutoModelForSequenceClassification.from_pretrained("GLLhJpFfYB/claim-gate-mdeberta") - Notebooks
- Google Colab
- Kaggle
Claim / no-claim gate (mDeBERTa-v3, multilingüe)
Clasificador binario multilingüe que decide si una frase es un claim verificable
(1) o no (0). Fine-tune de
microsoft/mdeberta-v3-base
(DebertaV2ForSequenceClassification, 2 clases).
prob_claim = softmax(logits)[:, 1]. La decisión aplica un umbral calibrado en
validación (threshold.json; por defecto 0.5).
| Label | id | Significado |
|---|---|---|
no-claim |
0 | relleno / opinión / pregunta / no verificable |
claim |
1 | afirmación fáctica verificable |
Variantes incluidas en este repo
| Variante | Archivo | Tamaño | macro-F1 (test) | Uso |
|---|---|---|---|---|
| fp32 (torch/HF) | model.safetensors + config/tokenizer en la raíz |
~1.0 GB | 0.9967 | referencia y fine-tuning |
| ONNX fp32 | onnx/model.onnx |
~1.0 GB | 0.9967 | compatibilidad amplia (opset 17) |
| ONNX int8 | onnx/model_quantized.onnx |
~535 MB | 0.9967 | inferencia en CPU (opset 21) |
El int8 usa cuantización estática QDQ: pesos int8, activaciones int16, atención en fp32
y embeddings int8 weight-only. Reduce el tamaño ~48 % respecto al fp32 y conserva la
macro-F1 (0.9967). Es estable frente al padding: max|Δprob| = 0.0020 entre puntuar una
frase aislada o rellenada en un lote, con 0 cambios de veredicto.
Requiere onnxruntime >= 1.20 (cuantización de 16 bits, opset 21). Con versiones
anteriores, usar onnx/model.onnx (fp32, opset 17), equivalente bit a bit al modelo
torch (max|Δprob| = 0.0000).
Uso
fp32 con transformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
repo = "<ORG>/claim-gate-mdeberta"
tok = AutoTokenizer.from_pretrained(repo)
model = AutoModelForSequenceClassification.from_pretrained(repo).eval()
enc = tok("El PIB de España creció un 3% en 2023.", return_tensors="pt",
truncation=True, max_length=64)
with torch.no_grad():
prob_claim = model(**enc).logits.softmax(-1)[0, 1].item()
print(prob_claim >= 0.5, prob_claim) # True 0.99...
ONNX fp32 con optimum
from optimum.onnxruntime import ORTModelForSequenceClassification
from transformers import AutoTokenizer
repo = "<ORG>/claim-gate-mdeberta"
tok = AutoTokenizer.from_pretrained(repo)
model = ORTModelForSequenceClassification.from_pretrained(repo, subfolder="onnx",
file_name="model.onnx")
Runtime mínimo (onnxruntime + tokenizers, sin torch/transformers)
import numpy as np, onnxruntime as ort
from tokenizers import Tokenizer
tok = Tokenizer.from_file("tokenizer.json")
tok.enable_truncation(max_length=64)
tok.enable_padding(pad_id=0, pad_token="[PAD]")
enc = tok.encode_batch(["El PIB de España creció un 3% en 2023."])
sess = ort.InferenceSession("onnx/model.onnx", providers=["CPUExecutionProvider"])
feed = {
"input_ids": np.array([e.ids for e in enc], dtype=np.int64),
"attention_mask": np.array([e.attention_mask for e in enc], dtype=np.int64),
}
logits = sess.run(None, feed)[0]
prob_claim = np.exp(logits - logits.max(-1, keepdims=True))
prob_claim = (prob_claim / prob_claim.sum(-1, keepdims=True))[:, 1]
Entrenamiento
- Base:
microsoft/mdeberta-v3-base(encoder multilingüe, ~100 idiomas). - Fine-tune completo para clasificación binaria de secuencias: AdamW, LR barrido en
{1e-5, 2e-5, 3e-5}, warmup ~8 %, hasta 15 epochs con early stopping (paciencia 3) sobre macro-F1, class weights por desbalanceo,max_length=64. - fp32 uniforme (fp16 produce NaN en DeBERTa-v3). Selección por validación y confirmación multi-semilla (42/123/2024).
Evaluación
- Macro-F1 (test) = 0.9967 con
threshold = 0.5(n = 311). - Paridad de empaquetado: ONNX fp32 vs torch
max|Δprob| = 0.0000, invariante al padding.
Uso previsto y limitaciones
- Gate previo a un verificador de hechos: filtra frases sin contenido verificable. No juzga la veracidad de un claim, solo si es un claim.
- Optimizado para frases cortas (
max_length=64); textos largos se truncan. - Evaluado principalmente en ES/EN/FR/IT; otros idiomas heredan la cobertura del base model pero no están medidos aquí.
Licencia
MIT, heredada del base model microsoft/mdeberta-v3-base (MIT).
Cita
Este modelo es un fine-tune de DeBERTaV3. Si lo usas, cita los papers del base model:
@misc{he2021debertav3,
title={DeBERTaV3: Improving DeBERTa using ELECTRA-Style Pre-Training with Gradient-Disentangled Embedding Sharing},
author={Pengcheng He and Jianfeng Gao and Weizhu Chen},
year={2021},
eprint={2111.09543},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
@inproceedings{he2021deberta,
title={DeBERTa: Decoding-enhanced BERT with Disentangled Attention},
author={Pengcheng He and Xiaodong Liu and Jianfeng Gao and Weizhu Chen},
booktitle={International Conference on Learning Representations},
year={2021},
url={https://openreview.net/forum?id=XPZIaotutsD}
}
- Downloads last month
- 47
Model tree for GLLhJpFfYB/claim-gate-mdeberta
Base model
microsoft/mdeberta-v3-basePaper for GLLhJpFfYB/claim-gate-mdeberta
Evaluation results
- Macro F1 (test)self-reported0.997