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-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-09-25 04:45:31 +00:00
|
|
|
version = "3.2.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "huggingface";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2020-09-25 04:45:31 +00:00
|
|
|
sha256 = "0jj94153kgdyklra30xcszxv11hwzfigzy82fgvgzvbwlxv3a1j5";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2020-07-18 16:06:22 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
boto3
|
|
|
|
filelock
|
|
|
|
numpy
|
|
|
|
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-07-18 16:06:22 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace setup.py \
|
2020-09-25 04:45:31 +00:00
|
|
|
--replace "tokenizers == 0.8.1.rc2" "tokenizers>=0.8"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2020-07-18 16:06:22 +00:00
|
|
|
preCheck = ''
|
|
|
|
export HOME="$TMPDIR"
|
2020-09-25 04:45:31 +00:00
|
|
|
|
|
|
|
# This test requires the nlp module, which we haven't
|
|
|
|
# packaged yet. However, nlp is optional for transformers
|
|
|
|
# itself
|
|
|
|
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-09-25 04:45:31 +00:00
|
|
|
"PegasusTokenizationTest"
|
|
|
|
"T5TokenizationTest"
|
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
|
|
|
};
|
|
|
|
}
|