This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datasets import load_dataset | |
from sentence_transformers import ( | |
SentenceTransformerTrainer, | |
SentenceTransformerTrainingArguments, | |
) | |
from pylate import evaluation, losses, models, utils | |
# Load the datasets required for knowledge distillation (train, queries, documents) | |
train = load_dataset( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import torch | |
import torch.distributed as dist | |
import lovely_tensors as lt; lt.monkey_patch() | |
def split_tensor(data: torch.Tensor, dim: int) -> torch.Tensor: | |
rank = dist.get_rank() | |
world_size = dist.get_world_size() |