2020-04-24 23:36:52 +00:00
|
|
|
{ buildPythonPackage
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, boto3
|
2020-07-18 16:06:22 +00:00
|
|
|
, filelock
|
2020-04-24 23:36:52 +00:00
|
|
|
, regex
|
2020-07-18 16:06:22 +00:00
|
|
|
, requests
|
2020-04-24 23:36:52 +00:00
|
|
|
, numpy
|
2020-09-25 04:45:31 +00:00
|
|
|
, parameterized
|
2020-11-03 02:18:15 +00:00
|
|
|
, protobuf
|
2020-07-18 16:06:22 +00:00
|
|
|
, sacremoses
|
|
|
|
, sentencepiece
|
|
|
|
, timeout-decorator
|
|
|
|
, tokenizers
|
|
|
|
, tqdm
|
|
|
|
, pytestCheckHook
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "transformers";
|
2020-11-03 02:18:15 +00:00
|
|
|
version = "3.4.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "huggingface";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2020-11-03 02:18:15 +00:00
|
|
|
sha256 = "1v09gryxsg57d2cjwagna1535m8mbxlazdbhsww210lxa818m5qj";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2020-07-18 16:06:22 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
filelock
|
|
|
|
numpy
|
2020-11-03 02:18:15 +00:00
|
|
|
protobuf
|
2020-07-18 16:06:22 +00:00
|
|
|
regex
|
|
|
|
requests
|
|
|
|
sacremoses
|
|
|
|
sentencepiece
|
|
|
|
tokenizers
|
|
|
|
tqdm
|
|
|
|
];
|
|
|
|
|
|
|
|
checkInputs = [
|
2020-09-25 04:45:31 +00:00
|
|
|
parameterized
|
2020-07-18 16:06:22 +00:00
|
|
|
pytestCheckHook
|
|
|
|
timeout-decorator
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-11-12 09:05:59 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace setup.py \
|
|
|
|
--replace "tokenizers == 0.9.2" "tokenizers"
|
|
|
|
'';
|
|
|
|
|
2020-07-18 16:06:22 +00:00
|
|
|
preCheck = ''
|
|
|
|
export HOME="$TMPDIR"
|
2020-09-25 04:45:31 +00:00
|
|
|
|
2020-10-07 09:15:18 +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-25 04:45:31 +00:00
|
|
|
rm tests/test_trainer.py
|
2020-07-18 16:06:22 +00:00
|
|
|
'';
|
|
|
|
|
2020-09-25 04:45:31 +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-18 16:06:22 +00:00
|
|
|
# Disable tests that require network access.
|
|
|
|
disabledTests = [
|
2020-11-03 02:18:15 +00:00
|
|
|
"BlenderbotSmallTokenizerTest"
|
|
|
|
"Blenderbot3BTokenizerTests"
|
|
|
|
"TokenizationTest"
|
|
|
|
"TestTokenizationBart"
|
2020-07-18 16:06:22 +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-25 04:45:31 +00:00
|
|
|
"test_padding_accepts_tensors"
|
2020-07-18 16:06:22 +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-25 04:45:31 +00:00
|
|
|
"test_tokenizer_from_tokenizer_class"
|
2020-07-18 16:06:22 +00:00
|
|
|
"test_tokenizer_identifier_with_correct_config"
|
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +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-25 04:45:31 +00:00
|
|
|
changelog = "https://github.com/huggingface/transformers/releases/tag/v${version}";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.asl20;
|
2020-08-20 17:08:02 +00:00
|
|
|
platforms = platforms.unix;
|
2020-07-18 16:06:22 +00:00
|
|
|
maintainers = with maintainers; [ danieldk pashashocky ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|