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
|
{
lib,
buildPythonPackage,
fetchFromGitHub,
# build-system
setuptools,
# dependencies
accelerate,
datasets,
huggingface-hub,
optimum,
pillow,
scikit-learn,
scipy,
torch,
tqdm,
transformers,
typing-extensions,
# tests
pytestCheckHook,
pytest-cov-stub,
}:
buildPythonPackage rec {
pname = "sentence-transformers";
version = "5.1.0";
pyproject = true;
src = fetchFromGitHub {
owner = "UKPLab";
repo = "sentence-transformers";
tag = "v${version}";
hash = "sha256-snowpTdHelcFjo1+hvqpoVt5ROB0f91yt0GsIvA5cso=";
};
build-system = [ setuptools ];
dependencies = [
huggingface-hub
pillow
scikit-learn
scipy
torch
tqdm
transformers
typing-extensions
];
optional-dependencies = {
train = [
accelerate
datasets
];
onnx = [ optimum ] ++ optimum.optional-dependencies.onnxruntime;
# onnx-gpu = [ optimum ] ++ optimum.optional-dependencies.onnxruntime-gpu;
# openvino = [ optimum-intel ] ++ optimum-intel.optional-dependencies.openvino;
};
nativeCheckInputs = [
pytest-cov-stub
pytestCheckHook
]
++ lib.flatten (builtins.attrValues optional-dependencies);
pythonImportsCheck = [ "sentence_transformers" ];
disabledTests = [
# Tests require network access
"test_LabelAccuracyEvaluator"
"test_ParaphraseMiningEvaluator"
"test_TripletEvaluator"
"test_cmnrl_same_grad"
"test_forward"
"test_initialization_with_embedding_dim"
"test_initialization_with_embedding_weights"
"test_loading_model2vec"
"test_mine_hard_negatives_with_prompt"
"test_model_card_base"
"test_model_card_reuse"
"test_nanobeir_evaluator"
"test_paraphrase_mining"
"test_pretrained_model"
"test_router_as_middle_module"
"test_router_backwards_compatibility"
"test_router_encode"
"test_router_load_with_config"
"test_router_save_load"
"test_router_save_load_with_custom_default_route"
"test_router_save_load_with_multiple_modules_per_route"
"test_router_save_load_without_default_route"
"test_router_with_trainer"
"test_router_with_trainer_without_router_mapping"
"test_save_and_load"
"test_simple_encode"
"test_tokenize"
"test_train_stsb"
"test_trainer"
"test_trainer_invalid_column_names"
"test_trainer_multi_dataset_errors"
# Assertion error: Sparse operations take too long
# (namely, load-sensitive test)
"test_performance_with_large_vectors"
];
disabledTestPaths = [
# Tests require network access
"tests/cross_encoder/test_cross_encoder.py"
"tests/cross_encoder/test_train_stsb.py"
"tests/evaluation/test_information_retrieval_evaluator.py"
"tests/sparse_encoder/models/test_csr.py"
"tests/sparse_encoder/models/test_sparse_static_embedding.py"
"tests/sparse_encoder/test_opensearch_models.py"
"tests/sparse_encoder/test_pretrained.py"
"tests/sparse_encoder/test_sparse_encoder.py"
"tests/test_compute_embeddings.py"
"tests/test_model_card_data.py"
"tests/test_multi_process.py"
"tests/test_pretrained_stsb.py"
"tests/test_sentence_transformer.py"
"tests/test_train_stsb.py"
"tests/util/test_hard_negatives.py"
];
# Sentence-transformer needs a writable hf_home cache
postInstall = ''
export HF_HOME=$(mktemp -d)
'';
meta = {
description = "Multilingual Sentence & Image Embeddings with BERT";
homepage = "https://github.com/UKPLab/sentence-transformers";
changelog = "https://github.com/UKPLab/sentence-transformers/releases/tag/${src.tag}";
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [ dit7ya ];
};
}
|