summary refs log tree commit diff
path: root/pkgs/development/python-modules/transformers/default.nix
blob: dcc89161d4eaa5ec42b457a87e393151b3426e49 (plain) (blame)
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
{ lib
, buildPythonPackage
, fetchFromGitHub
, pythonOlder
, cookiecutter
, filelock
, huggingface-hub
, importlib-metadata
, regex
, requests
, numpy
, packaging
, tensorflow
, sagemaker
, ftfy
, protobuf
, scikit-learn
, pillow
, pyyaml
, pytorch
, tokenizers
, tqdm
}:

buildPythonPackage rec {
  pname = "transformers";
  version = "4.19.2";
  format = "setuptools";

  disabled = pythonOlder "3.7";

  src = fetchFromGitHub {
    owner = "huggingface";
    repo = pname;
    rev = "refs/tags/v${version}";
    hash = "sha256-9r/1vW7Rhv9+Swxdzu5PTnlQlT8ofJeZamHf5X4ql8w=";
  };

  propagatedBuildInputs = [
    filelock
    huggingface-hub
    numpy
    protobuf
    packaging
    pyyaml
    regex
    requests
    tokenizers
    tqdm
  ] ++ lib.optionals (pythonOlder "3.8") [
    importlib-metadata
  ];

  passthru.optional-dependencies = {
    ja = [
      # fugashi
      # ipadic
      # unidic_lite
      # unidic
    ];
    sklearn = [
      scikit-learn
    ];
    tf = [
      tensorflow
      # onnxconverter-common
      # tf2onnx
    ];
    torch = [
      pytorch
    ];
    tokenizers = [
      tokenizers
    ];
    modelcreation = [
      cookiecutter
    ];
    sagemaker = [
      sagemaker
    ];
    ftfy = [ ftfy ];
    onnx = [
      # onnxconverter-common
      # tf2onnx
    ];
    vision = [
      pillow
    ];
  };


  # Many tests require internet access.
  doCheck = false;

  pythonImportsCheck = [
    "transformers"
  ];

  meta = with lib; {
    homepage = "https://github.com/huggingface/transformers";
    description = "Natural Language Processing for TensorFlow 2.0 and PyTorch";
    changelog = "https://github.com/huggingface/transformers/releases/tag/v${version}";
    license = licenses.asl20;
    platforms = platforms.unix;
    maintainers = with maintainers; [ pashashocky ];
  };
}