Upload folder using huggingface_hub
Browse files- distill/__pycache__/config.cpython-311.pyc +0 -0
- distill/__pycache__/data.cpython-311.pyc +0 -0
- distill/__pycache__/loss.cpython-311.pyc +0 -0
- distill/__pycache__/model.cpython-311.pyc +0 -0
- distill/__pycache__/ternary_qat.cpython-311.pyc +0 -0
- distill/__pycache__/trainer.cpython-311.pyc +0 -0
- distill/config.py +2 -1
- distill/configs/multilingual-fp32-4layer.yaml +40 -0
- distill/configs/multilingual-fp32-contrastive.yaml +40 -0
- distill/evaluate_multilingual.py +2 -22
- distill/loss.py +5 -5
- distill/retrieval.py +38 -0
- distill/runs/multilingual-fp32-contrastive-screen-v1-mle5-sc/checkpoint_ep10.pt +3 -0
- distill/runs/multilingual-fp32-contrastive-screen-v1-mle5-sc/checkpoint_ep5.pt +3 -0
- distill/tests/test_multilingual_config.py +27 -0
- distill/tests/test_multilingual_evaluation.py +22 -0
- distill/trainer.py +5 -5
distill/__pycache__/config.cpython-311.pyc
CHANGED
|
Binary files a/distill/__pycache__/config.cpython-311.pyc and b/distill/__pycache__/config.cpython-311.pyc differ
|
|
|
distill/__pycache__/data.cpython-311.pyc
CHANGED
|
Binary files a/distill/__pycache__/data.cpython-311.pyc and b/distill/__pycache__/data.cpython-311.pyc differ
|
|
|
distill/__pycache__/loss.cpython-311.pyc
CHANGED
|
Binary files a/distill/__pycache__/loss.cpython-311.pyc and b/distill/__pycache__/loss.cpython-311.pyc differ
|
|
|
distill/__pycache__/model.cpython-311.pyc
CHANGED
|
Binary files a/distill/__pycache__/model.cpython-311.pyc and b/distill/__pycache__/model.cpython-311.pyc differ
|
|
|
distill/__pycache__/ternary_qat.cpython-311.pyc
CHANGED
|
Binary files a/distill/__pycache__/ternary_qat.cpython-311.pyc and b/distill/__pycache__/ternary_qat.cpython-311.pyc differ
|
|
|
distill/__pycache__/trainer.cpython-311.pyc
CHANGED
|
Binary files a/distill/__pycache__/trainer.cpython-311.pyc and b/distill/__pycache__/trainer.cpython-311.pyc differ
|
|
|
distill/config.py
CHANGED
|
@@ -88,7 +88,8 @@ class TrainConfig(BaseModel):
|
|
| 88 |
lr_warmup_ratio: float = 0.10
|
| 89 |
grad_clip: float = 1.0
|
| 90 |
|
| 91 |
-
# QAT
|
|
|
|
| 92 |
enable_qat: bool = False
|
| 93 |
qat_warmup_epochs: int = 0
|
| 94 |
contrastive_w: float = 0.0
|
|
|
|
| 88 |
lr_warmup_ratio: float = 0.10
|
| 89 |
grad_clip: float = 1.0
|
| 90 |
|
| 91 |
+
# QAT and optional embedding-collapse guardrail. The baseline keeps
|
| 92 |
+
# contrastive_w at zero; controlled FP32 recipes may opt in.
|
| 93 |
enable_qat: bool = False
|
| 94 |
qat_warmup_epochs: int = 0
|
| 95 |
contrastive_w: float = 0.0
|
distill/configs/multilingual-fp32-4layer.yaml
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Screening run: deeper 4-layer student with the existing FP32 objective.
|
| 2 |
+
|
| 3 |
+
wandb_project: ternlight-multilingual
|
| 4 |
+
wandb_group: multilingual-fp32-screen-v1
|
| 5 |
+
wandb_tags:
|
| 6 |
+
- teacher:multilingual-e5-small
|
| 7 |
+
- phase:fp32-screen
|
| 8 |
+
- variant:4layer
|
| 9 |
+
|
| 10 |
+
train:
|
| 11 |
+
vocab_size: 250037
|
| 12 |
+
d_model: 256
|
| 13 |
+
n_layers: 4
|
| 14 |
+
n_heads: 4
|
| 15 |
+
ffn_dim: 1024
|
| 16 |
+
output_dim: 384
|
| 17 |
+
dropout: 0.1
|
| 18 |
+
padding_idx: 1
|
| 19 |
+
tokenizer_id: intfloat/multilingual-e5-small
|
| 20 |
+
max_len: 128
|
| 21 |
+
|
| 22 |
+
cache_dir: cache
|
| 23 |
+
cache_name: multilingual_full_v1_1m2
|
| 24 |
+
|
| 25 |
+
epochs: 10
|
| 26 |
+
batch_size: 64
|
| 27 |
+
lr: 1.0e-4
|
| 28 |
+
weight_decay: 0.01
|
| 29 |
+
lr_warmup_ratio: 0.05
|
| 30 |
+
grad_clip: 1.0
|
| 31 |
+
|
| 32 |
+
enable_qat: false
|
| 33 |
+
qat_warmup_epochs: 0
|
| 34 |
+
contrastive_w: 0.0
|
| 35 |
+
relational_w: 0.1
|
| 36 |
+
|
| 37 |
+
run_name: multilingual-fp32-4layer-screen-v1
|
| 38 |
+
runs_dir: runs
|
| 39 |
+
save_every: 5
|
| 40 |
+
log_every_n_steps: 100
|
distill/configs/multilingual-fp32-contrastive.yaml
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Screening run: baseline 2-layer student with the QAT contrastive guardrail in FP32.
|
| 2 |
+
|
| 3 |
+
wandb_project: ternlight-multilingual
|
| 4 |
+
wandb_group: multilingual-fp32-screen-v1
|
| 5 |
+
wandb_tags:
|
| 6 |
+
- teacher:multilingual-e5-small
|
| 7 |
+
- phase:fp32-screen
|
| 8 |
+
- variant:contrastive
|
| 9 |
+
|
| 10 |
+
train:
|
| 11 |
+
vocab_size: 250037
|
| 12 |
+
d_model: 256
|
| 13 |
+
n_layers: 2
|
| 14 |
+
n_heads: 4
|
| 15 |
+
ffn_dim: 1024
|
| 16 |
+
output_dim: 384
|
| 17 |
+
dropout: 0.1
|
| 18 |
+
padding_idx: 1
|
| 19 |
+
tokenizer_id: intfloat/multilingual-e5-small
|
| 20 |
+
max_len: 128
|
| 21 |
+
|
| 22 |
+
cache_dir: cache
|
| 23 |
+
cache_name: multilingual_full_v1_1m2
|
| 24 |
+
|
| 25 |
+
epochs: 10
|
| 26 |
+
batch_size: 64
|
| 27 |
+
lr: 1.0e-4
|
| 28 |
+
weight_decay: 0.01
|
| 29 |
+
lr_warmup_ratio: 0.05
|
| 30 |
+
grad_clip: 1.0
|
| 31 |
+
|
| 32 |
+
enable_qat: false
|
| 33 |
+
qat_warmup_epochs: 0
|
| 34 |
+
contrastive_w: 0.15
|
| 35 |
+
relational_w: 0.1
|
| 36 |
+
|
| 37 |
+
run_name: multilingual-fp32-contrastive-screen-v1
|
| 38 |
+
runs_dir: runs
|
| 39 |
+
save_every: 5
|
| 40 |
+
log_every_n_steps: 100
|
distill/evaluate_multilingual.py
CHANGED
|
@@ -14,6 +14,7 @@ from transformers import AutoTokenizer
|
|
| 14 |
|
| 15 |
import ternary_qat
|
| 16 |
from model import StudentEncoder
|
|
|
|
| 17 |
|
| 18 |
DEFAULT_LANGUAGES = "ar,de,el,en,es,hi,ro,ru,th,tr,vi,zh"
|
| 19 |
|
|
@@ -90,28 +91,7 @@ def encode(model, tokenizer, texts: list[str], prefix: str, max_len: int, batch_
|
|
| 90 |
def retrieval_metrics(query_embeddings: torch.Tensor, passage_embeddings: torch.Tensor, relevant: list[int]):
|
| 91 |
similarities = query_embeddings @ passage_embeddings.T
|
| 92 |
top = similarities.topk(k=min(10, passage_embeddings.shape[0]), dim=1).indices.tolist()
|
| 93 |
-
|
| 94 |
-
reciprocal_ranks = 0.0
|
| 95 |
-
|
| 96 |
-
for expected, retrieved in zip(relevant, top):
|
| 97 |
-
for k in recalls:
|
| 98 |
-
recalls[k] += int(expected in retrieved[:k])
|
| 99 |
-
if expected in retrieved:
|
| 100 |
-
reciprocal_ranks += 1.0 / (retrieved.index(expected) + 1)
|
| 101 |
-
|
| 102 |
-
count = len(relevant)
|
| 103 |
-
return {
|
| 104 |
-
"recall@1": recalls[1] / count,
|
| 105 |
-
"recall@5": recalls[5] / count,
|
| 106 |
-
"recall@10": recalls[10] / count,
|
| 107 |
-
"mrr@10": reciprocal_ranks / count,
|
| 108 |
-
"queries": count,
|
| 109 |
-
}
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
def mean_metrics(results: dict[str, dict[str, float]]):
|
| 113 |
-
keys = ("recall@1", "recall@5", "recall@10", "mrr@10")
|
| 114 |
-
return {key: sum(row[key] for row in results.values()) / len(results) for key in keys}
|
| 115 |
|
| 116 |
|
| 117 |
def main(
|
|
|
|
| 14 |
|
| 15 |
import ternary_qat
|
| 16 |
from model import StudentEncoder
|
| 17 |
+
from retrieval import mean_metrics, ranking_metrics
|
| 18 |
|
| 19 |
DEFAULT_LANGUAGES = "ar,de,el,en,es,hi,ro,ru,th,tr,vi,zh"
|
| 20 |
|
|
|
|
| 91 |
def retrieval_metrics(query_embeddings: torch.Tensor, passage_embeddings: torch.Tensor, relevant: list[int]):
|
| 92 |
similarities = query_embeddings @ passage_embeddings.T
|
| 93 |
top = similarities.topk(k=min(10, passage_embeddings.shape[0]), dim=1).indices.tolist()
|
| 94 |
+
return ranking_metrics(top, relevant)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
|
| 96 |
|
| 97 |
def main(
|
distill/loss.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
"""Loss functions for distillation training.
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
"""
|
| 7 |
|
| 8 |
import torch
|
|
@@ -55,8 +55,8 @@ def contrastive_loss(student_emb: torch.Tensor) -> torch.Tensor:
|
|
| 55 |
"""Within-batch repulsion — penalize high similarity between *different*
|
| 56 |
samples in the same batch.
|
| 57 |
|
| 58 |
-
Used
|
| 59 |
-
|
| 60 |
space — many inputs mapped to the same region, each near its teacher
|
| 61 |
target but indistinguishable from siblings at retrieval time. This term
|
| 62 |
penalizes that pattern.
|
|
|
|
| 1 |
"""Loss functions for distillation training.
|
| 2 |
|
| 3 |
+
The FP32 baseline uses pointwise and relational distillation. QAT and
|
| 4 |
+
controlled FP32 experiments may add `contrastive_loss` as an embedding-
|
| 5 |
+
collapse guardrail — see docs/tern-training-pipeline.md.
|
| 6 |
"""
|
| 7 |
|
| 8 |
import torch
|
|
|
|
| 55 |
"""Within-batch repulsion — penalize high similarity between *different*
|
| 56 |
samples in the same batch.
|
| 57 |
|
| 58 |
+
Used as an opt-in guardrail. Under ternary quantization, the model has
|
| 59 |
+
reduced expressive capacity and can collapse the embedding
|
| 60 |
space — many inputs mapped to the same region, each near its teacher
|
| 61 |
target but indistinguishable from siblings at retrieval time. This term
|
| 62 |
penalizes that pattern.
|
distill/retrieval.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import math
|
| 2 |
+
|
| 3 |
+
METRIC_KEYS = ("recall@1", "recall@5", "recall@10", "mrr@10", "ndcg@10")
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def ranking_metrics(retrieved: list[list[int]], relevant: list[int]):
|
| 7 |
+
if len(retrieved) != len(relevant) or not relevant:
|
| 8 |
+
raise ValueError("retrieved and relevant must have the same non-zero length")
|
| 9 |
+
|
| 10 |
+
recalls = {1: 0, 5: 0, 10: 0}
|
| 11 |
+
reciprocal_ranks = 0.0
|
| 12 |
+
discounted_gains = 0.0
|
| 13 |
+
|
| 14 |
+
for expected, ranking in zip(relevant, retrieved):
|
| 15 |
+
top = ranking[:10]
|
| 16 |
+
for k in recalls:
|
| 17 |
+
recalls[k] += int(expected in top[:k])
|
| 18 |
+
if expected in top:
|
| 19 |
+
rank = top.index(expected)
|
| 20 |
+
reciprocal_ranks += 1.0 / (rank + 1)
|
| 21 |
+
discounted_gains += 1.0 / math.log2(rank + 2)
|
| 22 |
+
|
| 23 |
+
count = len(relevant)
|
| 24 |
+
return {
|
| 25 |
+
"recall@1": recalls[1] / count,
|
| 26 |
+
"recall@5": recalls[5] / count,
|
| 27 |
+
"recall@10": recalls[10] / count,
|
| 28 |
+
"mrr@10": reciprocal_ranks / count,
|
| 29 |
+
"ndcg@10": discounted_gains / count,
|
| 30 |
+
"queries": count,
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def mean_metrics(results: dict[str, dict[str, float]]):
|
| 35 |
+
return {
|
| 36 |
+
key: sum(row[key] for row in results.values()) / len(results)
|
| 37 |
+
for key in METRIC_KEYS
|
| 38 |
+
}
|
distill/runs/multilingual-fp32-contrastive-screen-v1-mle5-sc/checkpoint_ep10.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7c8b6eabe573a8b6bab5abbc5d28bde01fc83f65292b96920c92aa3dcb907c63
|
| 3 |
+
size 788279959
|
distill/runs/multilingual-fp32-contrastive-screen-v1-mle5-sc/checkpoint_ep5.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:49c68db82af2aefc4d4da8668dcbf59f6b4ddd6a378f748f45bbeb93efd75735
|
| 3 |
+
size 788279829
|
distill/tests/test_multilingual_config.py
CHANGED
|
@@ -43,6 +43,33 @@ class MultilingualConfigTest(unittest.TestCase):
|
|
| 43 |
self.assertEqual(fp32.padding_idx, qat.padding_idx)
|
| 44 |
self.assertEqual(fp32.tokenizer_id, qat.tokenizer_id)
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
if __name__ == "__main__":
|
| 48 |
unittest.main()
|
|
|
|
| 43 |
self.assertEqual(fp32.padding_idx, qat.padding_idx)
|
| 44 |
self.assertEqual(fp32.tokenizer_id, qat.tokenizer_id)
|
| 45 |
|
| 46 |
+
def test_fp32_screening_recipes_change_one_variable_each(self):
|
| 47 |
+
baseline = load_config(DISTILL / "configs" / "multilingual-fp32.yaml").train
|
| 48 |
+
contrastive = load_config(
|
| 49 |
+
DISTILL / "configs" / "multilingual-fp32-contrastive.yaml"
|
| 50 |
+
).train
|
| 51 |
+
four_layer = load_config(
|
| 52 |
+
DISTILL / "configs" / "multilingual-fp32-4layer.yaml"
|
| 53 |
+
).train
|
| 54 |
+
|
| 55 |
+
self.assertFalse(contrastive.enable_qat)
|
| 56 |
+
self.assertEqual(contrastive.n_layers, baseline.n_layers)
|
| 57 |
+
self.assertEqual(contrastive.relational_w, baseline.relational_w)
|
| 58 |
+
self.assertGreater(contrastive.contrastive_w, 0)
|
| 59 |
+
|
| 60 |
+
self.assertFalse(four_layer.enable_qat)
|
| 61 |
+
self.assertEqual(four_layer.n_layers, 4)
|
| 62 |
+
self.assertEqual(four_layer.contrastive_w, baseline.contrastive_w)
|
| 63 |
+
self.assertEqual(four_layer.relational_w, baseline.relational_w)
|
| 64 |
+
|
| 65 |
+
for candidate in (contrastive, four_layer):
|
| 66 |
+
self.assertEqual(candidate.epochs, 10)
|
| 67 |
+
self.assertEqual(candidate.cache_name, baseline.cache_name)
|
| 68 |
+
self.assertEqual(candidate.vocab_size, baseline.vocab_size)
|
| 69 |
+
self.assertEqual(candidate.padding_idx, baseline.padding_idx)
|
| 70 |
+
self.assertEqual(candidate.tokenizer_id, baseline.tokenizer_id)
|
| 71 |
+
self.assertEqual(candidate.output_dim, baseline.output_dim)
|
| 72 |
+
|
| 73 |
|
| 74 |
if __name__ == "__main__":
|
| 75 |
unittest.main()
|
distill/tests/test_multilingual_evaluation.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import math
|
| 2 |
+
import sys
|
| 3 |
+
import unittest
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
|
| 6 |
+
DISTILL = Path(__file__).resolve().parents[1]
|
| 7 |
+
sys.path.insert(0, str(DISTILL))
|
| 8 |
+
|
| 9 |
+
from retrieval import ranking_metrics
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
class MultilingualEvaluationTest(unittest.TestCase):
|
| 13 |
+
def test_retrieval_metrics_include_ndcg_at_10(self):
|
| 14 |
+
metrics = ranking_metrics([[0, 1, 2], [0, 1, 2]], [0, 1])
|
| 15 |
+
|
| 16 |
+
self.assertAlmostEqual(metrics["recall@1"], 0.5)
|
| 17 |
+
self.assertAlmostEqual(metrics["mrr@10"], 0.75)
|
| 18 |
+
self.assertAlmostEqual(metrics["ndcg@10"], (1.0 + 1.0 / math.log2(3.0)) / 2.0)
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
if __name__ == "__main__":
|
| 22 |
+
unittest.main()
|
distill/trainer.py
CHANGED
|
@@ -155,9 +155,9 @@ class Trainer:
|
|
| 155 |
loss = loss + self.cfg.relational_w * rel
|
| 156 |
running_rel += rel.item()
|
| 157 |
|
| 158 |
-
#
|
| 159 |
-
#
|
| 160 |
-
if self.cfg.
|
| 161 |
contrast = contrastive_loss(student_emb)
|
| 162 |
loss = loss + self.cfg.contrastive_w * contrast
|
| 163 |
running_contrast += contrast.item()
|
|
@@ -181,7 +181,7 @@ class Trainer:
|
|
| 181 |
"train_step/lr": self.scheduler.get_last_lr()[0],
|
| 182 |
"train_step/grad_norm": grad_norm.item(),
|
| 183 |
}
|
| 184 |
-
if self.cfg.
|
| 185 |
step_log["train_step/distill"] = distill.item()
|
| 186 |
step_log["train_step/contrast"] = contrast.item()
|
| 187 |
if self.cfg.relational_w > 0:
|
|
@@ -194,7 +194,7 @@ class Trainer:
|
|
| 194 |
"train/cosine_sim": running_cos / n,
|
| 195 |
"train/distill": running_distill / n,
|
| 196 |
}
|
| 197 |
-
if self.cfg.
|
| 198 |
out["train/contrast"] = running_contrast / n
|
| 199 |
if self.cfg.relational_w > 0:
|
| 200 |
out["train/relational"] = running_rel / n
|
|
|
|
| 155 |
loss = loss + self.cfg.relational_w * rel
|
| 156 |
running_rel += rel.item()
|
| 157 |
|
| 158 |
+
# Optional within-batch repulsion guardrail. QAT and controlled
|
| 159 |
+
# FP32 experiments opt in through contrastive_w.
|
| 160 |
+
if self.cfg.contrastive_w > 0:
|
| 161 |
contrast = contrastive_loss(student_emb)
|
| 162 |
loss = loss + self.cfg.contrastive_w * contrast
|
| 163 |
running_contrast += contrast.item()
|
|
|
|
| 181 |
"train_step/lr": self.scheduler.get_last_lr()[0],
|
| 182 |
"train_step/grad_norm": grad_norm.item(),
|
| 183 |
}
|
| 184 |
+
if self.cfg.contrastive_w > 0:
|
| 185 |
step_log["train_step/distill"] = distill.item()
|
| 186 |
step_log["train_step/contrast"] = contrast.item()
|
| 187 |
if self.cfg.relational_w > 0:
|
|
|
|
| 194 |
"train/cosine_sim": running_cos / n,
|
| 195 |
"train/distill": running_distill / n,
|
| 196 |
}
|
| 197 |
+
if self.cfg.contrastive_w > 0:
|
| 198 |
out["train/contrast"] = running_contrast / n
|
| 199 |
if self.cfg.relational_w > 0:
|
| 200 |
out["train/relational"] = running_rel / n
|