Artificial Intelligence, Machine Learning, Python, Data Science, Deep Learning.
vector per sentence embeddings = model_output.last_hidden_state attention_mask = encoded_input['attention_mask'] mask_expanded = attention_mask.unsqueeze(-1).expand(embeddings.size()).float() sum_embeddings = torch.sum(embeddings * mask_expanded, 1) sum_mask = torch.clamp(mask_expanded.sum(1),