alignment-handbook
/
setup.py
147 строк · 4.8 Кб
1# Copyright 2023 The HuggingFace Team. All rights reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15# Adapted from huggingface/transformers: https://github.com/huggingface/transformers/blob/21a2d900eceeded7be9edc445b56877b95eda4ca/setup.py
16
17
18import re
19import shutil
20from pathlib import Path
21
22from setuptools import find_packages, setup
23
24
25# Remove stale alignment.egg-info directory to avoid https://github.com/pypa/pip/issues/5466
26stale_egg_info = Path(__file__).parent / "alignment.egg-info"
27if stale_egg_info.exists():
28print(
29(
30"Warning: {} exists.\n\n"
31"If you recently updated alignment, this is expected,\n"
32"but it may prevent alignment from installing in editable mode.\n\n"
33"This directory is automatically generated by Python's packaging tools.\n"
34"I will remove it now.\n\n"
35"See https://github.com/pypa/pip/issues/5466 for details.\n"
36).format(stale_egg_info)
37)
38shutil.rmtree(stale_egg_info)
39
40
41# IMPORTANT: all dependencies should be listed here with their version requirements, if any.
42# * If a dependency is fast-moving (e.g. transformers), pin to the exact version
43_deps = [
44"accelerate==0.27.2",
45"bitsandbytes==0.41.2.post2",
46"black==23.1.0",
47"datasets==2.14.6",
48"deepspeed==0.12.2",
49"einops>=0.6.1",
50"evaluate==0.4.0",
51"flake8>=6.0.0",
52"hf-doc-builder>=0.4.0",
53"hf_transfer>=0.1.4",
54"huggingface-hub>=0.19.2,<1.0",
55"isort>=5.12.0",
56"ninja>=1.11.1",
57"numpy>=1.24.2",
58"packaging>=23.0",
59"parameterized>=0.9.0",
60"peft==0.7.1",
61"protobuf<=3.20.2", # Needed to avoid conflicts with `transformers`
62"pytest",
63"safetensors>=0.3.3",
64"sentencepiece>=0.1.99",
65"scipy",
66"tensorboard",
67"torch==2.1.2",
68"transformers>=4.38.2", # Fixes RoPE computation
69"trl==0.7.10",
70"jinja2>=3.0.0",
71"tqdm>=4.64.1",
72]
73
74# this is a lookup table with items like:
75#
76# tokenizers: "tokenizers==0.9.4"
77# packaging: "packaging"
78#
79# some of the values are versioned whereas others aren't.
80deps = {b: a for a, b in (re.findall(r"^(([^!=<>~ \[\]]+)(?:\[[^\]]+\])?(?:[!=<>~ ].*)?$)", x)[0] for x in _deps)}
81
82
83def deps_list(*pkgs):
84return [deps[pkg] for pkg in pkgs]
85
86
87extras = {}
88extras["tests"] = deps_list("pytest", "parameterized")
89extras["torch"] = deps_list("torch")
90extras["quality"] = deps_list("black", "isort", "flake8")
91extras["docs"] = deps_list("hf-doc-builder")
92extras["dev"] = extras["docs"] + extras["quality"] + extras["tests"]
93
94# core dependencies shared across the whole project - keep this to a bare minimum :)
95install_requires = [
96deps["accelerate"],
97deps["bitsandbytes"],
98deps["einops"],
99deps["evaluate"],
100deps["datasets"],
101deps["deepspeed"],
102deps["hf_transfer"],
103deps["huggingface-hub"],
104deps["jinja2"],
105deps["ninja"],
106deps["numpy"],
107deps["packaging"], # utilities from PyPA to e.g., compare versions
108deps["peft"],
109deps["protobuf"],
110deps["safetensors"],
111deps["sentencepiece"],
112deps["scipy"],
113deps["tensorboard"],
114deps["tqdm"], # progress bars in model download and training scripts
115deps["transformers"],
116deps["trl"],
117]
118
119setup(
120name="alignment-handbook",
121version="0.4.0.dev0", # expected format is one of x.y.z.dev0, or x.y.z.rc1 or x.y.z (no to dashes, yes to dots)
122author="The Hugging Face team (past and future)",
123author_email="lewis@huggingface.co",
124description="The Alignment Handbook",
125long_description=open("README.md", "r", encoding="utf-8").read(),
126long_description_content_type="text/markdown",
127keywords="nlp deep learning rlhf llm",
128license="Apache",
129url="https://github.com/huggingface/alignment-handbook",
130package_dir={"": "src"},
131packages=find_packages("src"),
132zip_safe=False,
133extras_require=extras,
134python_requires=">=3.10.9",
135install_requires=install_requires,
136classifiers=[
137"Development Status :: 3 - Alpha",
138"Intended Audience :: Developers",
139"Intended Audience :: Education",
140"Intended Audience :: Science/Research",
141"License :: OSI Approved :: Apache Software License",
142"Operating System :: OS Independent",
143"Programming Language :: Python :: 3",
144"Programming Language :: Python :: 3.10",
145"Topic :: Scientific/Engineering :: Artificial Intelligence",
146],
147)
148