Views
No views yet
| Componente | Detalle |
|---|---|
| Base | microsoft/mdeberta-v3-base |
| Task | pibimacecv3 |
| Intent heads | 5 (activity, calc_mode, investment, region, req_form) |
| Slot labels | 15 (BIO) |
| Custom code | modeling_jointbert.py, module.py |
| Head | Clases | Valores |
|---|---|---|
activity | 3 | none, specific, general |
calc_mode | 4 | original, prev_period, yoy, contribution |
investment | 3 | none, specific, general |
region | 3 | none, specific, general |
req_form | 3 | latest, point, range |
activity, frequency, indicator, investment, period, region, seasonalityO, B-*, I-*).pip install torch transformers1import torch
2from transformers import AutoTokenizer, AutoConfig
3
4# Cargar tokenizer y config
5tokenizer = AutoTokenizer.from_pretrained("smenaaliaga/pibert-v2", trust_remote_code=True)
6config = AutoConfig.from_pretrained("smenaaliaga/pibert-v2", trust_remote_code=True)
7
8# Cargar labels desde el repo
9from huggingface_hub import hf_hub_download
10import os
11
12label_dir = os.path.dirname(hf_hub_download("smenaaliaga/pibert-v2", "labels/slot_label.txt"))
13
14# Leer intent y slot labels
15def read_labels(path):
16 with open(path) as f:
17 return [line.strip() for line in f if line.strip()]
18
19slot_labels = read_labels(os.path.join(label_dir, "slot_label.txt"))
20
21# Preparar intent_label_lst para cada head
22intent_label_lst = []
23for head in ['activity', 'calc_mode', 'investment', 'region', 'req_form']:
24 intent_label_lst.append(read_labels(os.path.join(label_dir, f"{head}_label.txt")))
25
26# Cargar modelo con custom code
27from transformers import AutoModelForTokenClassification
28from modeling_jointbert import JointBERT # auto-cargado con trust_remote_code
29
30model = JointBERT.from_pretrained(
31 "smenaaliaga/pibert-v2",
32 config=config,
33 intent_label_lst=intent_label_lst,
34 slot_label_lst=slot_labels,
35 trust_remote_code=True,
36)
37model.eval()1text = "cuál fue el imacec de agosto 2024"
2tokens = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
3
4with torch.no_grad():
5 outputs = model(**tokens)
6 # outputs contiene intent_logits (lista) y slot_logitsmodel_package/
├── config.json # Configuración BERT + task
├── model.safetensors # Pesos del modelo
├── tokenizer.json # Tokenizer
├── tokenizer_config.json
├── special_tokens_map.json
├── vocab.txt
├── modeling_jointbert.py # Arquitectura JointBERT (custom)
├── module.py # CRF y módulos auxiliares
├── __init__.py
├── README.md # Este archivo
└── labels/
├── slot_label.txt
├── activity_label.txt
├── calc_mode_label.txt
├── investment_label.txt
├── region_label.txt
├── req_form_label.txttrust_remote_code=True por la arquitectura custom1@misc{pibot-jointbert,
2 author = {Banco Central de Chile},
3 title = {PIBot Joint BERT - Multi-head Intent + Slot Filling},
4 year = {2025},
5 publisher = {Hugging Face},
6 howpublished = {\url{https://huggingface.co/smenaaliaga/pibert-v2}}
7}