2019-12-06 18:40:29 +00:00
|
|
|
{ buildPythonPackage
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, boto3
|
2020-07-03 16:13:29 +00:00
|
|
|
, filelock
|
2019-12-06 18:40:29 +00:00
|
|
|
, regex
|
2020-07-03 16:13:29 +00:00
|
|
|
, requests
|
2019-12-06 18:40:29 +00:00
|
|
|
, numpy
|
2020-09-22 16:56:04 +00:00
|
|
|
, parameterized
|
2020-10-23 06:32:06 +00:00
|
|
|
, protobuf
|
2020-07-03 16:13:29 +00:00
|
|
|
, sacremoses
|
|
|
|
, sentencepiece
|
|
|
|
, timeout-decorator
|
|
|
|
, tokenizers
|
|
|
|
, tqdm
|
|
|
|
, pytestCheckHook
|
2019-12-06 18:40:29 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "transformers";
|
2020-10-23 06:32:06 +00:00
|
|
|
version = "3.4.0";
|
2019-12-06 18:40:29 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "huggingface";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2020-10-23 06:32:06 +00:00
|
|
|
sha256 = "1v09gryxsg57d2cjwagna1535m8mbxlazdbhsww210lxa818m5qj";
|
2019-12-06 18:40:29 +00:00
|
|
|
};
|
|
|
|
|
2020-07-03 16:13:29 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
filelock
|
|
|
|
numpy
|
2020-10-23 06:32:06 +00:00
|
|
|
protobuf
|
2020-07-03 16:13:29 +00:00
|
|
|
regex
|
|
|
|
requests
|
|
|
|
sacremoses
|
|
|
|
sentencepiece
|
|
|
|
tokenizers
|
|
|
|
tqdm
|
|
|
|
];
|
|
|
|
|
|
|
|
checkInputs = [
|
2020-09-22 16:56:04 +00:00
|
|
|
parameterized
|
2020-07-03 16:13:29 +00:00
|
|
|
pytestCheckHook
|
|
|
|
timeout-decorator
|
|
|
|
];
|
2019-12-06 18:40:29 +00:00
|
|
|
|
2020-11-10 17:22:51 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace setup.py \
|
|
|
|
--replace "tokenizers == 0.9.2" "tokenizers"
|
|
|
|
'';
|
|
|
|
|
2020-07-03 16:13:29 +00:00
|
|
|
preCheck = ''
|
|
|
|
export HOME="$TMPDIR"
|
2020-09-01 13:49:05 +00:00
|
|
|
|
2020-09-30 08:35:48 +00:00
|
|
|
# This test requires the `datasets` module to download test
|
|
|
|
# data. However, since we cannot download in the Nix sandbox
|
|
|
|
# and `dataset` is an optional dependency for transformers
|
|
|
|
# itself, we will just remove the tests files that import
|
|
|
|
# `dataset`.
|
|
|
|
rm tests/test_retrieval_rag.py
|
2020-09-22 16:56:04 +00:00
|
|
|
rm tests/test_trainer.py
|
2020-07-03 16:13:29 +00:00
|
|
|
'';
|
|
|
|
|
2020-09-22 16:56:04 +00:00
|
|
|
# We have to run from the main directory for the tests. However,
|
|
|
|
# letting pytest discover tests leads to errors.
|
|
|
|
pytestFlagsArray = [ "tests" ];
|
|
|
|
|
2020-07-03 16:13:29 +00:00
|
|
|
# Disable tests that require network access.
|
|
|
|
disabledTests = [
|
2020-10-23 06:32:06 +00:00
|
|
|
"BlenderbotSmallTokenizerTest"
|
|
|
|
"Blenderbot3BTokenizerTests"
|
|
|
|
"TokenizationTest"
|
|
|
|
"TestTokenizationBart"
|
2020-07-03 16:13:29 +00:00
|
|
|
"test_all_tokenizers"
|
|
|
|
"test_batch_encoding_is_fast"
|
|
|
|
"test_batch_encoding_pickle"
|
|
|
|
"test_config_from_model_shortcut"
|
|
|
|
"test_config_model_type_from_model_identifier"
|
|
|
|
"test_from_pretrained_use_fast_toggle"
|
|
|
|
"test_hf_api"
|
|
|
|
"test_outputs_can_be_shorter"
|
|
|
|
"test_outputs_not_longer_than_maxlen"
|
2020-09-01 13:49:05 +00:00
|
|
|
"test_padding_accepts_tensors"
|
2020-07-03 16:13:29 +00:00
|
|
|
"test_pretokenized_tokenizers"
|
|
|
|
"test_tokenizer_equivalence_en_de"
|
|
|
|
"test_tokenizer_from_model_type"
|
|
|
|
"test_tokenizer_from_model_type"
|
|
|
|
"test_tokenizer_from_pretrained"
|
2020-09-22 16:56:04 +00:00
|
|
|
"test_tokenizer_from_tokenizer_class"
|
2020-07-03 16:13:29 +00:00
|
|
|
"test_tokenizer_identifier_with_correct_config"
|
|
|
|
];
|
|
|
|
|
2019-12-06 18:40:29 +00:00
|
|
|
meta = with stdenv.lib; {
|
|
|
|
homepage = "https://github.com/huggingface/transformers";
|
|
|
|
description = "State-of-the-art Natural Language Processing for TensorFlow 2.0 and PyTorch";
|
2020-09-01 13:49:05 +00:00
|
|
|
changelog = "https://github.com/huggingface/transformers/releases/tag/v${version}";
|
2019-12-06 18:40:29 +00:00
|
|
|
license = licenses.asl20;
|
2020-08-05 07:04:14 +00:00
|
|
|
platforms = platforms.unix;
|
2020-07-03 16:13:09 +00:00
|
|
|
maintainers = with maintainers; [ danieldk pashashocky ];
|
2019-12-06 18:40:29 +00:00
|
|
|
};
|
|
|
|
}
|