Spaces:
Sleeping
Sleeping
File size: 7,374 Bytes
f60bb61 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | """Default hyperparameters shared across training experiments."""
# ββ HuggingFace org & auth βββββββββββββββββββββββββββββββββββββββββββββββββββ
HF_ORG = "AITeamUIT"
# Collection slugs β fill in after creating collections on HF Hub UI:
# https://huggingface.co/AITeamUIT β Collections β New collection
MODEL_COLLECTION_SLUG = "AITeamUIT/securepii-model" # e.g. "AITeamUIT/securepii-<id>"
BENCH_COLLECTION_SLUG ="AITeamUIT/securepii-bench" # e.g. "AITeamUIT/securepii-bench-<id>"
# ββ Dataset ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
TRAIN_DATASET_ID = "quynong/rosenxt-v7-15-6-full"
EVAL_DATASET_ID = "trinhtrantran122/gen_aug_dataset"
EVAL_SPLIT = "train"
LANGUAGES = ["en", "de", "vi"]
MAX_TRAIN_SAMPLES = 1_000_000
MAX_VAL_SAMPLES = 5000
# ββ K-Fold Cross-Validation ββββββββββββββββββββββββββββββββββββββββββββββββββ
FOLD_DATASET_ID = "quynong/rosenxt-v7-15-6" # dataset with fold_k_train / fold_k_test splits
N_FOLDS = 5
# Fine-tune validation set (secondary eval source)
FINETUNE_VAL_DATASET = "quynong/rosenxt-v7-15-6-full"
FINETUNE_VAL_SPLIT = "test"
FINETUNE_VAL_MAX = 5000
EXTRA_LANGS_FROM_FT = ["en", "de", "vi"]
USE_EXTRA_FT_VAL = True
# ββ Training defaults (Baseline & DataAug) βββββββββββββββββββββββββββββββββββ
USE_LABEL_DESCRIPTIONS = True
MAX_WIDTH = 30
DEFAULT_TRAINING = dict(
num_epochs=3,
max_steps=-1,
batch_size=8,
eval_batch_size=8,
max_len=1024, # word-level tokens (WhitespaceTokenSplitter units)
encoder_lr=1e-5,
task_lr=5e-4,
weight_decay=0.01,
adam_beta1=0.9,
adam_beta2=0.999,
adam_epsilon=1e-8,
max_grad_norm=1.0,
scheduler_type="linear",
warmup_ratio=0.1,
warmup_steps=0,
num_cycles=0.5,
fp16=True,
bf16=False,
eval_strategy="epoch",
save_total_limit=2,
save_best=True,
metric_for_best="eval_loss",
greater_is_better=False,
logging_steps=50,
logging_first_step=True,
report_to_wandb=False,
early_stopping=False,
early_stopping_patience=3,
early_stopping_threshold=0.0,
num_workers=4,
pin_memory=True,
prefetch_factor=2,
seed=42,
deterministic=False,
validate_data=True,
use_lora=False,
lora_r=16,
lora_alpha=32.0,
lora_dropout=0.0,
lora_target_modules=["encoder", "span_rep", "classifier", "count_embed", "count_pred"],
save_adapter_only=True,
)
# ββ mmBERT overrides (applied on top of DEFAULT_TRAINING) βββββββββββββββββββ
MMBERT_OVERRIDES = dict(
num_epochs=6, # cold-start task heads need more epochs
max_len=2048,
task_lr=2e-4,
adam_epsilon=1e-6,
fp16=False,
bf16=True, # H100 native bfloat16
eval_strategy="steps",
eval_steps=2000,
early_stopping=True,
early_stopping_patience=2,
)
# ββ Data augmentation defaults βββββββββββββββββββββββββββββββββββββββββββββββ
AUG_FACTOR = 1 # augmented copies per selected example
AUG_RATIO = 0.5 # fraction of train examples to augment
AUG_SEED = 42
# ββ Evaluation defaults ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
THRESHOLD = 0.7
BENCHMARK_THRESHOLD = 0.7 # stricter threshold used in full benchmark runs
# Per-label threshold overrides for schema building.
# Labels listed here use the given threshold; all others use the global
# threshold passed to model.extract() (BENCHMARK_THRESHOLD = 0.7).
PER_LABEL_THRESHOLDS = {
# NhΓ³m cαΊ§n giαΊ£m threshold Δα» tΔng recall
"API_KEY": 0.35,
"PLATE": 0.50,
"ACCOUNT_ID": 0.55,
"BANK_ACCOUNT": 0.55,
"LICENSE": 0.55,
"MEDICAL_INFO": 0.55,
"TIME": 0.55,
"PREFIX": 0.55,
"ETHNICITY": 0.60,
"TIN": 0.60,
"NATIONAL_ID": 0.65,
# NhΓ³m cαΊ§n tΔng threshold Δα» giαΊ£m false positive
"TICKET_ID": 0.65,
"CARD_NUMBER": 0.85,
"EMPLOYEE_ID": 0.6,
"JOB_TITLE": 0.85,
"PIN": 0.88,
# NhΓ³m giα»― α»n Δα»nh
"ADDRESS": 0.70,
"AGE": 0.70,
"BIRTHDATE": 0.70,
"COORDINATE": 0.70,
"DATE": 0.70,
"EMAIL": 0.70,
"IBAN": 0.70,
"INSURANCE_ID": 0.70,
"IP": 0.70,
"LOCATION": 0.70,
"MARITAL": 0.70,
"MONEY": 0.70,
"NATIONALITY": 0.70,
"ORGANIZATION": 0.70,
"PASSPORT": 0.70,
"PASSWORD": 0.70,
"PERSON": 0.70,
"PHONE": 0.70,
"RELIGION": 0.70,
"SWIFT": 0.70,
"TRADE_UNION": 0.70,
"USERNAME": 0.70,
# NhΓ³m hΖ‘i nghiΓͺng vα» recall cao, cΓ³ thα» giα»― hoαΊ·c tΔng nhαΊΉ
"CARD_ISSUER": 0.75,
"CVV": 0.75,
"GENDER": 0.75,
"URL": 0.75,
"WALLET": 0.75,
"ZIP_CODE": 0.75,
}
IOU_THRESH = 0.5
MAX_TOKENS_PER_CHUNK = 1024
CHUNK_SAFETY_MARGIN = 20
MAX_CHARS_PER_CHUNK = 1000
RANDOM_SEED = 123
PARALLEL_BATCH_SIZE = 8
# ββ Benchmark model registry βββββββββββββββββββββββββββββββββββββββββββββββββ
BENCHMARK_MODELS = [
{
"name": "glinerv2",
"display": "glinerv2",
"repo_id": "AITeamUIT/gliner2-multi-v1-3e-20260514",
"subfolder": None,
"max_width": 30,
"chunk": True,
"chunk_tokens": 768,
},
{
"name": "glinerv2_data_aug",
"display": "glinerv2 data aug",
"repo_id": "AITeamUIT/gliner2-multi-v1-3e-20260514-dataaug",
"subfolder": None,
"max_width": 30,
"chunk": True,
"chunk_tokens": 768,
},
{
"name": "glinerv2_mmbert_backbone",
"display": "glinerv2 mmbert backbone",
"repo_id": "AITeamUIT/gliner2-mmbert-base-rosenxt-6e-20260515",
"subfolder": None,
"max_width": 30,
"chunk": True,
"chunk_tokens": 2048,
},
{
"name": "glinerv2_quy",
"display": "glinerv2 quy",
"repo_id": "AITeamUIT/gliner2-rosenxt-full-20260515-quy",
"subfolder": "best",
"max_width": None,
"chunk": False,
"chunk_tokens": None,
},
{
"name": "gliner_v2_quy_code_sai",
"display": "gliner v2 quy code sai",
"repo_id": "AITeamUIT/gliner2-rosenxt-multi-v7",
"subfolder": "best",
"max_width": None,
"chunk": False,
"chunk_tokens": None,
},
]
|