-
Notifications
You must be signed in to change notification settings - Fork 0
/
model-pkgs.nix
61 lines (52 loc) · 1.37 KB
/
model-pkgs.nix
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
{ fetchurl
, models
}:
let
inherit (builtins) attrNames foldl' replaceStrings;
fetchHuggingFaceModel = { owner, repo, commit, model, hash }:
fetchurl {
url = "https://huggingface.co/${owner}/${repo}/resolve/${commit}/${model}?download=true";
inherit hash;
};
hf = models.huggingface;
# HuggingFace model list (objects with parameters for fetchHuggingFaceModel function)
hf-model-list =
foldl'
(acc: owner: acc ++
(foldl'
(acc: repo: acc ++
(foldl'
(acc: model: acc ++ [
{
inherit owner repo model;
commit = hf.${owner}."${repo}".commit;
hash = hf.${owner}."${repo}".models."${model}";
}
])
[ ]
(attrNames hf.${owner}.${repo}.models)
)
)
[ ]
(attrNames hf.${owner})
)
)
[ ]
(attrNames hf);
# HuggingFace model packages
hf-model-packages =
foldl'
(acc: pkg: acc // (
let
repo-str = replaceStrings [ "." ] [ "_" ] pkg.repo;
model-str = replaceStrings [ "." ] [ "_" ] pkg.model;
in
{
"HF__${pkg.owner}__${repo-str}__${model-str}" = fetchHuggingFaceModel pkg;
}
))
{ }
hf-model-list;
packages = hf-model-packages;
in
packages