Views
No views yet
| Loss term | Hệ số | Mô tả |
|---|---|---|
| Invariance | 25.0 | MSE giữa z1 và z2 (căn chỉnh hai views) |
| Variance | 25.0 | Giữ std của mỗi chiều ≥ 1 (chống collapse) |
| Covariance | 1.0 | Decorrelate các chiều embedding |
Text → BERT (mean-pool) → z ∈ R^768 → Expander MLP → z' ∈ R^3072
↑ VICReg loss áp dụng tại đây3072).| Tham số | Giá trị |
|---|---|
| Max sequence length | 256 |
| Batch size | 256 |
| Epochs | 10 |
| Learning rate | 0.0001 |
| Expander dim | 3072 |
| Max span length (masking) | 5 |
| sim_coeff | 25.0 |
| std_coeff | 25.0 |
| cov_coeff | 1.0 |
1from transformers import BertModel, BertTokenizerFast
2import torch
3
4tokenizer = BertTokenizerFast.from_pretrained("ducanhdinh/jepa_proof_vicreg")
5bert = BertModel.from_pretrained("ducanhdinh/jepa_proof_vicreg/encoder")
6
7encoded = tokenizer(
8 ["Hello world!", "VICReg is great."],
9 return_tensors="pt",
10 padding=True,
11 truncation=True,
12)
13with torch.no_grad():
14 out = bert(**encoded)
15 hidden = out.last_hidden_state # (B, T, 768)
16 mask = encoded["attention_mask"].unsqueeze(-1).float()
17 emb = (hidden * mask).sum(1) / mask.sum(1).clamp(min=1) # mean-pool → (B, 768)1import torch
2from transformers import BertTokenizerFast
3
4# Load weights thủ công
5from text_vicreg import TextVICReg, VICRegPretrainConfig
6
7cfg = VICRegPretrainConfig()
8model = TextVICReg(cfg)
9state = torch.load(
10 hf_hub_download("ducanhdinh/jepa_proof_vicreg", "pytorch_model.bin"),
11 map_location="cpu",
12)
13model.load_state_dict(state)
14model.eval()