Justinrune commited on
Commit
2852136
1 Parent(s): d6e9a56

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
.dockerignore ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .vscode
2
+ .git
3
+ .github
4
+ .venv
5
+ cache
6
+ data
7
+ hf_cache
8
+ output
9
+ examples
10
+ .dockerignore
11
+ .gitattributes
12
+ .gitignore
13
+ Dockerfile
.gitattributes CHANGED
@@ -1,35 +1,5 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
3
+ evaluation/ceval/ceval.zip filter=lfs diff=lfs merge=lfs -text
4
+ evaluation/cmmlu/cmmlu.zip filter=lfs diff=lfs merge=lfs -text
5
+ evaluation/mmlu/mmlu.zip filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.github/CODE_OF_CONDUCT.md ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, religion, or sexual identity
10
+ and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the
26
+ overall community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or
31
+ advances of any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email
35
+ address, without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ `hoshihiyouga AT gmail DOT com`.
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series
86
+ of actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or
93
+ permanent ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within
113
+ the community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.0, available at
119
+ https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120
+
121
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct
122
+ enforcement ladder](https://github.com/mozilla/diversity).
123
+
124
+ [homepage]: https://www.contributor-covenant.org
125
+
126
+ For answers to common questions about this code of conduct, see the FAQ at
127
+ https://www.contributor-covenant.org/faq. Translations are available at
128
+ https://www.contributor-covenant.org/translations.
.github/CONTRIBUTING.md ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Contributing to LLaMA Factory
2
+
3
+ Everyone is welcome to contribute, and we value everybody's contribution. Code contributions are not the only way to help the community. Answering questions, helping others, and improving the documentation are also immensely valuable.
4
+
5
+ It also helps us if you spread the word! Reference the library in blog posts about the awesome projects it made possible, shout out on Twitter every time it has helped you, or simply ⭐️ the repository to say thank you.
6
+
7
+ However you choose to contribute, please be mindful and respect our [code of conduct](CODE_OF_CONDUCT.md).
8
+
9
+ **This guide was heavily inspired by [transformers guide to contributing](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md).**
10
+
11
+ ## Ways to contribute
12
+
13
+ There are several ways you can contribute to LLaMA Factory:
14
+
15
+ * Fix outstanding issues with the existing code.
16
+ * Submit issues related to bugs or desired new features.
17
+ * Contribute to the examples or to the documentation.
18
+
19
+ ### Style guide
20
+
21
+ LLaMA Factory follows the [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html), check it for details.
.github/ISSUE_TEMPLATE/bug-report.yml ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: "\U0001F41B Bug / Help"
2
+ description: Create a report to help us improve the LLaMA Factory
3
+ body:
4
+ - type: checkboxes
5
+ id: reminder
6
+ attributes:
7
+ label: Reminder
8
+ description: |
9
+ Please ensure you have read the README carefully and searched the existing issues.
10
+ 请确保您已经认真阅读了 README 并且搜索过现有的 Issue。
11
+
12
+ options:
13
+ - label: I have read the README and searched the existing issues.
14
+ required: true
15
+
16
+ - type: textarea
17
+ id: system-info
18
+ validations:
19
+ required: true
20
+ attributes:
21
+ label: System Info
22
+ description: |
23
+ Please share your system info with us. You can run the command **llamafactory-cli env** and copy-paste its output below.
24
+ 请提供您的系统信息。您可以在命令行运行 **llamafactory-cli env** 并将其输出复制到该文本框中。
25
+
26
+ placeholder: llamafactory version, platform, python version, ...
27
+
28
+ - type: textarea
29
+ id: reproduction
30
+ validations:
31
+ required: true
32
+ attributes:
33
+ label: Reproduction
34
+ description: |
35
+ Please provide code snippets, error messages and stack traces that reproduces the problem.
36
+ 请提供运行参数,错误信息以及异常堆栈以便于我们复现该问题。
37
+ Remember to use Markdown tags to correctly format your code.
38
+ 请合理使用 Markdown 标签来格式化您的文本。
39
+
40
+ placeholder: |
41
+ ```bash
42
+ llamafactory-cli train ...
43
+ ```
44
+
45
+ - type: textarea
46
+ id: expected-behavior
47
+ validations:
48
+ required: false
49
+ attributes:
50
+ label: Expected behavior
51
+ description: |
52
+ Please provide a clear and concise description of what you would expect to happen.
53
+ 请提供您原本的目的,即这段代码的期望行为。
54
+
55
+ - type: textarea
56
+ id: others
57
+ validations:
58
+ required: false
59
+ attributes:
60
+ label: Others
.github/PULL_REQUEST_TEMPLATE.md ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ # What does this PR do?
2
+
3
+ Fixes # (issue)
4
+
5
+ ## Before submitting
6
+
7
+ - [ ] Did you read the [contributor guideline](https://github.com/hiyouga/LLaMA-Factory/blob/main/.github/CONTRIBUTING.md)?
8
+ - [ ] Did you write any new necessary tests?
.github/SECURITY.md ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Reporting Security Issues
2
+
3
+ To report a security issue, please use the GitHub Security Advisory ["Report a Vulnerability"](https://github.com/hiyouga/LLaMA-Factory/security/advisories/new) tab.
4
+
5
+ We will send a response indicating the next steps in handling your report. After the initial reply to your report, the security team will keep you informed of the progress towards a fix and full announcement, and may ask for additional information or guidance.
6
+
7
+ Report security bugs in third-party modules to the person or team maintaining the module.
.github/workflows/label_issue.yml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: label_issue
2
+
3
+ on:
4
+ issues:
5
+ types:
6
+ - opened
7
+
8
+ jobs:
9
+ label_issue:
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - env:
14
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15
+ ISSUE_URL: ${{ github.event.issue.html_url }}
16
+ run: |
17
+ gh issue edit $ISSUE_URL --add-label "pending"
.github/workflows/tests.yml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: tests
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ paths:
8
+ - "**.py"
9
+ - "requirements.txt"
10
+ - ".github/workflows/*.yml"
11
+ pull_request:
12
+ branches:
13
+ - main
14
+ paths:
15
+ - "**.py"
16
+ - "requirements.txt"
17
+ - ".github/workflows/*.yml"
18
+
19
+ jobs:
20
+ tests:
21
+ runs-on: ubuntu-latest
22
+
23
+ steps:
24
+ - name: Checkout
25
+ uses: actions/checkout@v4
26
+
27
+ - name: Set up Python
28
+ uses: actions/setup-python@v5
29
+ with:
30
+ python-version: "3.8"
31
+ cache: "pip"
32
+ cache-dependency-path: "setup.py"
33
+
34
+ - name: Install dependencies
35
+ run: |
36
+ python -m pip install --upgrade pip
37
+ python -m pip install .[torch,dev]
38
+
39
+ - name: Check quality
40
+ run: |
41
+ make style && make quality
42
+
43
+ - name: Test with pytest
44
+ run: |
45
+ make test
.gitignore ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/#use-with-ide
110
+ .pdm.toml
111
+
112
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113
+ __pypackages__/
114
+
115
+ # Celery stuff
116
+ celerybeat-schedule
117
+ celerybeat.pid
118
+
119
+ # SageMath parsed files
120
+ *.sage.py
121
+
122
+ # Environments
123
+ .env
124
+ .venv
125
+ env/
126
+ venv/
127
+ ENV/
128
+ env.bak/
129
+ venv.bak/
130
+
131
+ # Spyder project settings
132
+ .spyderproject
133
+ .spyproject
134
+
135
+ # Rope project settings
136
+ .ropeproject
137
+
138
+ # mkdocs documentation
139
+ /site
140
+
141
+ # mypy
142
+ .mypy_cache/
143
+ .dmypy.json
144
+ dmypy.json
145
+
146
+ # Pyre type checker
147
+ .pyre/
148
+
149
+ # pytype static type analyzer
150
+ .pytype/
151
+
152
+ # Cython debug symbols
153
+ cython_debug/
154
+
155
+ # PyCharm
156
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
159
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
160
+ .idea/
161
+
162
+ # custom .gitignore
163
+ user.config
164
+ saves/
165
+ cache/
CITATION.cff ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ cff-version: 1.2.0
2
+ date-released: 2024-03
3
+ message: "If you use this software, please cite it as below."
4
+ authors:
5
+ - family-names: "Zheng"
6
+ given-names: "Yaowei"
7
+ - family-names: "Zhang"
8
+ given-names: "Richong"
9
+ - family-names: "Zhang"
10
+ given-names: "Junhao"
11
+ - family-names: "Ye"
12
+ given-names: "Yanhan"
13
+ - family-names: "Luo"
14
+ given-names: "Zheyan"
15
+ - family-names: "Ma"
16
+ given-names: "Yongqiang"
17
+ title: "LlamaFactory: Unified Efficient Fine-Tuning of 100+ Language Models"
18
+ url: "https://arxiv.org/abs/2403.13372"
19
+ preferred-citation:
20
+ type: article
21
+ authors:
22
+ - family-names: "Zheng"
23
+ given-names: "Yaowei"
24
+ - family-names: "Zhang"
25
+ given-names: "Richong"
26
+ - family-names: "Zhang"
27
+ given-names: "Junhao"
28
+ - family-names: "Ye"
29
+ given-names: "Yanhan"
30
+ - family-names: "Luo"
31
+ given-names: "Zheyan"
32
+ - family-names: "Ma"
33
+ given-names: "Yongqiang"
34
+ journal: "arXiv preprint arXiv:2403.13372"
35
+ title: "LlamaFactory: Unified Efficient Fine-Tuning of 100+ Language Models"
36
+ url: "https://arxiv.org/abs/2403.13372"
37
+ year: 2024
Dockerfile ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use the NVIDIA official image with PyTorch 2.3.0
2
+ # https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes/rel-24-02.html
3
+ FROM nvcr.io/nvidia/pytorch:24.02-py3
4
+
5
+ # Define installation arguments
6
+ ARG INSTALL_BNB=false
7
+ ARG INSTALL_VLLM=false
8
+ ARG INSTALL_DEEPSPEED=false
9
+ ARG PIP_INDEX=https://pypi.org/simple
10
+
11
+ # Set the working directory
12
+ WORKDIR /app
13
+
14
+ # Install the requirements
15
+ COPY requirements.txt /app/
16
+ RUN pip config set global.index-url $PIP_INDEX
17
+ RUN python -m pip install --upgrade pip
18
+ RUN python -m pip install -r requirements.txt
19
+
20
+ # Copy the rest of the application into the image
21
+ COPY . /app/
22
+
23
+ # Install the LLaMA Factory
24
+ RUN EXTRA_PACKAGES="metrics"; \
25
+ if [ "$INSTALL_BNB" = "true" ]; then \
26
+ EXTRA_PACKAGES="${EXTRA_PACKAGES},bitsandbytes"; \
27
+ fi; \
28
+ if [ "$INSTALL_VLLM" = "true" ]; then \
29
+ EXTRA_PACKAGES="${EXTRA_PACKAGES},vllm"; \
30
+ fi; \
31
+ if [ "$INSTALL_DEEPSPEED" = "true" ]; then \
32
+ EXTRA_PACKAGES="${EXTRA_PACKAGES},deepspeed"; \
33
+ fi; \
34
+ pip install -e .[$EXTRA_PACKAGES] && \
35
+ pip uninstall -y transformer-engine flash-attn
36
+
37
+ # Set up volumes
38
+ VOLUME [ "/root/.cache/huggingface/", "/app/data", "/app/output" ]
39
+
40
+ # Expose port 7860 for the LLaMA Board
41
+ EXPOSE 7860
42
+
43
+ # Expose port 8000 for the API service
44
+ EXPOSE 8000
LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
MANIFEST.in ADDED
@@ -0,0 +1 @@
 
 
1
+ include LICENSE requirements.txt
Makefile ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .PHONY: quality style test
2
+
3
+ check_dirs := scripts src tests
4
+
5
+ quality:
6
+ ruff check $(check_dirs)
7
+ ruff format --check $(check_dirs)
8
+
9
+ style:
10
+ ruff check $(check_dirs) --fix
11
+ ruff format $(check_dirs)
12
+
13
+ test:
14
+ CUDA_VISIBLE_DEVICES= pytest tests/
README.md CHANGED
@@ -1,12 +1,578 @@
1
  ---
2
- title: LLaMA Factory
3
- emoji: 🏃
4
- colorFrom: pink
5
- colorTo: pink
6
  sdk: gradio
7
  sdk_version: 4.36.1
8
- app_file: app.py
9
- pinned: false
10
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: LLaMA-Factory
3
+ app_file: app.py
 
 
4
  sdk: gradio
5
  sdk_version: 4.36.1
 
 
6
  ---
7
+ ![# LLaMA Factory](assets/logo.png)
8
+
9
+ [![GitHub Repo stars](https://img.shields.io/github/stars/hiyouga/LLaMA-Factory?style=social)](https://github.com/hiyouga/LLaMA-Factory/stargazers)
10
+ [![GitHub Code License](https://img.shields.io/github/license/hiyouga/LLaMA-Factory)](LICENSE)
11
+ [![GitHub last commit](https://img.shields.io/github/last-commit/hiyouga/LLaMA-Factory)](https://github.com/hiyouga/LLaMA-Factory/commits/main)
12
+ [![PyPI](https://img.shields.io/pypi/v/llamafactory)](https://pypi.org/project/llamafactory/)
13
+ [![Citation](https://img.shields.io/badge/citation-44-green)](#projects-using-llama-factory)
14
+ [![GitHub pull request](https://img.shields.io/badge/PRs-welcome-blue)](https://github.com/hiyouga/LLaMA-Factory/pulls)
15
+ [![Discord](https://dcbadge.vercel.app/api/server/rKfvV9r9FK?compact=true&style=flat)](https://discord.gg/rKfvV9r9FK)
16
+ [![Twitter](https://img.shields.io/twitter/follow/llamafactory_ai)](https://twitter.com/llamafactory_ai)
17
+ [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1eRTPn37ltBbYsISy9Aw2NuI2Aq5CQrD9?usp=sharing)
18
+ [![Open in DSW](https://gallery.pai-ml.com/assets/open-in-dsw.svg)](https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory)
19
+ [![Spaces](https://img.shields.io/badge/🤗-Open%20in%20Spaces-blue)](https://huggingface.co/spaces/hiyouga/LLaMA-Board)
20
+ [![Studios](https://img.shields.io/badge/ModelScope-Open%20in%20Studios-blue)](https://modelscope.cn/studios/hiyouga/LLaMA-Board)
21
+
22
+ [![GitHub Tread](https://trendshift.io/api/badge/repositories/4535)](https://trendshift.io/repositories/4535)
23
+
24
+ 👋 Join our [WeChat](assets/wechat.jpg).
25
+
26
+ \[ English | [中文](README_zh.md) \]
27
+
28
+ **Fine-tuning a large language model can be easy as...**
29
+
30
+ https://github.com/hiyouga/LLaMA-Factory/assets/16256802/9840a653-7e9c-41c8-ae89-7ace5698baf6
31
+
32
+ Choose your path:
33
+
34
+ - **Colab**: https://colab.research.google.com/drive/1eRTPn37ltBbYsISy9Aw2NuI2Aq5CQrD9?usp=sharing
35
+ - **PAI-DSW**: https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory
36
+ - **Local machine**: Please refer to [usage](#getting-started)
37
+
38
+ ## Table of Contents
39
+
40
+ - [Features](#features)
41
+ - [Benchmark](#benchmark)
42
+ - [Changelog](#changelog)
43
+ - [Supported Models](#supported-models)
44
+ - [Supported Training Approaches](#supported-training-approaches)
45
+ - [Provided Datasets](#provided-datasets)
46
+ - [Requirement](#requirement)
47
+ - [Getting Started](#getting-started)
48
+ - [Projects using LLaMA Factory](#projects-using-llama-factory)
49
+ - [License](#license)
50
+ - [Citation](#citation)
51
+ - [Acknowledgement](#acknowledgement)
52
+
53
+ ## Features
54
+
55
+ - **Various models**: LLaMA, LLaVA, Mistral, Mixtral-MoE, Qwen, Yi, Gemma, Baichuan, ChatGLM, Phi, etc.
56
+ - **Integrated methods**: (Continuous) pre-training, (multimodal) supervised fine-tuning, reward modeling, PPO, DPO, KTO, ORPO, etc.
57
+ - **Scalable resources**: 32-bit full-tuning, 16-bit freeze-tuning, 16-bit LoRA and 2/4/8-bit QLoRA via AQLM/AWQ/GPTQ/LLM.int8.
58
+ - **Advanced algorithms**: GaLore, BAdam, DoRA, LongLoRA, LLaMA Pro, Mixture-of-Depths, LoRA+, LoftQ, PiSSA and Agent tuning.
59
+ - **Practical tricks**: FlashAttention-2, Unsloth, RoPE scaling, NEFTune and rsLoRA.
60
+ - **Experiment monitors**: LlamaBoard, TensorBoard, Wandb, MLflow, etc.
61
+ - **Faster inference**: OpenAI-style API, Gradio UI and CLI with vLLM worker.
62
+
63
+ ## Benchmark
64
+
65
+ Compared to ChatGLM's [P-Tuning](https://github.com/THUDM/ChatGLM2-6B/tree/main/ptuning), LLaMA Factory's LoRA tuning offers up to **3.7 times faster** training speed with a better Rouge score on the advertising text generation task. By leveraging 4-bit quantization technique, LLaMA Factory's QLoRA further improves the efficiency regarding the GPU memory.
66
+
67
+ ![benchmark](assets/benchmark.svg)
68
+
69
+ <details><summary>Definitions</summary>
70
+
71
+ - **Training Speed**: the number of training samples processed per second during the training. (bs=4, cutoff_len=1024)
72
+ - **Rouge Score**: Rouge-2 score on the development set of the [advertising text generation](https://aclanthology.org/D19-1321.pdf) task. (bs=4, cutoff_len=1024)
73
+ - **GPU Memory**: Peak GPU memory usage in 4-bit quantized training. (bs=1, cutoff_len=1024)
74
+ - We adopt `pre_seq_len=128` for ChatGLM's P-Tuning and `lora_rank=32` for LLaMA Factory's LoRA tuning.
75
+
76
+ </details>
77
+
78
+ ## Changelog
79
+
80
+ [24/06/16] We support **[PiSSA](https://arxiv.org/abs/2404.02948)** algorithm. See [examples](examples/README.md) for usage.
81
+
82
+ [24/06/07] We supported fine-tuning the **[Qwen2](https://qwenlm.github.io/blog/qwen2/)** and **[GLM-4](https://github.com/THUDM/GLM-4)** models.
83
+
84
+ [24/05/26] We supported **[SimPO](https://arxiv.org/abs/2405.14734)** algorithm for preference learning. See [examples](examples/README.md) for usage.
85
+
86
+ <details><summary>Full Changelog</summary>
87
+
88
+ [24/05/20] We supported fine-tuning the **PaliGemma** series models. Note that the PaliGemma models are pre-trained models, you need to fine-tune them with `gemma` template for chat completion.
89
+
90
+ [24/05/18] We supported **[KTO](https://arxiv.org/abs/2402.01306)** algorithm for preference learning. See [examples](examples/README.md) for usage.
91
+
92
+ [24/05/14] We supported training and inference on the Ascend NPU devices. Check [installation](#installation) section for details.
93
+
94
+ [24/04/26] We supported fine-tuning the **LLaVA-1.5** multimodal LLMs. See [examples](examples/README.md) for usage.
95
+
96
+ [24/04/22] We provided a **[Colab notebook](https://colab.research.google.com/drive/1eRTPn37ltBbYsISy9Aw2NuI2Aq5CQrD9?usp=sharing)** for fine-tuning the Llama-3 model on a free T4 GPU. Two Llama-3-derived models fine-tuned using LLaMA Factory are available at Hugging Face, check [Llama3-8B-Chinese-Chat](https://huggingface.co/shenzhi-wang/Llama3-8B-Chinese-Chat) and [Llama3-Chinese](https://huggingface.co/zhichen/Llama3-Chinese) for details.
97
+
98
+ [24/04/21] We supported **[Mixture-of-Depths](https://arxiv.org/abs/2404.02258)** according to [AstraMindAI's implementation](https://github.com/astramind-ai/Mixture-of-depths). See [examples](examples/README.md) for usage.
99
+
100
+ [24/04/16] We supported **[BAdam](https://arxiv.org/abs/2404.02827)**. See [examples](examples/README.md) for usage.
101
+
102
+ [24/04/16] We supported **[unsloth](https://github.com/unslothai/unsloth)**'s long-sequence training (Llama-2-7B-56k within 24GB). It achieves **117%** speed and **50%** memory compared with FlashAttention-2, more benchmarks can be found in [this page](https://github.com/hiyouga/LLaMA-Factory/wiki/Performance-comparison).
103
+
104
+ [24/03/31] We supported **[ORPO](https://arxiv.org/abs/2403.07691)**. See [examples](examples/README.md) for usage.
105
+
106
+ [24/03/21] Our paper "[LlamaFactory: Unified Efficient Fine-Tuning of 100+ Language Models](https://arxiv.org/abs/2403.13372)" is available at arXiv!
107
+
108
+ [24/03/20] We supported **FSDP+QLoRA** that fine-tunes a 70B model on 2x24GB GPUs. See [examples](examples/README.md) for usage.
109
+
110
+ [24/03/13] We supported **[LoRA+](https://arxiv.org/abs/2402.12354)**. See [examples](examples/README.md) for usage.
111
+
112
+ [24/03/07] We supported gradient low-rank projection (**[GaLore](https://arxiv.org/abs/2403.03507)**) algorithm. See [examples](examples/README.md) for usage.
113
+
114
+ [24/03/07] We integrated **[vLLM](https://github.com/vllm-project/vllm)** for faster and concurrent inference. Try `infer_backend: vllm` to enjoy **270%** inference speed.
115
+
116
+ [24/02/28] We supported weight-decomposed LoRA (**[DoRA](https://arxiv.org/abs/2402.09353)**). Try `use_dora: true` to activate DoRA training.
117
+
118
+ [24/02/15] We supported **block expansion** proposed by [LLaMA Pro](https://github.com/TencentARC/LLaMA-Pro). See [examples](examples/README.md) for usage.
119
+
120
+ [24/02/05] Qwen1.5 (Qwen2 beta version) series models are supported in LLaMA-Factory. Check this [blog post](https://qwenlm.github.io/blog/qwen1.5/) for details.
121
+
122
+ [24/01/18] We supported **agent tuning** for most models, equipping model with tool using abilities by fine-tuning with `dataset: glaive_toolcall_en`.
123
+
124
+ [23/12/23] We supported **[unsloth](https://github.com/unslothai/unsloth)**'s implementation to boost LoRA tuning for the LLaMA, Mistral and Yi models. Try `use_unsloth: true` argument to activate unsloth patch. It achieves **170%** speed in our benchmark, check [this page](https://github.com/hiyouga/LLaMA-Factory/wiki/Performance-comparison) for details.
125
+
126
+ [23/12/12] We supported fine-tuning the latest MoE model **[Mixtral 8x7B](https://huggingface.co/mistralai/Mixtral-8x7B-v0.1)** in our framework. See hardware requirement [here](#hardware-requirement).
127
+
128
+ [23/12/01] We supported downloading pre-trained models and datasets from the **[ModelScope Hub](https://modelscope.cn/models)** for Chinese mainland users. See [this tutorial](#download-from-modelscope-hub) for usage.
129
+
130
+ [23/10/21] We supported **[NEFTune](https://arxiv.org/abs/2310.05914)** trick for fine-tuning. Try `neftune_noise_alpha: 5` argument to activate NEFTune.
131
+
132
+ [23/09/27] We supported **$S^2$-Attn** proposed by [LongLoRA](https://github.com/dvlab-research/LongLoRA) for the LLaMA models. Try `shift_attn: true` argument to enable shift short attention.
133
+
134
+ [23/09/23] We integrated MMLU, C-Eval and CMMLU benchmarks in this repo. See [examples](examples/README.md) for usage.
135
+
136
+ [23/09/10] We supported **[FlashAttention-2](https://github.com/Dao-AILab/flash-attention)**. Try `flash_attn: fa2` argument to enable FlashAttention-2 if you are using RTX4090, A100 or H100 GPUs.
137
+
138
+ [23/08/12] We supported **RoPE scaling** to extend the context length of the LLaMA models. Try `rope_scaling: linear` argument in training and `rope_scaling: dynamic` argument at inference to extrapolate the position embeddings.
139
+
140
+ [23/08/11] We supported **[DPO training](https://arxiv.org/abs/2305.18290)** for instruction-tuned models. See [examples](examples/README.md) for usage.
141
+
142
+ [23/07/31] We supported **dataset streaming**. Try `streaming: true` and `max_steps: 10000` arguments to load your dataset in streaming mode.
143
+
144
+ [23/07/29] We released two instruction-tuned 13B models at Hugging Face. See these Hugging Face Repos ([LLaMA-2](https://huggingface.co/hiyouga/Llama-2-Chinese-13b-chat) / [Baichuan](https://huggingface.co/hiyouga/Baichuan-13B-sft)) for details.
145
+
146
+ [23/07/18] We developed an **all-in-one Web UI** for training, evaluation and inference. Try `train_web.py` to fine-tune models in your Web browser. Thank [@KanadeSiina](https://github.com/KanadeSiina) and [@codemayq](https://github.com/codemayq) for their efforts in the development.
147
+
148
+ [23/07/09] We released **[FastEdit](https://github.com/hiyouga/FastEdit)** ⚡🩹, an easy-to-use package for editing the factual knowledge of large language models efficiently. Please follow [FastEdit](https://github.com/hiyouga/FastEdit) if you are interested.
149
+
150
+ [23/06/29] We provided a **reproducible example** of training a chat model using instruction-following datasets, see [Baichuan-7B-sft](https://huggingface.co/hiyouga/Baichuan-7B-sft) for details.
151
+
152
+ [23/06/22] We aligned the [demo API](src/api_demo.py) with the [OpenAI's](https://platform.openai.com/docs/api-reference/chat) format where you can insert the fine-tuned model in **arbitrary ChatGPT-based applications**.
153
+
154
+ [23/06/03] We supported quantized training and inference (aka **[QLoRA](https://github.com/artidoro/qlora)**). See [examples](examples/README.md) for usage.
155
+
156
+ </details>
157
+
158
+ ## Supported Models
159
+
160
+ | Model | Model size | Template |
161
+ | -------------------------------------------------------- | -------------------------------- | --------- |
162
+ | [Baichuan2](https://huggingface.co/baichuan-inc) | 7B/13B | baichuan2 |
163
+ | [BLOOM](https://huggingface.co/bigscience) | 560M/1.1B/1.7B/3B/7.1B/176B | - |
164
+ | [BLOOMZ](https://huggingface.co/bigscience) | 560M/1.1B/1.7B/3B/7.1B/176B | - |
165
+ | [ChatGLM3](https://huggingface.co/THUDM) | 6B | chatglm3 |
166
+ | [Command-R](https://huggingface.co/CohereForAI) | 35B/104B | cohere |
167
+ | [DeepSeek (MoE)](https://huggingface.co/deepseek-ai) | 7B/16B/67B/236B | deepseek |
168
+ | [Falcon](https://huggingface.co/tiiuae) | 7B/11B/40B/180B | falcon |
169
+ | [Gemma/CodeGemma](https://huggingface.co/google) | 2B/7B | gemma |
170
+ | [GLM4](https://huggingface.co/THUDM) | 9B | glm4 |
171
+ | [InternLM2](https://huggingface.co/internlm) | 7B/20B | intern2 |
172
+ | [LLaMA](https://github.com/facebookresearch/llama) | 7B/13B/33B/65B | - |
173
+ | [LLaMA-2](https://huggingface.co/meta-llama) | 7B/13B/70B | llama2 |
174
+ | [LLaMA-3](https://huggingface.co/meta-llama) | 8B/70B | llama3 |
175
+ | [LLaVA-1.5](https://huggingface.co/llava-hf) | 7B/13B | vicuna |
176
+ | [Mistral/Mixtral](https://huggingface.co/mistralai) | 7B/8x7B/8x22B | mistral |
177
+ | [OLMo](https://huggingface.co/allenai) | 1B/7B | - |
178
+ | [PaliGemma](https://huggingface.co/google) | 3B | gemma |
179
+ | [Phi-1.5/2](https://huggingface.co/microsoft) | 1.3B/2.7B | - |
180
+ | [Phi-3](https://huggingface.co/microsoft) | 4B/7B/14B | phi |
181
+ | [Qwen](https://huggingface.co/Qwen) | 1.8B/7B/14B/72B | qwen |
182
+ | [Qwen1.5 (Code/MoE)](https://huggingface.co/Qwen) | 0.5B/1.8B/4B/7B/14B/32B/72B/110B | qwen |
183
+ | [Qwen2 (MoE)](https://huggingface.co/Qwen) | 0.5B/1.5B/7B/57B/72B | qwen |
184
+ | [StarCoder2](https://huggingface.co/bigcode) | 3B/7B/15B | - |
185
+ | [XVERSE](https://huggingface.co/xverse) | 7B/13B/65B | xverse |
186
+ | [Yi (1/1.5)](https://huggingface.co/01-ai) | 6B/9B/34B | yi |
187
+ | [Yi-VL](https://huggingface.co/01-ai) | 6B/34B | yi_vl |
188
+ | [Yuan](https://huggingface.co/IEITYuan) | 2B/51B/102B | yuan |
189
+
190
+ > [!NOTE]
191
+ > For the "base" models, the `template` argument can be chosen from `default`, `alpaca`, `vicuna` etc. But make sure to use the **corresponding template** for the "instruct/chat" models.
192
+ >
193
+ > Remember to use the **SAME** template in training and inference.
194
+
195
+ Please refer to [constants.py](src/llamafactory/extras/constants.py) for a full list of models we supported.
196
+
197
+ You also can add a custom chat template to [template.py](src/llamafactory/data/template.py).
198
+
199
+ ## Supported Training Approaches
200
+
201
+ | Approach | Full-tuning | Freeze-tuning | LoRA | QLoRA |
202
+ | ---------------------- | ------------------ | ------------------ | ------------------ | ------------------ |
203
+ | Pre-Training | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
204
+ | Supervised Fine-Tuning | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
205
+ | Reward Modeling | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
206
+ | PPO Training | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
207
+ | DPO Training | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
208
+ | KTO Training | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
209
+ | ORPO Training | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
210
+ | SimPO Training | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
211
+
212
+ ## Provided Datasets
213
+
214
+ <details><summary>Pre-training datasets</summary>
215
+
216
+ - [Wiki Demo (en)](data/wiki_demo.txt)
217
+ - [RefinedWeb (en)](https://huggingface.co/datasets/tiiuae/falcon-refinedweb)
218
+ - [RedPajama V2 (en)](https://huggingface.co/datasets/togethercomputer/RedPajama-Data-V2)
219
+ - [Wikipedia (en)](https://huggingface.co/datasets/olm/olm-wikipedia-20221220)
220
+ - [Wikipedia (zh)](https://huggingface.co/datasets/pleisto/wikipedia-cn-20230720-filtered)
221
+ - [Pile (en)](https://huggingface.co/datasets/EleutherAI/pile)
222
+ - [SkyPile (zh)](https://huggingface.co/datasets/Skywork/SkyPile-150B)
223
+ - [FineWeb (en)](https://huggingface.co/datasets/HuggingFaceFW/fineweb)
224
+ - [FineWeb-Edu (en)](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu)
225
+ - [The Stack (en)](https://huggingface.co/datasets/bigcode/the-stack)
226
+ - [StarCoder (en)](https://huggingface.co/datasets/bigcode/starcoderdata)
227
+
228
+ </details>
229
+
230
+ <details><summary>Supervised fine-tuning datasets</summary>
231
+
232
+ - [Identity (en&zh)](data/identity.json)
233
+ - [Stanford Alpaca (en)](https://github.com/tatsu-lab/stanford_alpaca)
234
+ - [Stanford Alpaca (zh)](https://github.com/ymcui/Chinese-LLaMA-Alpaca-3)
235
+ - [Alpaca GPT4 (en&zh)](https://github.com/Instruction-Tuning-with-GPT-4/GPT-4-LLM)
236
+ - [Glaive Function Calling V2 (en&zh)](https://huggingface.co/datasets/glaiveai/glaive-function-calling-v2)
237
+ - [LIMA (en)](https://huggingface.co/datasets/GAIR/lima)
238
+ - [Guanaco Dataset (multilingual)](https://huggingface.co/datasets/JosephusCheung/GuanacoDataset)
239
+ - [BELLE 2M (zh)](https://huggingface.co/datasets/BelleGroup/train_2M_CN)
240
+ - [BELLE 1M (zh)](https://huggingface.co/datasets/BelleGroup/train_1M_CN)
241
+ - [BELLE 0.5M (zh)](https://huggingface.co/datasets/BelleGroup/train_0.5M_CN)
242
+ - [BELLE Dialogue 0.4M (zh)](https://huggingface.co/datasets/BelleGroup/generated_chat_0.4M)
243
+ - [BELLE School Math 0.25M (zh)](https://huggingface.co/datasets/BelleGroup/school_math_0.25M)
244
+ - [BELLE Multiturn Chat 0.8M (zh)](https://huggingface.co/datasets/BelleGroup/multiturn_chat_0.8M)
245
+ - [UltraChat (en)](https://github.com/thunlp/UltraChat)
246
+ - [OpenPlatypus (en)](https://huggingface.co/datasets/garage-bAInd/Open-Platypus)
247
+ - [CodeAlpaca 20k (en)](https://huggingface.co/datasets/sahil2801/CodeAlpaca-20k)
248
+ - [Alpaca CoT (multilingual)](https://huggingface.co/datasets/QingyiSi/Alpaca-CoT)
249
+ - [OpenOrca (en)](https://huggingface.co/datasets/Open-Orca/OpenOrca)
250
+ - [SlimOrca (en)](https://huggingface.co/datasets/Open-Orca/SlimOrca)
251
+ - [MathInstruct (en)](https://huggingface.co/datasets/TIGER-Lab/MathInstruct)
252
+ - [Firefly 1.1M (zh)](https://huggingface.co/datasets/YeungNLP/firefly-train-1.1M)
253
+ - [Wiki QA (en)](https://huggingface.co/datasets/wiki_qa)
254
+ - [Web QA (zh)](https://huggingface.co/datasets/suolyer/webqa)
255
+ - [WebNovel (zh)](https://huggingface.co/datasets/zxbsmk/webnovel_cn)
256
+ - [Nectar (en)](https://huggingface.co/datasets/berkeley-nest/Nectar)
257
+ - [deepctrl (en&zh)](https://www.modelscope.cn/datasets/deepctrl/deepctrl-sft-data)
258
+ - [Advertise Generating (zh)](https://huggingface.co/datasets/HasturOfficial/adgen)
259
+ - [ShareGPT Hyperfiltered (en)](https://huggingface.co/datasets/totally-not-an-llm/sharegpt-hyperfiltered-3k)
260
+ - [ShareGPT4 (en&zh)](https://huggingface.co/datasets/shibing624/sharegpt_gpt4)
261
+ - [UltraChat 200k (en)](https://huggingface.co/datasets/HuggingFaceH4/ultrachat_200k)
262
+ - [AgentInstruct (en)](https://huggingface.co/datasets/THUDM/AgentInstruct)
263
+ - [LMSYS Chat 1M (en)](https://huggingface.co/datasets/lmsys/lmsys-chat-1m)
264
+ - [Evol Instruct V2 (en)](https://huggingface.co/datasets/WizardLM/WizardLM_evol_instruct_V2_196k)
265
+ - [Cosmopedia (en)](https://huggingface.co/datasets/HuggingFaceTB/cosmopedia)
266
+ - [STEM (zh)](https://huggingface.co/datasets/hfl/stem_zh_instruction)
267
+ - [Ruozhiba (zh)](https://huggingface.co/datasets/hfl/ruozhiba_gpt4_turbo)
268
+ - [Neo-sft (zh)](https://huggingface.co/datasets/m-a-p/neo_sft_phase2)
269
+ - [LLaVA mixed (en&zh)](https://huggingface.co/datasets/BUAADreamer/llava-en-zh-300k)
270
+ - [Open Assistant (de)](https://huggingface.co/datasets/mayflowergmbh/oasst_de)
271
+ - [Dolly 15k (de)](https://huggingface.co/datasets/mayflowergmbh/dolly-15k_de)
272
+ - [Alpaca GPT4 (de)](https://huggingface.co/datasets/mayflowergmbh/alpaca-gpt4_de)
273
+ - [OpenSchnabeltier (de)](https://huggingface.co/datasets/mayflowergmbh/openschnabeltier_de)
274
+ - [Evol Instruct (de)](https://huggingface.co/datasets/mayflowergmbh/evol-instruct_de)
275
+ - [Dolphin (de)](https://huggingface.co/datasets/mayflowergmbh/dolphin_de)
276
+ - [Booksum (de)](https://huggingface.co/datasets/mayflowergmbh/booksum_de)
277
+ - [Airoboros (de)](https://huggingface.co/datasets/mayflowergmbh/airoboros-3.0_de)
278
+ - [Ultrachat (de)](https://huggingface.co/datasets/mayflowergmbh/ultra-chat_de)
279
+
280
+ </details>
281
+
282
+ <details><summary>Preference datasets</summary>
283
+
284
+ - [DPO mixed (en&zh)](https://huggingface.co/datasets/hiyouga/DPO-En-Zh-20k)
285
+ - [UltraFeedback (en)](https://huggingface.co/datasets/HuggingFaceH4/ultrafeedback_binarized)
286
+ - [Orca DPO Pairs (en)](https://huggingface.co/datasets/Intel/orca_dpo_pairs)
287
+ - [HH-RLHF (en)](https://huggingface.co/datasets/Anthropic/hh-rlhf)
288
+ - [Nectar (en)](https://huggingface.co/datasets/berkeley-nest/Nectar)
289
+ - [Orca DPO (de)](https://huggingface.co/datasets/mayflowergmbh/intel_orca_dpo_pairs_de)
290
+ - [KTO mixed (en)](https://huggingface.co/datasets/argilla/kto-mix-15k)
291
+
292
+ </details>
293
+
294
+ Some datasets require confirmation before using them, so we recommend logging in with your Hugging Face account using these commands.
295
+
296
+ ```bash
297
+ pip install --upgrade huggingface_hub
298
+ huggingface-cli login
299
+ ```
300
+
301
+ ## Requirement
302
+
303
+ | Mandatory | Minimum | Recommend |
304
+ | ------------ | ------- | --------- |
305
+ | python | 3.8 | 3.11 |
306
+ | torch | 1.13.1 | 2.3.0 |
307
+ | transformers | 4.41.2 | 4.41.2 |
308
+ | datasets | 2.16.0 | 2.19.2 |
309
+ | accelerate | 0.30.1 | 0.30.1 |
310
+ | peft | 0.11.1 | 0.11.1 |
311
+ | trl | 0.8.6 | 0.9.4 |
312
+
313
+ | Optional | Minimum | Recommend |
314
+ | ------------ | ------- | --------- |
315
+ | CUDA | 11.6 | 12.2 |
316
+ | deepspeed | 0.10.0 | 0.14.0 |
317
+ | bitsandbytes | 0.39.0 | 0.43.1 |
318
+ | vllm | 0.4.3 | 0.4.3 |
319
+ | flash-attn | 2.3.0 | 2.5.9 |
320
+
321
+ ### Hardware Requirement
322
+
323
+ \* *estimated*
324
+
325
+ | Method | Bits | 7B | 13B | 30B | 70B | 110B | 8x7B | 8x22B |
326
+ | ----------------- | ---- | ----- | ----- | ----- | ------ | ------ | ----- | ------ |
327
+ | Full | AMP | 120GB | 240GB | 600GB | 1200GB | 2000GB | 900GB | 2400GB |
328
+ | Full | 16 | 60GB | 120GB | 300GB | 600GB | 900GB | 400GB | 1200GB |
329
+ | Freeze | 16 | 20GB | 40GB | 80GB | 200GB | 360GB | 160GB | 400GB |
330
+ | LoRA/GaLore/BAdam | 16 | 16GB | 32GB | 64GB | 160GB | 240GB | 120GB | 320GB |
331
+ | QLoRA | 8 | 10GB | 20GB | 40GB | 80GB | 140GB | 60GB | 160GB |
332
+ | QLoRA | 4 | 6GB | 12GB | 24GB | 48GB | 72GB | 30GB | 96GB |
333
+ | QLoRA | 2 | 4GB | 8GB | 16GB | 24GB | 48GB | 18GB | 48GB |
334
+
335
+ ## Getting Started
336
+
337
+ ### Installation
338
+
339
+ > [!IMPORTANT]
340
+ > Installation is mandatory.
341
+
342
+ ```bash
343
+ git clone --depth 1 https://github.com/hiyouga/LLaMA-Factory.git
344
+ cd LLaMA-Factory
345
+ pip install -e ".[torch,metrics]"
346
+ ```
347
+
348
+ Extra dependencies available: torch, torch_npu, metrics, deepspeed, bitsandbytes, vllm, galore, badam, gptq, awq, aqlm, qwen, modelscope, quality
349
+
350
+ > [!TIP]
351
+ > Use `pip install --no-deps -e .` to resolve package conflicts.
352
+
353
+ <details><summary>For Windows users</summary>
354
+
355
+ If you want to enable the quantized LoRA (QLoRA) on the Windows platform, you need to install a pre-built version of `bitsandbytes` library, which supports CUDA 11.1 to 12.2, please select the appropriate [release version](https://github.com/jllllll/bitsandbytes-windows-webui/releases/tag/wheels) based on your CUDA version.
356
+
357
+ ```bash
358
+ pip install https://github.com/jllllll/bitsandbytes-windows-webui/releases/download/wheels/bitsandbytes-0.41.2.post2-py3-none-win_amd64.whl
359
+ ```
360
+
361
+ To enable FlashAttention-2 on the Windows platform, you need to install the precompiled `flash-attn` library, which supports CUDA 12.1 to 12.2. Please download the corresponding version from [flash-attention](https://github.com/bdashore3/flash-attention/releases) based on your requirements.
362
+
363
+ </details>
364
+
365
+ <details><summary>For Ascend NPU users</summary>
366
+
367
+ Join [NPU user group](assets/wechat_npu.jpg).
368
+
369
+ To install LLaMA Factory on Ascend NPU devices, please specify extra dependencies: `pip install -e '.[torch-npu,metrics]'`. Additionally, you need to install the **[Ascend CANN Toolkit and Kernels](https://www.hiascend.com/developer/download/community/result?module=cann)**. Please follow the [installation tutorial](https://www.hiascend.com/document/detail/en/CANNCommunityEdition/600alphaX/softwareinstall/instg/atlasdeploy_03_0031.html) or use the following commands:
370
+
371
+ ```bash
372
+ # replace the url according to your CANN version and devices
373
+ # install CANN Toolkit
374
+ wget https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Milan-ASL/Milan-ASL%20V100R001C17SPC701/Ascend-cann-toolkit_8.0.RC1.alpha001_linux-"$(uname -i)".run
375
+ bash Ascend-cann-toolkit_8.0.RC1.alpha001_linux-"$(uname -i)".run --install
376
+
377
+ # install CANN Kernels
378
+ wget https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Milan-ASL/Milan-ASL%20V100R001C17SPC701/Ascend-cann-kernels-910b_8.0.RC1.alpha001_linux.run
379
+ bash Ascend-cann-kernels-910b_8.0.RC1.alpha001_linux.run --install
380
+
381
+ # set env variables
382
+ source /usr/local/Ascend/ascend-toolkit/set_env.sh
383
+ ```
384
+
385
+ | Requirement | Minimum | Recommend |
386
+ | ------------ | ------- | ----------- |
387
+ | CANN | 8.0.RC1 | 8.0.RC1 |
388
+ | torch | 2.1.0 | 2.1.0 |
389
+ | torch-npu | 2.1.0 | 2.1.0.post3 |
390
+ | deepspeed | 0.13.2 | 0.13.2 |
391
+
392
+ Docker image:
393
+
394
+ - 32GB: [Download page](http://mirrors.cn-central-221.ovaijisuan.com/detail/130.html)
395
+ - 64GB: [Download page](http://mirrors.cn-central-221.ovaijisuan.com/detail/131.html)
396
+
397
+ Remember to use `ASCEND_RT_VISIBLE_DEVICES` instead of `CUDA_VISIBLE_DEVICES` to specify the device to use.
398
+
399
+ If you cannot infer model on NPU devices, try setting `do_sample: false` in the configurations.
400
+
401
+ </details>
402
+
403
+ ### Data Preparation
404
+
405
+ Please refer to [data/README.md](data/README.md) for checking the details about the format of dataset files. You can either use datasets on HuggingFace / ModelScope hub or load the dataset in local disk.
406
+
407
+ > [!NOTE]
408
+ > Please update `data/dataset_info.json` to use your custom dataset.
409
+
410
+ ### Quickstart
411
+
412
+ Use the following 3 commands to run LoRA **fine-tuning**, **inference** and **merging** of the Llama3-8B-Instruct model, respectively.
413
+
414
+ ```bash
415
+ llamafactory-cli train examples/train_lora/llama3_lora_sft.yaml
416
+ llamafactory-cli chat examples/inference/llama3_lora_sft.yaml
417
+ llamafactory-cli export examples/merge_lora/llama3_lora_sft.yaml
418
+ ```
419
+
420
+ See [examples/README.md](examples/README.md) for advanced usage (including distributed training).
421
+
422
+ > [!TIP]
423
+ > Use `llamafactory-cli help` to show help information.
424
+
425
+ ### Fine-Tuning with LLaMA Board GUI (powered by [Gradio](https://github.com/gradio-app/gradio))
426
+
427
+ ```bash
428
+ llamafactory-cli webui
429
+ ```
430
+
431
+ ### Build Docker
432
+
433
+ #### Use Docker
434
+
435
+ ```bash
436
+ docker build -f ./Dockerfile \
437
+ --build-arg INSTALL_BNB=false \
438
+ --build-arg INSTALL_VLLM=false \
439
+ --build-arg INSTALL_DEEPSPEED=false \
440
+ --build-arg PIP_INDEX=https://pypi.org/simple \
441
+ -t llamafactory:latest .
442
+
443
+ docker run -it --gpus=all \
444
+ -v ./hf_cache:/root/.cache/huggingface/ \
445
+ -v ./data:/app/data \
446
+ -v ./output:/app/output \
447
+ -p 7860:7860 \
448
+ -p 8000:8000 \
449
+ --shm-size 16G \
450
+ --name llamafactory \
451
+ llamafactory:latest
452
+ ```
453
+
454
+ #### Use Docker Compose
455
+
456
+ ```bash
457
+ docker-compose up -d
458
+ docker-compose exec llamafactory bash
459
+ ```
460
+
461
+ <details><summary>Details about volume</summary>
462
+
463
+ - hf_cache: Utilize Hugging Face cache on the host machine. Reassignable if a cache already exists in a different directory.
464
+ - data: Place datasets on this dir of the host machine so that they can be selected on LLaMA Board GUI.
465
+ - output: Set export dir to this location so that the merged result can be accessed directly on the host machine.
466
+
467
+ </details>
468
+
469
+ ### Deploy with OpenAI-style API and vLLM
470
+
471
+ ```bash
472
+ API_PORT=8000 llamafactory-cli api examples/inference/llama3_vllm.yaml
473
+ ```
474
+
475
+ > [!TIP]
476
+ > Visit https://platform.openai.com/docs/api-reference/chat/create for API document.
477
+
478
+ ### Download from ModelScope Hub
479
+
480
+ If you have trouble with downloading models and datasets from Hugging Face, you can use ModelScope.
481
+
482
+ ```bash
483
+ export USE_MODELSCOPE_HUB=1 # `set USE_MODELSCOPE_HUB=1` for Windows
484
+ ```
485
+
486
+ Train the model by specifying a model ID of the ModelScope Hub as the `model_name_or_path`. You can find a full list of model IDs at [ModelScope Hub](https://modelscope.cn/models), e.g., `LLM-Research/Meta-Llama-3-8B-Instruct`.
487
+
488
+ ### Use W&B Logger
489
+
490
+ To use [Weights & Biases](https://wandb.ai) for logging experimental results, you need to add the following arguments to yaml files.
491
+
492
+ ```yaml
493
+ report_to: wandb
494
+ run_name: test_run # optional
495
+ ```
496
+
497
+ Set `WANDB_API_KEY` to [your key](https://wandb.ai/authorize) when launching training tasks to log in with your W&B account.
498
+
499
+ ## Projects using LLaMA Factory
500
+
501
+ If you have a project that should be incorporated, please contact via email or create a pull request.
502
+
503
+ <details><summary>Click to show</summary>
504
+
505
+ 1. Wang et al. ESRL: Efficient Sampling-based Reinforcement Learning for Sequence Generation. 2023. [[arxiv]](https://arxiv.org/abs/2308.02223)
506
+ 1. Yu et al. Open, Closed, or Small Language Models for Text Classification? 2023. [[arxiv]](https://arxiv.org/abs/2308.10092)
507
+ 1. Wang et al. UbiPhysio: Support Daily Functioning, Fitness, and Rehabilitation with Action Understanding and Feedback in Natural Language. 2023. [[arxiv]](https://arxiv.org/abs/2308.10526)
508
+ 1. Luceri et al. Leveraging Large Language Models to Detect Influence Campaigns in Social Media. 2023. [[arxiv]](https://arxiv.org/abs/2311.07816)
509
+ 1. Zhang et al. Alleviating Hallucinations of Large Language Models through Induced Hallucinations. 2023. [[arxiv]](https://arxiv.org/abs/2312.15710)
510
+ 1. Wang et al. Know Your Needs Better: Towards Structured Understanding of Marketer Demands with Analogical Reasoning Augmented LLMs. 2024. [[arxiv]](https://arxiv.org/abs/2401.04319)
511
+ 1. Wang et al. CANDLE: Iterative Conceptualization and Instantiation Distillation from Large Language Models for Commonsense Reasoning. 2024. [[arxiv]](https://arxiv.org/abs/2401.07286)
512
+ 1. Choi et al. FACT-GPT: Fact-Checking Augmentation via Claim Matching with LLMs. 2024. [[arxiv]](https://arxiv.org/abs/2402.05904)
513
+ 1. Zhang et al. AutoMathText: Autonomous Data Selection with Language Models for Mathematical Texts. 2024. [[arxiv]](https://arxiv.org/abs/2402.07625)
514
+ 1. Lyu et al. KnowTuning: Knowledge-aware Fine-tuning for Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2402.11176)
515
+ 1. Yang et al. LaCo: Large Language Model Pruning via Layer Collaps. 2024. [[arxiv]](https://arxiv.org/abs/2402.11187)
516
+ 1. Bhardwaj et al. Language Models are Homer Simpson! Safety Re-Alignment of Fine-tuned Language Models through Task Arithmetic. 2024. [[arxiv]](https://arxiv.org/abs/2402.11746)
517
+ 1. Yang et al. Enhancing Empathetic Response Generation by Augmenting LLMs with Small-scale Empathetic Models. 2024. [[arxiv]](https://arxiv.org/abs/2402.11801)
518
+ 1. Yi et al. Generation Meets Verification: Accelerating Large Language Model Inference with Smart Parallel Auto-Correct Decoding. 2024. [[arxiv]](https://arxiv.org/abs/2402.11809)
519
+ 1. Cao et al. Head-wise Shareable Attention for Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2402.11819)
520
+ 1. Zhang et al. Enhancing Multilingual Capabilities of Large Language Models through Self-Distillation from Resource-Rich Languages. 2024. [[arxiv]](https://arxiv.org/abs/2402.12204)
521
+ 1. Kim et al. Efficient and Effective Vocabulary Expansion Towards Multilingual Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2402.14714)
522
+ 1. Yu et al. KIEval: A Knowledge-grounded Interactive Evaluation Framework for Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2402.15043)
523
+ 1. Huang et al. Key-Point-Driven Data Synthesis with its Enhancement on Mathematical Reasoning. 2024. [[arxiv]](https://arxiv.org/abs/2403.02333)
524
+ 1. Duan et al. Negating Negatives: Alignment without Human Positive Samples via Distributional Dispreference Optimization. 2024. [[arxiv]](https://arxiv.org/abs/2403.03419)
525
+ 1. Xie and Schwertfeger. Empowering Robotics with Large Language Models: osmAG Map Comprehension with LLMs. 2024. [[arxiv]](https://arxiv.org/abs/2403.08228)
526
+ 1. Wu et al. Large Language Models are Parallel Multilingual Learners. 2024. [[arxiv]](https://arxiv.org/abs/2403.09073)
527
+ 1. Zhang et al. EDT: Improving Large Language Models' Generation by Entropy-based Dynamic Temperature Sampling. 2024. [[arxiv]](https://arxiv.org/abs/2403.14541)
528
+ 1. Weller et al. FollowIR: Evaluating and Teaching Information Retrieval Models to Follow Instructions. 2024. [[arxiv]](https://arxiv.org/abs/2403.15246)
529
+ 1. Hongbin Na. CBT-LLM: A Chinese Large Language Model for Cognitive Behavioral Therapy-based Mental Health Question Answering. 2024. [[arxiv]](https://arxiv.org/abs/2403.16008)
530
+ 1. Zan et al. CodeS: Natural Language to Code Repository via Multi-Layer Sketch. 2024. [[arxiv]](https://arxiv.org/abs/2403.16443)
531
+ 1. Liu et al. Extensive Self-Contrast Enables Feedback-Free Language Model Alignment. 2024. [[arxiv]](https://arxiv.org/abs/2404.00604)
532
+ 1. Luo et al. BAdam: A Memory Efficient Full Parameter Training Method for Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2404.02827)
533
+ 1. Du et al. Chinese Tiny LLM: Pretraining a Chinese-Centric Large Language Model. 2024. [[arxiv]](https://arxiv.org/abs/2404.04167)
534
+ 1. Ma et al. Parameter Efficient Quasi-Orthogonal Fine-Tuning via Givens Rotation. 2024. [[arxiv]](https://arxiv.org/abs/2404.04316)
535
+ 1. Liu et al. Dynamic Generation of Personalities with Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2404.07084)
536
+ 1. Shang et al. How Far Have We Gone in Stripped Binary Code Understanding Using Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2404.09836)
537
+ 1. Huang et al. LLMTune: Accelerate Database Knob Tuning with Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2404.11581)
538
+ 1. Deng et al. Text-Tuple-Table: Towards Information Integration in Text-to-Table Generation via Global Tuple Extraction. 2024. [[arxiv]](https://arxiv.org/abs/2404.14215)
539
+ 1. Acikgoz et al. Hippocrates: An Open-Source Framework for Advancing Large Language Models in Healthcare. 2024. [[arxiv]](https://arxiv.org/abs/2404.16621)
540
+ 1. Zhang et al. Small Language Models Need Strong Verifiers to Self-Correct Reasoning. 2024. [[arxiv]](https://arxiv.org/abs/2404.17140)
541
+ 1. Zhou et al. FREB-TQA: A Fine-Grained Robustness Evaluation Benchmark for Table Question Answering. 2024. [[arxiv]](https://arxiv.org/abs/2404.18585)
542
+ 1. **[StarWhisper](https://github.com/Yu-Yang-Li/StarWhisper)**: A large language model for Astronomy, based on ChatGLM2-6B and Qwen-14B.
543
+ 1. **[DISC-LawLLM](https://github.com/FudanDISC/DISC-LawLLM)**: A large language model specialized in Chinese legal domain, based on Baichuan-13B, is capable of retrieving and reasoning on legal knowledge.
544
+ 1. **[Sunsimiao](https://github.com/X-D-Lab/Sunsimiao)**: A large language model specialized in Chinese medical domain, based on Baichuan-7B and ChatGLM-6B.
545
+ 1. **[CareGPT](https://github.com/WangRongsheng/CareGPT)**: A series of large language models for Chinese medical domain, based on LLaMA2-7B and Baichuan-13B.
546
+ 1. **[MachineMindset](https://github.com/PKU-YuanGroup/Machine-Mindset/)**: A series of MBTI Personality large language models, capable of giving any LLM 16 different personality types based on different datasets and training methods.
547
+ 1. **[Luminia-13B-v3](https://huggingface.co/Nekochu/Luminia-13B-v3)**: A large language model specialized in generate metadata for stable diffusion. [[🤗Demo]](https://huggingface.co/spaces/Nekochu/Luminia-13B_SD_Prompt)
548
+ 1. **[Chinese-LLaVA-Med](https://github.com/BUAADreamer/Chinese-LLaVA-Med)**: A multimodal large language model specialized in Chinese medical domain, based on LLaVA-1.5-7B.
549
+
550
+ </details>
551
+
552
+ ## License
553
+
554
+ This repository is licensed under the [Apache-2.0 License](LICENSE).
555
+
556
+ Please follow the model licenses to use the corresponding model weights: [Baichuan2](https://huggingface.co/baichuan-inc/Baichuan2-7B-Base/blob/main/Community%20License%20for%20Baichuan%202%20Model.pdf) / [BLOOM](https://huggingface.co/spaces/bigscience/license) / [ChatGLM3](https://github.com/THUDM/ChatGLM3/blob/main/MODEL_LICENSE) / [Command-R](https://cohere.com/c4ai-cc-by-nc-license) / [DeepSeek](https://github.com/deepseek-ai/DeepSeek-LLM/blob/main/LICENSE-MODEL) / [Falcon](https://huggingface.co/tiiuae/falcon-180B/blob/main/LICENSE.txt) / [Gemma](https://ai.google.dev/gemma/terms) / [GLM4](https://huggingface.co/THUDM/glm-4-9b/blob/main/LICENSE) / [InternLM2](https://github.com/InternLM/InternLM#license) / [LLaMA](https://github.com/facebookresearch/llama/blob/main/MODEL_CARD.md) / [LLaMA-2 (LLaVA-1.5)](https://ai.meta.com/llama/license/) / [LLaMA-3](https://llama.meta.com/llama3/license/) / [Mistral](LICENSE) / [OLMo](LICENSE) / [Phi-1.5/2](https://huggingface.co/microsoft/phi-1_5/resolve/main/Research%20License.docx) / [Phi-3](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct/blob/main/LICENSE) / [Qwen](https://github.com/QwenLM/Qwen/blob/main/Tongyi%20Qianwen%20LICENSE%20AGREEMENT) / [StarCoder2](https://huggingface.co/spaces/bigcode/bigcode-model-license-agreement) / [XVERSE](https://github.com/xverse-ai/XVERSE-13B/blob/main/MODEL_LICENSE.pdf) / [Yi](https://huggingface.co/01-ai/Yi-6B/blob/main/LICENSE) / [Yi-1.5](LICENSE) / [Yuan](https://github.com/IEIT-Yuan/Yuan-2.0/blob/main/LICENSE-Yuan)
557
+
558
+ ## Citation
559
+
560
+ If this work is helpful, please kindly cite as:
561
+
562
+ ```bibtex
563
+ @article{zheng2024llamafactory,
564
+ title={LlamaFactory: Unified Efficient Fine-Tuning of 100+ Language Models},
565
+ author={Yaowei Zheng and Richong Zhang and Junhao Zhang and Yanhan Ye and Zheyan Luo and Yongqiang Ma},
566
+ journal={arXiv preprint arXiv:2403.13372},
567
+ year={2024},
568
+ url={http://arxiv.org/abs/2403.13372}
569
+ }
570
+ ```
571
+
572
+ ## Acknowledgement
573
+
574
+ This repo benefits from [PEFT](https://github.com/huggingface/peft), [TRL](https://github.com/huggingface/trl), [QLoRA](https://github.com/artidoro/qlora) and [FastChat](https://github.com/lm-sys/FastChat). Thanks for their wonderful works.
575
+
576
+ ## Star History
577
 
578
+ ![Star History Chart](https://api.star-history.com/svg?repos=hiyouga/LLaMA-Factory&type=Date)
README_zh.md ADDED
@@ -0,0 +1,572 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ![# LLaMA Factory](assets/logo.png)
2
+
3
+ [![GitHub Repo stars](https://img.shields.io/github/stars/hiyouga/LLaMA-Factory?style=social)](https://github.com/hiyouga/LLaMA-Factory/stargazers)
4
+ [![GitHub Code License](https://img.shields.io/github/license/hiyouga/LLaMA-Factory)](LICENSE)
5
+ [![GitHub last commit](https://img.shields.io/github/last-commit/hiyouga/LLaMA-Factory)](https://github.com/hiyouga/LLaMA-Factory/commits/main)
6
+ [![PyPI](https://img.shields.io/pypi/v/llamafactory)](https://pypi.org/project/llamafactory/)
7
+ [![Citation](https://img.shields.io/badge/citation-44-green)](#使用了-llama-factory-的项目)
8
+ [![GitHub pull request](https://img.shields.io/badge/PRs-welcome-blue)](https://github.com/hiyouga/LLaMA-Factory/pulls)
9
+ [![Discord](https://dcbadge.vercel.app/api/server/rKfvV9r9FK?compact=true&style=flat)](https://discord.gg/rKfvV9r9FK)
10
+ [![Twitter](https://img.shields.io/twitter/follow/llamafactory_ai)](https://twitter.com/llamafactory_ai)
11
+ [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1d5KQtbemerlSDSxZIfAaWXhKr30QypiK?usp=sharing)
12
+ [![Open in DSW](https://gallery.pai-ml.com/assets/open-in-dsw.svg)](https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory)
13
+ [![Spaces](https://img.shields.io/badge/🤗-Open%20in%20Spaces-blue)](https://huggingface.co/spaces/hiyouga/LLaMA-Board)
14
+ [![Studios](https://img.shields.io/badge/ModelScope-Open%20in%20Studios-blue)](https://modelscope.cn/studios/hiyouga/LLaMA-Board)
15
+
16
+ [![GitHub Tread](https://trendshift.io/api/badge/repositories/4535)](https://trendshift.io/repositories/4535)
17
+
18
+ 👋 加入我们的[微信群](assets/wechat.jpg)。
19
+
20
+ \[ [English](README.md) | 中文 \]
21
+
22
+ **微调大模型可以像这样轻松…**
23
+
24
+ https://github.com/hiyouga/LLaMA-Factory/assets/16256802/ec36a9dd-37f4-4f72-81bd-d76c6d0a6594
25
+
26
+ 选择你的打开方式:
27
+
28
+ - **Colab**:https://colab.research.google.com/drive/1d5KQtbemerlSDSxZIfAaWXhKr30QypiK?usp=sharing
29
+ - **PAI-DSW**: https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory
30
+ - **本地机器**:请见[如何使用](#如何使用)
31
+
32
+ ## 目录
33
+
34
+ - [项目特色](#项目特色)
35
+ - [性能指标](#性能指标)
36
+ - [更新日志](#更新日志)
37
+ - [模型](#模型)
38
+ - [训练方法](#训练方法)
39
+ - [数据集](#数据集)
40
+ - [软硬件依赖](#软硬件依赖)
41
+ - [如何使用](#如何使用)
42
+ - [使用了 LLaMA Factory 的项目](#使用了-llama-factory-的项目)
43
+ - [协议](#协议)
44
+ - [引用](#引用)
45
+ - [致谢](#致谢)
46
+
47
+ ## 项目特色
48
+
49
+ - **多种模型**:LLaMA、LLaVA、Mistral、Mixtral-MoE、Qwen、Yi、Gemma、Baichuan、ChatGLM、Phi 等等。
50
+ - **集成方法**:(增量)预训练、(多模态)指令监督微调、奖励模型训练、PPO 训练、DPO 训练、KTO 训练、ORPO 训练等等。
51
+ - **多种精度**:32 比特全参数微调、16 比特冻结微调、16 比特 LoRA 微调和基于 AQLM/AWQ/GPTQ/LLM.int8 的 2/4/8 比特 QLoRA 微调。
52
+ - **先进算法**:GaLore、BAdam、DoRA、LongLoRA、LLaMA Pro、Mixture-of-Depths、LoRA+、LoftQ、PiSSA 和 Agent 微调。
53
+ - **实用技巧**:FlashAttention-2、Unsloth、RoPE scaling、NEFTune 和 rsLoRA。
54
+ - **实验监控**:LlamaBoard、TensorBoard、Wandb、MLflow 等等。
55
+ - **极速推理**:基于 vLLM 的 OpenAI 风格 API、浏览器界面和命令行接口。
56
+
57
+ ## 性能指标
58
+
59
+ 与 ChatGLM 官方的 [P-Tuning](https://github.com/THUDM/ChatGLM2-6B/tree/main/ptuning) 微调相比,LLaMA Factory 的 LoRA 微调提供了 **3.7 倍**的加速比,同时在广告文案生成任务上取得了更高的 Rouge 分数。结合 4 比特量化技术,LLaMA Factory 的 QLoRA 微调进一步降低了 GPU 显存消耗。
60
+
61
+ ![benchmark](assets/benchmark.svg)
62
+
63
+ <details><summary>变量定义</summary>
64
+
65
+ - **Training Speed**: 训练阶段每秒处理的样本数量。(批处理大小=4,截断长度=1024)
66
+ - **Rouge Score**: [广告文案生成](https://aclanthology.org/D19-1321.pdf)任务验证集上的 Rouge-2 分数。(批处理大小=4,截断长度=1024)
67
+ - **GPU Memory**: 4 比特量化训练的 GPU 显存峰值。(批处理大小=1,截断长度=1024)
68
+ - 我们在 ChatGLM 的 P-Tuning 中采用 `pre_seq_len=128`,在 LLaMA Factory 的 LoRA 微调中采用 `lora_rank=32`。
69
+
70
+ </details>
71
+
72
+ ## 更新日志
73
+
74
+ [24/06/16] 我们支持了 **[PiSSA](https://arxiv.org/abs/2404.02948)** 算法。详细用法请参照 [examples](examples/README_zh.md)。
75
+
76
+ [24/06/07] 我们支持了 **[Qwen2](https://qwenlm.github.io/blog/qwen2/)** 和 **[GLM-4](https://github.com/THUDM/GLM-4)** 模型的微调。
77
+
78
+ [24/05/26] 我们支持了 **[SimPO](https://arxiv.org/abs/2405.14734)** 偏好对齐算法。详细用法请参照 [examples](examples/README_zh.md)。
79
+
80
+ <details><summary>展开日志</summary>
81
+
82
+ [24/05/20] 我们支持了 **PaliGemma** 系列模型的微调。注意 PaliGemma 是预训练模型,你需要使用 `gemma` 模板进行微调使其获得对话能力。
83
+
84
+ [24/05/18] 我们支持了 **[KTO](https://arxiv.org/abs/2402.01306)** 偏好对齐算法。详细用法请参照 [examples](examples/README_zh.md)。
85
+
86
+ [24/05/14] 我们支持了昇腾 NPU 设备的训练和推理。详情请查阅[安装](#安装-llama-factory)部分。
87
+
88
+ [24/04/26] 我们支持了多模态模型 **LLaVA-1.5** 的微调。详细用法请参照 [examples](examples/README_zh.md)。
89
+
90
+ [24/04/22] 我们提供了在免费 T4 GPU 上微调 Llama-3 模型的 **[Colab 笔记本](https://colab.research.google.com/drive/1d5KQtbemerlSDSxZIfAaWXhKr30QypiK?usp=sharing)**。Hugging Face 社区公开了两个利用 LLaMA Factory 微调的 Llama-3 模型,详情请见 [Llama3-8B-Chinese-Chat](https://huggingface.co/shenzhi-wang/Llama3-8B-Chinese-Chat) 和 [Llama3-Chinese](https://huggingface.co/zhichen/Llama3-Chinese)。
91
+
92
+ [24/04/21] 我们基于 [AstraMindAI 的仓库](https://github.com/astramind-ai/Mixture-of-depths)支持了 **[混合深度训练](https://arxiv.org/abs/2404.02258)**。详细用法请参照 [examples](examples/README_zh.md)。
93
+
94
+ [24/04/16] 我们支持了 **[BAdam](https://arxiv.org/abs/2404.02827)**。详细用法请参照 [examples](examples/README_zh.md)。
95
+
96
+ [24/04/16] 我们支持了 **[unsloth](https://github.com/unslothai/unsloth)** 的长序列训练(24GB 可训练 Llama-2-7B-56k)。该方法相比 FlashAttention-2 提供了 **117%** 的训练速度和 **50%** 的显存节约。更多数据请见[此页面](https://github.com/hiyouga/LLaMA-Factory/wiki/Performance-comparison)。
97
+
98
+ [24/03/31] 我们支持了 **[ORPO](https://arxiv.org/abs/2403.07691)**。详细用法请参照 [examples](examples/README_zh.md)。
99
+
100
+ [24/03/21] 我们的论文 "[LlamaFactory: Unified Efficient Fine-Tuning of 100+ Language Models](https://arxiv.org/abs/2403.13372)" 可在 arXiv 上查看!
101
+
102
+ [24/03/20] 我们支持了能在 2x24GB GPU 上微调 70B 模型的 **FSDP+QLoRA**。详细用法请参照 [examples](examples/README_zh.md)。
103
+
104
+ [24/03/13] 我们支持了 **[LoRA+](https://arxiv.org/abs/2402.12354)**。详细用法请参照 [examples](examples/README_zh.md)。
105
+
106
+ [24/03/07] 我们支持了梯度低秩投影(**[GaLore](https://arxiv.org/abs/2403.03507)**)算法。详细用法请参照 [examples](examples/README_zh.md)。
107
+
108
+ [24/03/07] 我们集成了 **[vLLM](https://github.com/vllm-project/vllm)** 以实现极速并发推理。请使用 `infer_backend: vllm` 来获得 **270%** 的推理速度。
109
+
110
+ [24/02/28] 我们支持了 **[DoRA](https://arxiv.org/abs/2402.09353)** 微调。请使用 `use_dora: true` 参数进行 DoRA 微调。
111
+
112
+ [24/02/15] 我们支持了 [LLaMA Pro](https://github.com/TencentARC/LLaMA-Pro) 提出的**块扩展**方法。详细用法请参照 [examples](examples/README_zh.md)。
113
+
114
+ [24/02/05] Qwen1.5(Qwen2 测试版)系列模型已在 LLaMA-Factory 中实现微调支持。详情请查阅该[博客页面](https://qwenlm.github.io/zh/blog/qwen1.5/)。
115
+
116
+ [24/01/18] 我们针对绝大多数模型实现了 **Agent 微调**,微调时指定 `dataset: glaive_toolcall_zh` 即可使模型获得工具调用能力。
117
+
118
+ [23/12/23] 我们针对 LLaMA, Mistral 和 Yi 模型支持了 **[unsloth](https://github.com/unslothai/unsloth)** 的 LoRA 训练加速。请使用 `use_unsloth: true` 参数启用 unsloth 优化。该方法可提供 **170%** 的训练速度,详情请查阅[此页面](https://github.com/hiyouga/LLaMA-Factory/wiki/Performance-comparison)。
119
+
120
+ [23/12/12] 我们支持了微调最新的混合专家模型 **[Mixtral 8x7B](https://huggingface.co/mistralai/Mixtral-8x7B-v0.1)**。硬件需求请查阅[此处](#硬件依赖)。
121
+
122
+ [23/12/01] 我们支持了从 **[魔搭社区](https://modelscope.cn/models)** 下载预训练模型和数据集。详细用法请参照 [此教程](#从魔搭社区下载)。
123
+
124
+ [23/10/21] 我们支持了 **[NEFTune](https://arxiv.org/abs/2310.05914)** 训练技巧。请使用 `neftune_noise_alpha: 5` 参数启用 NEFTune。
125
+
126
+ [23/09/27] 我们针对 LLaMA 模型支持了 [LongLoRA](https://github.com/dvlab-research/LongLoRA) 提出的 **$S^2$-Attn**。请使用 `shift_attn: true` 参数以启用该功能。
127
+
128
+ [23/09/23] 我们在项目中集成了 MMLU、C-Eval 和 CMMLU 评估集。详细用法请参照 [examples](examples/README_zh.md)。
129
+
130
+ [23/09/10] 我们支持了 **[FlashAttention-2](https://github.com/Dao-AILab/flash-attention)**。如果您使用的是 RTX4090、A100 或 H100 GPU,请使用 `flash_attn: fa2` 参数以启用 FlashAttention-2。
131
+
132
+ [23/08/12] 我们支持了 **RoPE 插值**来扩展 LLaMA 模型的上下文长度。请使用 `rope_scaling: linear` 参数训练模型或使用 `rope_scaling: dynamic` 参数评估模型。
133
+
134
+ [23/08/11] 我们支持了指令模型的 **[DPO 训练](https://arxiv.org/abs/2305.18290)**。详细用法请参照 [examples](examples/README_zh.md)。
135
+
136
+ [23/07/31] 我们支持了**数据流式加载**。请使用 `streaming: true` 和 `max_steps: 10000` 参数来流式加载数据集。
137
+
138
+ [23/07/29] 我们在 Hugging Face 发布了两个 13B 指令微调模型。详细内容请查阅我们的 Hugging Face 项目([LLaMA-2](https://huggingface.co/hiyouga/Llama-2-Chinese-13b-chat) / [Baichuan](https://huggingface.co/hiyouga/Baichuan-13B-sft))。
139
+
140
+ [23/07/18] 我们开发了支持训练和测试的**浏览器一体化界面**。请使用 `train_web.py` 在您的浏览器中微调模型。感谢 [@KanadeSiina](https://github.com/KanadeSiina) 和 [@codemayq](https://github.com/codemayq) 在该功能开发中付出的努力。
141
+
142
+ [23/07/09] 我们开源了 **[FastEdit](https://github.com/hiyouga/FastEdit)** ⚡🩹,一个简单易用的、能迅速编辑大模型事实记忆的工具包。如果您感兴趣请关注我们的 [FastEdit](https://github.com/hiyouga/FastEdit) 项目。
143
+
144
+ [23/06/29] 我们提供了一个**可复现的**指令模型微调示例,详细内容请查阅 [Baichuan-7B-sft](https://huggingface.co/hiyouga/Baichuan-7B-sft)。
145
+
146
+ [23/06/22] 我们对齐了[示例 API](src/api_demo.py) 与 [OpenAI API](https://platform.openai.com/docs/api-reference/chat) 的格式,您可以将微调模型接入**任意基于 ChatGPT 的应用**中。
147
+
148
+ [23/06/03] 我们实现了 4 比特的 LoRA 训练(也称 **[QLoRA](https://github.com/artidoro/qlora)**)。详细用法请参照 [examples](examples/README_zh.md)。
149
+
150
+ </details>
151
+
152
+ ## 模型
153
+
154
+ | 模型名 | 模型大小 | Template |
155
+ | -------------------------------------------------------- | -------------------------------- | --------- |
156
+ | [Baichuan2](https://huggingface.co/baichuan-inc) | 7B/13B | baichuan2 |
157
+ | [BLOOM](https://huggingface.co/bigscience) | 560M/1.1B/1.7B/3B/7.1B/176B | - |
158
+ | [BLOOMZ](https://huggingface.co/bigscience) | 560M/1.1B/1.7B/3B/7.1B/176B | - |
159
+ | [ChatGLM3](https://huggingface.co/THUDM) | 6B | chatglm3 |
160
+ | [Command-R](https://huggingface.co/CohereForAI) | 35B/104B | cohere |
161
+ | [DeepSeek (MoE)](https://huggingface.co/deepseek-ai) | 7B/16B/67B/236B | deepseek |
162
+ | [Falcon](https://huggingface.co/tiiuae) | 7B/11B/40B/180B | falcon |
163
+ | [Gemma/CodeGemma](https://huggingface.co/google) | 2B/7B | gemma |
164
+ | [GLM4](https://huggingface.co/THUDM) | 9B | glm4 |
165
+ | [InternLM2](https://huggingface.co/internlm) | 7B/20B | intern2 |
166
+ | [LLaMA](https://github.com/facebookresearch/llama) | 7B/13B/33B/65B | - |
167
+ | [LLaMA-2](https://huggingface.co/meta-llama) | 7B/13B/70B | llama2 |
168
+ | [LLaMA-3](https://huggingface.co/meta-llama) | 8B/70B | llama3 |
169
+ | [LLaVA-1.5](https://huggingface.co/llava-hf) | 7B/13B | vicuna |
170
+ | [Mistral/Mixtral](https://huggingface.co/mistralai) | 7B/8x7B/8x22B | mistral |
171
+ | [OLMo](https://huggingface.co/allenai) | 1B/7B | - |
172
+ | [PaliGemma](https://huggingface.co/google) | 3B | gemma |
173
+ | [Phi-1.5/2](https://huggingface.co/microsoft) | 1.3B/2.7B | - |
174
+ | [Phi-3](https://huggingface.co/microsoft) | 4B/7B/14B | phi |
175
+ | [Qwen](https://huggingface.co/Qwen) | 1.8B/7B/14B/72B | qwen |
176
+ | [Qwen1.5 (Code/MoE)](https://huggingface.co/Qwen) | 0.5B/1.8B/4B/7B/14B/32B/72B/110B | qwen |
177
+ | [Qwen2 (MoE)](https://huggingface.co/Qwen) | 0.5B/1.5B/7B/57B/72B | qwen |
178
+ | [StarCoder2](https://huggingface.co/bigcode) | 3B/7B/15B | - |
179
+ | [XVERSE](https://huggingface.co/xverse) | 7B/13B/65B | xverse |
180
+ | [Yi (1/1.5)](https://huggingface.co/01-ai) | 6B/9B/34B | yi |
181
+ | [Yi-VL](https://huggingface.co/01-ai) | 6B/34B | yi_vl |
182
+ | [Yuan](https://huggingface.co/IEITYuan) | 2B/51B/102B | yuan |
183
+
184
+ > [!NOTE]
185
+ > 对于所有“基座”(Base)模型,`template` 参数可以是 `default`, `alpaca`, `vicuna` 等任意值。但“对话”(Instruct/Chat)模型请务必使用**对应的模板**。
186
+ >
187
+ > 请务必在训练和推理时采用**完全一致**的模板。
188
+
189
+ 项目所支持模型的完整列表请参阅 [constants.py](src/llamafactory/extras/constants.py)。
190
+
191
+ 您也可以在 [template.py](src/llamafactory/data/template.py) 中添加自己的对话模板。
192
+
193
+ ## 训练方法
194
+
195
+ | 方法 | 全参数训练 | 部分参数训练 | LoRA | QLoRA |
196
+ | ---------------------- | ------------------ | ------------------ | ------------------ | ------------------ |
197
+ | 预训练 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
198
+ | 指令监督微调 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
199
+ | 奖励模型训练 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
200
+ | PPO 训练 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
201
+ | DPO 训练 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
202
+ | KTO 训练 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
203
+ | ORPO 训练 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
204
+ | SimPO 训练 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
205
+
206
+ ## 数据集
207
+
208
+ <details><summary>预训练数据集</summary>
209
+
210
+ - [Wiki Demo (en)](data/wiki_demo.txt)
211
+ - [RefinedWeb (en)](https://huggingface.co/datasets/tiiuae/falcon-refinedweb)
212
+ - [RedPajama V2 (en)](https://huggingface.co/datasets/togethercomputer/RedPajama-Data-V2)
213
+ - [Wikipedia (en)](https://huggingface.co/datasets/olm/olm-wikipedia-20221220)
214
+ - [Wikipedia (zh)](https://huggingface.co/datasets/pleisto/wikipedia-cn-20230720-filtered)
215
+ - [Pile (en)](https://huggingface.co/datasets/EleutherAI/pile)
216
+ - [SkyPile (zh)](https://huggingface.co/datasets/Skywork/SkyPile-150B)
217
+ - [FineWeb (en)](https://huggingface.co/datasets/HuggingFaceFW/fineweb)
218
+ - [FineWeb-Edu (en)](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu)
219
+ - [The Stack (en)](https://huggingface.co/datasets/bigcode/the-stack)
220
+ - [StarCoder (en)](https://huggingface.co/datasets/bigcode/starcoderdata)
221
+
222
+ </details>
223
+
224
+ <details><summary>指令微调数据集</summary>
225
+
226
+ - [Identity (en&zh)](data/identity.json)
227
+ - [Stanford Alpaca (en)](https://github.com/tatsu-lab/stanford_alpaca)
228
+ - [Stanford Alpaca (zh)](https://github.com/ymcui/Chinese-LLaMA-Alpaca-3)
229
+ - [Alpaca GPT4 (en&zh)](https://github.com/Instruction-Tuning-with-GPT-4/GPT-4-LLM)
230
+ - [Glaive Function Calling V2 (en&zh)](https://huggingface.co/datasets/glaiveai/glaive-function-calling-v2)
231
+ - [LIMA (en)](https://huggingface.co/datasets/GAIR/lima)
232
+ - [Guanaco Dataset (multilingual)](https://huggingface.co/datasets/JosephusCheung/GuanacoDataset)
233
+ - [BELLE 2M (zh)](https://huggingface.co/datasets/BelleGroup/train_2M_CN)
234
+ - [BELLE 1M (zh)](https://huggingface.co/datasets/BelleGroup/train_1M_CN)
235
+ - [BELLE 0.5M (zh)](https://huggingface.co/datasets/BelleGroup/train_0.5M_CN)
236
+ - [BELLE Dialogue 0.4M (zh)](https://huggingface.co/datasets/BelleGroup/generated_chat_0.4M)
237
+ - [BELLE School Math 0.25M (zh)](https://huggingface.co/datasets/BelleGroup/school_math_0.25M)
238
+ - [BELLE Multiturn Chat 0.8M (zh)](https://huggingface.co/datasets/BelleGroup/multiturn_chat_0.8M)
239
+ - [UltraChat (en)](https://github.com/thunlp/UltraChat)
240
+ - [OpenPlatypus (en)](https://huggingface.co/datasets/garage-bAInd/Open-Platypus)
241
+ - [CodeAlpaca 20k (en)](https://huggingface.co/datasets/sahil2801/CodeAlpaca-20k)
242
+ - [Alpaca CoT (multilingual)](https://huggingface.co/datasets/QingyiSi/Alpaca-CoT)
243
+ - [OpenOrca (en)](https://huggingface.co/datasets/Open-Orca/OpenOrca)
244
+ - [SlimOrca (en)](https://huggingface.co/datasets/Open-Orca/SlimOrca)
245
+ - [MathInstruct (en)](https://huggingface.co/datasets/TIGER-Lab/MathInstruct)
246
+ - [Firefly 1.1M (zh)](https://huggingface.co/datasets/YeungNLP/firefly-train-1.1M)
247
+ - [Wiki QA (en)](https://huggingface.co/datasets/wiki_qa)
248
+ - [Web QA (zh)](https://huggingface.co/datasets/suolyer/webqa)
249
+ - [WebNovel (zh)](https://huggingface.co/datasets/zxbsmk/webnovel_cn)
250
+ - [Nectar (en)](https://huggingface.co/datasets/berkeley-nest/Nectar)
251
+ - [deepctrl (en&zh)](https://www.modelscope.cn/datasets/deepctrl/deepctrl-sft-data)
252
+ - [Advertise Generating (zh)](https://huggingface.co/datasets/HasturOfficial/adgen)
253
+ - [ShareGPT Hyperfiltered (en)](https://huggingface.co/datasets/totally-not-an-llm/sharegpt-hyperfiltered-3k)
254
+ - [ShareGPT4 (en&zh)](https://huggingface.co/datasets/shibing624/sharegpt_gpt4)
255
+ - [UltraChat 200k (en)](https://huggingface.co/datasets/HuggingFaceH4/ultrachat_200k)
256
+ - [AgentInstruct (en)](https://huggingface.co/datasets/THUDM/AgentInstruct)
257
+ - [LMSYS Chat 1M (en)](https://huggingface.co/datasets/lmsys/lmsys-chat-1m)
258
+ - [Evol Instruct V2 (en)](https://huggingface.co/datasets/WizardLM/WizardLM_evol_instruct_V2_196k)
259
+ - [Cosmopedia (en)](https://huggingface.co/datasets/HuggingFaceTB/cosmopedia)
260
+ - [STEM (zh)](https://huggingface.co/datasets/hfl/stem_zh_instruction)
261
+ - [Ruozhiba (zh)](https://huggingface.co/datasets/hfl/ruozhiba_gpt4_turbo)
262
+ - [Neo-sft (zh)](https://huggingface.co/datasets/m-a-p/neo_sft_phase2)
263
+ - [LLaVA mixed (en&zh)](https://huggingface.co/datasets/BUAADreamer/llava-en-zh-300k)
264
+ - [Open Assistant (de)](https://huggingface.co/datasets/mayflowergmbh/oasst_de)
265
+ - [Dolly 15k (de)](https://huggingface.co/datasets/mayflowergmbh/dolly-15k_de)
266
+ - [Alpaca GPT4 (de)](https://huggingface.co/datasets/mayflowergmbh/alpaca-gpt4_de)
267
+ - [OpenSchnabeltier (de)](https://huggingface.co/datasets/mayflowergmbh/openschnabeltier_de)
268
+ - [Evol Instruct (de)](https://huggingface.co/datasets/mayflowergmbh/evol-instruct_de)
269
+ - [Dolphin (de)](https://huggingface.co/datasets/mayflowergmbh/dolphin_de)
270
+ - [Booksum (de)](https://huggingface.co/datasets/mayflowergmbh/booksum_de)
271
+ - [Airoboros (de)](https://huggingface.co/datasets/mayflowergmbh/airoboros-3.0_de)
272
+ - [Ultrachat (de)](https://huggingface.co/datasets/mayflowergmbh/ultra-chat_de)
273
+
274
+ </details>
275
+
276
+ <details><summary>偏好数据集</summary>
277
+
278
+ - [DPO mixed (en&zh)](https://huggingface.co/datasets/hiyouga/DPO-En-Zh-20k)
279
+ - [UltraFeedback (en)](https://huggingface.co/datasets/HuggingFaceH4/ultrafeedback_binarized)
280
+ - [Orca DPO Pairs (en)](https://huggingface.co/datasets/Intel/orca_dpo_pairs)
281
+ - [HH-RLHF (en)](https://huggingface.co/datasets/Anthropic/hh-rlhf)
282
+ - [Nectar (en)](https://huggingface.co/datasets/berkeley-nest/Nectar)
283
+ - [Orca DPO (de)](https://huggingface.co/datasets/mayflowergmbh/intel_orca_dpo_pairs_de)
284
+ - [KTO mixed (en)](https://huggingface.co/datasets/argilla/kto-mix-15k)
285
+
286
+ </details>
287
+
288
+ 部分数据集的使用需要确认,我们推荐使用下述命令登录您的 Hugging Face 账户。
289
+
290
+ ```bash
291
+ pip install --upgrade huggingface_hub
292
+ huggingface-cli login
293
+ ```
294
+
295
+ ## 软硬件依赖
296
+
297
+ | 必需项 | 至少 | 推荐 |
298
+ | ------------ | ------- | --------- |
299
+ | python | 3.8 | 3.11 |
300
+ | torch | 1.13.1 | 2.3.0 |
301
+ | transformers | 4.41.2 | 4.41.2 |
302
+ | datasets | 2.16.0 | 2.19.2 |
303
+ | accelerate | 0.30.1 | 0.30.1 |
304
+ | peft | 0.11.1 | 0.11.1 |
305
+ | trl | 0.8.6 | 0.9.4 |
306
+
307
+ | 可选项 | 至少 | 推荐 |
308
+ | ------------ | ------- | --------- |
309
+ | CUDA | 11.6 | 12.2 |
310
+ | deepspeed | 0.10.0 | 0.14.0 |
311
+ | bitsandbytes | 0.39.0 | 0.43.1 |
312
+ | vllm | 0.4.3 | 0.4.3 |
313
+ | flash-attn | 2.3.0 | 2.5.9 |
314
+
315
+ ### 硬件依赖
316
+
317
+ \* *估算值*
318
+
319
+ | 方法 | 精度 | 7B | 13B | 30B | 70B | 110B | 8x7B | 8x22B |
320
+ | ----------------- | ---- | ----- | ----- | ----- | ------ | ------ | ----- | ------ |
321
+ | Full | AMP | 120GB | 240GB | 600GB | 1200GB | 2000GB | 900GB | 2400GB |
322
+ | Full | 16 | 60GB | 120GB | 300GB | 600GB | 900GB | 400GB | 1200GB |
323
+ | Freeze | 16 | 20GB | 40GB | 80GB | 200GB | 360GB | 160GB | 400GB |
324
+ | LoRA/GaLore/BAdam | 16 | 16GB | 32GB | 64GB | 160GB | 240GB | 120GB | 320GB |
325
+ | QLoRA | 8 | 10GB | 20GB | 40GB | 80GB | 140GB | 60GB | 160GB |
326
+ | QLoRA | 4 | 6GB | 12GB | 24GB | 48GB | 72GB | 30GB | 96GB |
327
+ | QLoRA | 2 | 4GB | 8GB | 16GB | 24GB | 48GB | 18GB | 48GB |
328
+
329
+ ## 如何使用
330
+
331
+ ### 安装 LLaMA Factory
332
+
333
+ > [!IMPORTANT]
334
+ > 此步骤为必需。
335
+
336
+ ```bash
337
+ git clone --depth 1 https://github.com/hiyouga/LLaMA-Factory.git
338
+ cd LLaMA-Factory
339
+ pip install -e ".[torch,metrics]"
340
+ ```
341
+
342
+ 可选的额外依赖项:torch、torch_npu、metrics、deepspeed、bitsandbytes、vllm、galore、badam、gptq、awq、aqlm、qwen、modelscope、quality
343
+
344
+ > [!TIP]
345
+ > 遇到包冲突时,可使用 `pip install --no-deps -e .` 解决。
346
+
347
+ <details><summary>Windows 用户指南</summary>
348
+
349
+ 如果要在 Windows 平台上开启量化 LoRA(QLoRA),需要安装预编译的 `bitsandbytes` 库, 支持 CUDA 11.1 到 12.2, 请根据您的 CUDA 版本情况选择适合的[发布版本](https://github.com/jllllll/bitsandbytes-windows-webui/releases/tag/wheels)。
350
+
351
+ ```bash
352
+ pip install https://github.com/jllllll/bitsandbytes-windows-webui/releases/download/wheels/bitsandbytes-0.41.2.post2-py3-none-win_amd64.whl
353
+ ```
354
+
355
+ 如果要在 Windows 平台上开启 FlashAttention-2,需要安装预编译的 `flash-attn` 库,支持 CUDA 12.1 到 12.2,请根据需求到 [flash-attention](https://github.com/bdashore3/flash-attention/releases) 下载对应版本安装。
356
+
357
+ </details>
358
+
359
+ <details><summary>昇腾 NPU 用户指南</summary>
360
+
361
+ 加入 [NPU 用户群](assets/wechat_npu.jpg)。
362
+
363
+ 在昇腾 NPU 设备上安装 LLaMA Factory 时,需要指定额外依赖项,使用 `pip install -e '.[torch-npu,metrics]'` 命令安装。此外,还需要安装 **[Ascend CANN Toolkit and Kernels](https://www.hiascend.com/developer/download/community/result?module=cann)**,安装方法请参考[安装教程](https://www.hiascend.com/document/detail/zh/CANNCommunityEdition/80RC2alpha002/quickstart/quickstart/quickstart_18_0004.html)或使用以下命令:
364
+
365
+ ```bash
366
+ # 请替换 URL 为 CANN 版本和设备型号对应的 URL
367
+ # 安装 CANN Toolkit
368
+ wget https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Milan-ASL/Milan-ASL%20V100R001C17SPC701/Ascend-cann-toolkit_8.0.RC1.alpha001_linux-"$(uname -i)".run
369
+ bash Ascend-cann-toolkit_8.0.RC1.alpha001_linux-"$(uname -i)".run --install
370
+
371
+ # 安装 CANN Kernels
372
+ wget https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/Milan-ASL/Milan-ASL%20V100R001C17SPC701/Ascend-cann-kernels-910b_8.0.RC1.alpha001_linux.run
373
+ bash Ascend-cann-kernels-910b_8.0.RC1.alpha001_linux.run --install
374
+
375
+ # 设置环境变量
376
+ source /usr/local/Ascend/ascend-toolkit/set_env.sh
377
+ ```
378
+
379
+ | 依赖项 | 至少 | 推荐 |
380
+ | ------------ | ------- | ----------- |
381
+ | CANN | 8.0.RC1 | 8.0.RC1 |
382
+ | torch | 2.1.0 | 2.1.0 |
383
+ | torch-npu | 2.1.0 | 2.1.0.post3 |
384
+ | deepspeed | 0.13.2 | 0.13.2 |
385
+
386
+ Docker 镜像:
387
+
388
+ - 32GB:[下载地址](http://mirrors.cn-central-221.ovaijisuan.com/detail/130.html)
389
+ - 64GB:[下载地址](http://mirrors.cn-central-221.ovaijisuan.com/detail/131.html)
390
+
391
+ 请使用 `ASCEND_RT_VISIBLE_DEVICES` 而非 `CUDA_VISIBLE_DEVICES` 来指定运算设备。
392
+
393
+ 如果遇到无法正常推理的情况,请尝试设置 `do_sample: false`。
394
+
395
+ </details>
396
+
397
+ ### 数据准备
398
+
399
+ 关于数据集文件的格式,请参考 [data/README_zh.md](data/README_zh.md) 的内容。你可以使用 HuggingFace / ModelScope 上的数据集或加载本地数据集。
400
+
401
+ > [!NOTE]
402
+ > 使用自定义数据集时,请更新 `data/dataset_info.json` 文件。
403
+
404
+ ### 快速开始
405
+
406
+ 下面三行命令分别对 Llama3-8B-Instruct 模型进行 LoRA **微调**、**推理**和**合并**。
407
+
408
+ ```bash
409
+ llamafactory-cli train examples/train_lora/llama3_lora_sft.yaml
410
+ llamafactory-cli chat examples/inference/llama3_lora_sft.yaml
411
+ llamafactory-cli export examples/merge_lora/llama3_lora_sft.yaml
412
+ ```
413
+
414
+ 高级用法请参考 [examples/README_zh.md](examples/README_zh.md)(包括多 GPU 微调)。
415
+
416
+ > [!TIP]
417
+ > 使用 `llamafactory-cli help` 显示帮助信息。
418
+
419
+ ### LLaMA Board 可视化微调(由 [Gradio](https://github.com/gradio-app/gradio) 驱动)
420
+
421
+ ```bash
422
+ llamafactory-cli webui
423
+ ```
424
+
425
+ ### 构建 Docker
426
+
427
+ #### 使用 Docker
428
+
429
+ ```bash
430
+ docker build -f ./Dockerfile \
431
+ --build-arg INSTALL_BNB=false \
432
+ --build-arg INSTALL_VLLM=false \
433
+ --build-arg INSTALL_DEEPSPEED=false \
434
+ --build-arg PIP_INDEX=https://pypi.org/simple \
435
+ -t llamafactory:latest .
436
+
437
+ docker run -it --gpus=all \
438
+ -v ./hf_cache:/root/.cache/huggingface/ \
439
+ -v ./data:/app/data \
440
+ -v ./output:/app/output \
441
+ -p 7860:7860 \
442
+ -p 8000:8000 \
443
+ --shm-size 16G \
444
+ --name llamafactory \
445
+ llamafactory:latest
446
+ ```
447
+
448
+ #### 使用 Docker Compose
449
+
450
+ ```bash
451
+ docker-compose up -d
452
+ docker-compose exec llamafactory bash
453
+ ```
454
+
455
+ <details><summary>数据卷详情</summary>
456
+
457
+ - hf_cache:使用宿主机的 Hugging Face 缓存文件夹,允许更改为新的目录。
458
+ - data:宿主机中存放数据集的文件夹路径。
459
+ - output:将导出目录设置为该路径后,即可在宿主机中访问导出后的模型。
460
+
461
+ </details>
462
+
463
+ ### 利用 vLLM 部署 OpenAI API
464
+
465
+ ```bash
466
+ API_PORT=8000 llamafactory-cli api examples/inference/llama3_vllm.yaml
467
+ ```
468
+
469
+ > [!TIP]
470
+ > API 文档请查阅 https://platform.openai.com/docs/api-reference/chat/create。
471
+
472
+ ### 从魔搭社区下载
473
+
474
+ 如果您在 Hugging Face 模型和数据集的下载中遇到了问题,可以通过下述方法使用魔搭社区。
475
+
476
+ ```bash
477
+ export USE_MODELSCOPE_HUB=1 # Windows 使用 `set USE_MODELSCOPE_HUB=1`
478
+ ```
479
+
480
+ 将 `model_name_or_path` 设置为模型 ID 来加载对应的模型。在[魔搭社区](https://modelscope.cn/models)查看所有可用的模型,例如 `LLM-Research/Meta-Llama-3-8B-Instruct`。
481
+
482
+ ### 使用 W&B 面板
483
+
484
+ 若要使用 [Weights & Biases](https://wandb.ai) 记录实验数据,请在 yaml 文件中添加下面的参数。
485
+
486
+ ```yaml
487
+ report_to: wandb
488
+ run_name: test_run # 可选
489
+ ```
490
+
491
+ 在启动训练任务时,将 `WANDB_API_KEY` 设置为[密钥](https://wandb.ai/authorize)来登录 W&B 账户。
492
+
493
+ ## 使用了 LLaMA Factory 的项目
494
+
495
+ 如果您有项目希望添加至下述列表,请通过邮件联系或者创建一个 PR。
496
+
497
+ <details><summary>点击显示</summary>
498
+
499
+ 1. Wang et al. ESRL: Efficient Sampling-based Reinforcement Learning for Sequence Generation. 2023. [[arxiv]](https://arxiv.org/abs/2308.02223)
500
+ 1. Yu et al. Open, Closed, or Small Language Models for Text Classification? 2023. [[arxiv]](https://arxiv.org/abs/2308.10092)
501
+ 1. Wang et al. UbiPhysio: Support Daily Functioning, Fitness, and Rehabilitation with Action Understanding and Feedback in Natural Language. 2023. [[arxiv]](https://arxiv.org/abs/2308.10526)
502
+ 1. Luceri et al. Leveraging Large Language Models to Detect Influence Campaigns in Social Media. 2023. [[arxiv]](https://arxiv.org/abs/2311.07816)
503
+ 1. Zhang et al. Alleviating Hallucinations of Large Language Models through Induced Hallucinations. 2023. [[arxiv]](https://arxiv.org/abs/2312.15710)
504
+ 1. Wang et al. Know Your Needs Better: Towards Structured Understanding of Marketer Demands with Analogical Reasoning Augmented LLMs. 2024. [[arxiv]](https://arxiv.org/abs/2401.04319)
505
+ 1. Wang et al. CANDLE: Iterative Conceptualization and Instantiation Distillation from Large Language Models for Commonsense Reasoning. 2024. [[arxiv]](https://arxiv.org/abs/2401.07286)
506
+ 1. Choi et al. FACT-GPT: Fact-Checking Augmentation via Claim Matching with LLMs. 2024. [[arxiv]](https://arxiv.org/abs/2402.05904)
507
+ 1. Zhang et al. AutoMathText: Autonomous Data Selection with Language Models for Mathematical Texts. 2024. [[arxiv]](https://arxiv.org/abs/2402.07625)
508
+ 1. Lyu et al. KnowTuning: Knowledge-aware Fine-tuning for Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2402.11176)
509
+ 1. Yang et al. LaCo: Large Language Model Pruning via Layer Collaps. 2024. [[arxiv]](https://arxiv.org/abs/2402.11187)
510
+ 1. Bhardwaj et al. Language Models are Homer Simpson! Safety Re-Alignment of Fine-tuned Language Models through Task Arithmetic. 2024. [[arxiv]](https://arxiv.org/abs/2402.11746)
511
+ 1. Yang et al. Enhancing Empathetic Response Generation by Augmenting LLMs with Small-scale Empathetic Models. 2024. [[arxiv]](https://arxiv.org/abs/2402.11801)
512
+ 1. Yi et al. Generation Meets Verification: Accelerating Large Language Model Inference with Smart Parallel Auto-Correct Decoding. 2024. [[arxiv]](https://arxiv.org/abs/2402.11809)
513
+ 1. Cao et al. Head-wise Shareable Attention for Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2402.11819)
514
+ 1. Zhang et al. Enhancing Multilingual Capabilities of Large Language Models through Self-Distillation from Resource-Rich Languages. 2024. [[arxiv]](https://arxiv.org/abs/2402.12204)
515
+ 1. Kim et al. Efficient and Effective Vocabulary Expansion Towards Multilingual Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2402.14714)
516
+ 1. Yu et al. KIEval: A Knowledge-grounded Interactive Evaluation Framework for Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2402.15043)
517
+ 1. Huang et al. Key-Point-Driven Data Synthesis with its Enhancement on Mathematical Reasoning. 2024. [[arxiv]](https://arxiv.org/abs/2403.02333)
518
+ 1. Duan et al. Negating Negatives: Alignment without Human Positive Samples via Distributional Dispreference Optimization. 2024. [[arxiv]](https://arxiv.org/abs/2403.03419)
519
+ 1. Xie and Schwertfeger. Empowering Robotics with Large Language Models: osmAG Map Comprehension with LLMs. 2024. [[arxiv]](https://arxiv.org/abs/2403.08228)
520
+ 1. Wu et al. Large Language Models are Parallel Multilingual Learners. 2024. [[arxiv]](https://arxiv.org/abs/2403.09073)
521
+ 1. Zhang et al. EDT: Improving Large Language Models' Generation by Entropy-based Dynamic Temperature Sampling. 2024. [[arxiv]](https://arxiv.org/abs/2403.14541)
522
+ 1. Weller et al. FollowIR: Evaluating and Teaching Information Retrieval Models to Follow Instructions. 2024. [[arxiv]](https://arxiv.org/abs/2403.15246)
523
+ 1. Hongbin Na. CBT-LLM: A Chinese Large Language Model for Cognitive Behavioral Therapy-based Mental Health Question Answering. 2024. [[arxiv]](https://arxiv.org/abs/2403.16008)
524
+ 1. Zan et al. CodeS: Natural Language to Code Repository via Multi-Layer Sketch. 2024. [[arxiv]](https://arxiv.org/abs/2403.16443)
525
+ 1. Liu et al. Extensive Self-Contrast Enables Feedback-Free Language Model Alignment. 2024. [[arxiv]](https://arxiv.org/abs/2404.00604)
526
+ 1. Luo et al. BAdam: A Memory Efficient Full Parameter Training Method for Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2404.02827)
527
+ 1. Du et al. Chinese Tiny LLM: Pretraining a Chinese-Centric Large Language Model. 2024. [[arxiv]](https://arxiv.org/abs/2404.04167)
528
+ 1. Ma et al. Parameter Efficient Quasi-Orthogonal Fine-Tuning via Givens Rotation. 2024. [[arxiv]](https://arxiv.org/abs/2404.04316)
529
+ 1. Liu et al. Dynamic Generation of Personalities with Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2404.07084)
530
+ 1. Shang et al. How Far Have We Gone in Stripped Binary Code Understanding Using Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2404.09836)
531
+ 1. Huang et al. LLMTune: Accelerate Database Knob Tuning with Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2404.11581)
532
+ 1. Deng et al. Text-Tuple-Table: Towards Information Integration in Text-to-Table Generation via Global Tuple Extraction. 2024. [[arxiv]](https://arxiv.org/abs/2404.14215)
533
+ 1. Acikgoz et al. Hippocrates: An Open-Source Framework for Advancing Large Language Models in Healthcare. 2024. [[arxiv]](https://arxiv.org/abs/2404.16621)
534
+ 1. Zhang et al. Small Language Models Need Strong Verifiers to Self-Correct Reasoning. 2024. [[arxiv]](https://arxiv.org/abs/2404.17140)
535
+ 1. Zhou et al. FREB-TQA: A Fine-Grained Robustness Evaluation Benchmark for Table Question Answering. 2024. [[arxiv]](https://arxiv.org/abs/2404.18585)
536
+ 1. **[StarWhisper](https://github.com/Yu-Yang-Li/StarWhisper)**: 天文大模型 StarWhisper,基于 ChatGLM2-6B 和 Qwen-14B 在天文数据上微调而得。
537
+ 1. **[DISC-LawLLM](https://github.com/FudanDISC/DISC-LawLLM)**: 中文法律领域大模型 DISC-LawLLM,基于 Baichuan-13B 微调而得,具有法律推理和知识检索能力。
538
+ 1. **[Sunsimiao](https://github.com/X-D-Lab/Sunsimiao)**: 孙思邈中文医疗大模型 Sumsimiao,基于 Baichuan-7B 和 ChatGLM-6B 在中文医疗数据上微调而得。
539
+ 1. **[CareGPT](https://github.com/WangRongsheng/CareGPT)**: 医疗大模型项目 CareGPT,基�� LLaMA2-7B 和 Baichuan-13B 在中文医疗数据上微调而得。
540
+ 1. **[MachineMindset](https://github.com/PKU-YuanGroup/Machine-Mindset/)**:MBTI性格大模型项目,根据数据集与训练方式让任意 LLM 拥有 16 个不同的性格类型。
541
+ 1. **[Luminia-13B-v3](https://huggingface.co/Nekochu/Luminia-13B-v3)**:一个用于生成 Stable Diffusion 提示词的大型语言模型。[[🤗Demo]](https://huggingface.co/spaces/Nekochu/Luminia-13B_SD_Prompt)
542
+ 1. **[Chinese-LLaVA-Med](https://github.com/BUAADreamer/Chinese-LLaVA-Med)**:中文多模态医学大模型,基于 LLaVA-1.5-7B 在中文多模态医疗数据上微调而得。
543
+
544
+ </details>
545
+
546
+ ## 协议
547
+
548
+ 本仓库的代码依照 [Apache-2.0](LICENSE) 协议开源。
549
+
550
+ 使用模型权重时,请遵循对应的模型协议:[Baichuan2](https://huggingface.co/baichuan-inc/Baichuan2-7B-Base/blob/main/Community%20License%20for%20Baichuan%202%20Model.pdf) / [BLOOM](https://huggingface.co/spaces/bigscience/license) / [ChatGLM3](https://github.com/THUDM/ChatGLM3/blob/main/MODEL_LICENSE) / [Command-R](https://cohere.com/c4ai-cc-by-nc-license) / [DeepSeek](https://github.com/deepseek-ai/DeepSeek-LLM/blob/main/LICENSE-MODEL) / [Falcon](https://huggingface.co/tiiuae/falcon-180B/blob/main/LICENSE.txt) / [Gemma](https://ai.google.dev/gemma/terms) / [GLM4](https://huggingface.co/THUDM/glm-4-9b/blob/main/LICENSE) / [InternLM2](https://github.com/InternLM/InternLM#license) / [LLaMA](https://github.com/facebookresearch/llama/blob/main/MODEL_CARD.md) / [LLaMA-2 (LLaVA-1.5)](https://ai.meta.com/llama/license/) / [LLaMA-3](https://llama.meta.com/llama3/license/) / [Mistral](LICENSE) / [OLMo](LICENSE) / [Phi-1.5/2](https://huggingface.co/microsoft/phi-1_5/resolve/main/Research%20License.docx) / [Phi-3](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct/blob/main/LICENSE) / [Qwen](https://github.com/QwenLM/Qwen/blob/main/Tongyi%20Qianwen%20LICENSE%20AGREEMENT) / [StarCoder2](https://huggingface.co/spaces/bigcode/bigcode-model-license-agreement) / [XVERSE](https://github.com/xverse-ai/XVERSE-13B/blob/main/MODEL_LICENSE.pdf) / [Yi](https://huggingface.co/01-ai/Yi-6B/blob/main/LICENSE) / [Yi-1.5](LICENSE) / [Yuan](https://github.com/IEIT-Yuan/Yuan-2.0/blob/main/LICENSE-Yuan)
551
+
552
+ ## 引用
553
+
554
+ 如果您觉得此项目有帮助,请考虑以下列格式引用
555
+
556
+ ```bibtex
557
+ @article{zheng2024llamafactory,
558
+ title={LlamaFactory: Unified Efficient Fine-Tuning of 100+ Language Models},
559
+ author={Yaowei Zheng and Richong Zhang and Junhao Zhang and Yanhan Ye and Zheyan Luo and Yongqiang Ma},
560
+ journal={arXiv preprint arXiv:2403.13372},
561
+ year={2024},
562
+ url={http://arxiv.org/abs/2403.13372}
563
+ }
564
+ ```
565
+
566
+ ## 致谢
567
+
568
+ 本项目受益于 [PEFT](https://github.com/huggingface/peft)、[TRL](https://github.com/huggingface/trl)、[QLoRA](https://github.com/artidoro/qlora) 和 [FastChat](https://github.com/lm-sys/FastChat),感谢以上诸位作者的付出。
569
+
570
+ ## Star History
571
+
572
+ ![Star History Chart](https://api.star-history.com/svg?repos=hiyouga/LLaMA-Factory&type=Date)
app.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def greet(name):
4
+ return "Hello " + name + "!"
5
+
6
+ demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
+
8
+ if __name__ == "__main__":
9
+ demo.launch()
assets/benchmark.svg ADDED
assets/logo.png ADDED
assets/wechat.jpg ADDED
assets/wechat_npu.jpg ADDED
data/README.md ADDED
@@ -0,0 +1,350 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The [dataset_info.json](dataset_info.json) contains all available datasets. If you are using a custom dataset, please **make sure** to add a *dataset description* in `dataset_info.json` and specify `dataset: dataset_name` before training to use it.
2
+
3
+ Currently we support datasets in **alpaca** and **sharegpt** format.
4
+
5
+ ```json
6
+ "dataset_name": {
7
+ "hf_hub_url": "the name of the dataset repository on the Hugging Face hub. (if specified, ignore script_url and file_name)",
8
+ "ms_hub_url": "the name of the dataset repository on the Model Scope hub. (if specified, ignore script_url and file_name)",
9
+ "script_url": "the name of the directory containing a dataset loading script. (if specified, ignore file_name)",
10
+ "file_name": "the name of the dataset folder or dataset file in this directory. (required if above are not specified)",
11
+ "formatting": "the format of the dataset. (optional, default: alpaca, can be chosen from {alpaca, sharegpt})",
12
+ "ranking": "whether the dataset is a preference dataset or not. (default: False)",
13
+ "subset": "the name of the subset. (optional, default: None)",
14
+ "folder": "the name of the folder of the dataset repository on the Hugging Face hub. (optional, default: None)",
15
+ "num_samples": "the number of samples in the dataset used for training. (optional, default: None)",
16
+ "columns (optional)": {
17
+ "prompt": "the column name in the dataset containing the prompts. (default: instruction)",
18
+ "query": "the column name in the dataset containing the queries. (default: input)",
19
+ "response": "the column name in the dataset containing the responses. (default: output)",
20
+ "history": "the column name in the dataset containing the histories. (default: None)",
21
+ "messages": "the column name in the dataset containing the messages. (default: conversations)",
22
+ "system": "the column name in the dataset containing the system prompts. (default: None)",
23
+ "tools": "the column name in the dataset containing the tool description. (default: None)",
24
+ "images": "the column name in the dataset containing the image inputs. (default: None)",
25
+ "chosen": "the column name in the dataset containing the chosen answers. (default: None)",
26
+ "rejected": "the column name in the dataset containing the rejected answers. (default: None)",
27
+ "kto_tag": "the column name in the dataset containing the kto tags. (default: None)"
28
+ },
29
+ "tags (optional, used for the sharegpt format)": {
30
+ "role_tag": "the key in the message represents the identity. (default: from)",
31
+ "content_tag": "the key in the message represents the content. (default: value)",
32
+ "user_tag": "the value of the role_tag represents the user. (default: human)",
33
+ "assistant_tag": "the value of the role_tag represents the assistant. (default: gpt)",
34
+ "observation_tag": "the value of the role_tag represents the tool results. (default: observation)",
35
+ "function_tag": "the value of the role_tag represents the function call. (default: function_call)",
36
+ "system_tag": "the value of the role_tag represents the system prompt. (default: system, can override system column)"
37
+ }
38
+ }
39
+ ```
40
+
41
+ ## Alpaca Format
42
+
43
+ ### Supervised Fine-Tuning Dataset
44
+
45
+ * [Example dataset](alpaca_en_demo.json)
46
+
47
+ In supervised fine-tuning, the `instruction` column will be concatenated with the `input` column and used as the human prompt, then the human prompt would be `instruction\ninput`. The `output` column represents the model response.
48
+
49
+ The `system` column will be used as the system prompt if specified.
50
+
51
+ The `history` column is a list consisting of string tuples representing prompt-response pairs in the history messages. Note that the responses in the history **will also be learned by the model** in supervised fine-tuning.
52
+
53
+ ```json
54
+ [
55
+ {
56
+ "instruction": "human instruction (required)",
57
+ "input": "human input (optional)",
58
+ "output": "model response (required)",
59
+ "system": "system prompt (optional)",
60
+ "history": [
61
+ ["human instruction in the first round (optional)", "model response in the first round (optional)"],
62
+ ["human instruction in the second round (optional)", "model response in the second round (optional)"]
63
+ ]
64
+ }
65
+ ]
66
+ ```
67
+
68
+ Regarding the above dataset, the *dataset description* in `dataset_info.json` should be:
69
+
70
+ ```json
71
+ "dataset_name": {
72
+ "file_name": "data.json",
73
+ "columns": {
74
+ "prompt": "instruction",
75
+ "query": "input",
76
+ "response": "output",
77
+ "system": "system",
78
+ "history": "history"
79
+ }
80
+ }
81
+ ```
82
+
83
+ ### Pre-training Dataset
84
+
85
+ - [Example dataset](c4_demo.json)
86
+
87
+ In pre-training, only the `text` column will be used for model learning.
88
+
89
+ ```json
90
+ [
91
+ {"text": "document"},
92
+ {"text": "document"}
93
+ ]
94
+ ```
95
+
96
+ Regarding the above dataset, the *dataset description* in `dataset_info.json` should be:
97
+
98
+ ```json
99
+ "dataset_name": {
100
+ "file_name": "data.json",
101
+ "columns": {
102
+ "prompt": "text"
103
+ }
104
+ }
105
+ ```
106
+
107
+ ### Preference Dataset
108
+
109
+ Preference datasets are used for reward modeling, DPO training and ORPO training.
110
+
111
+ It requires a better response in `chosen` column and a worse response in `rejected` column.
112
+
113
+ ```json
114
+ [
115
+ {
116
+ "instruction": "human instruction (required)",
117
+ "input": "human input (optional)",
118
+ "chosen": "chosen answer (required)",
119
+ "rejected": "rejected answer (required)"
120
+ }
121
+ ]
122
+ ```
123
+
124
+ Regarding the above dataset, the *dataset description* in `dataset_info.json` should be:
125
+
126
+ ```json
127
+ "dataset_name": {
128
+ "file_name": "data.json",
129
+ "ranking": true,
130
+ "columns": {
131
+ "prompt": "instruction",
132
+ "query": "input",
133
+ "chosen": "chosen",
134
+ "rejected": "rejected"
135
+ }
136
+ }
137
+ ```
138
+
139
+ ### KTO Dataset
140
+
141
+ - [Example dataset](kto_en_demo.json)
142
+
143
+ KTO datasets require a extra `kto_tag` column containing the boolean human feedback.
144
+
145
+ ```json
146
+ [
147
+ {
148
+ "instruction": "human instruction (required)",
149
+ "input": "human input (optional)",
150
+ "output": "model response (required)",
151
+ "kto_tag": "human feedback [true/false] (required)"
152
+ }
153
+ ]
154
+ ```
155
+
156
+ Regarding the above dataset, the *dataset description* in `dataset_info.json` should be:
157
+
158
+ ```json
159
+ "dataset_name": {
160
+ "file_name": "data.json",
161
+ "columns": {
162
+ "prompt": "instruction",
163
+ "query": "input",
164
+ "response": "output",
165
+ "kto_tag": "kto_tag"
166
+ }
167
+ }
168
+ ```
169
+
170
+ ### Multimodal Dataset
171
+
172
+ - [Example dataset](mllm_demo.json)
173
+
174
+ Multimodal datasets require a `images` column containing the paths to the input images. Currently we only support one image.
175
+
176
+ ```json
177
+ [
178
+ {
179
+ "instruction": "human instruction (required)",
180
+ "input": "human input (optional)",
181
+ "output": "model response (required)",
182
+ "images": [
183
+ "image path (required)"
184
+ ]
185
+ }
186
+ ]
187
+ ```
188
+
189
+ Regarding the above dataset, the *dataset description* in `dataset_info.json` should be:
190
+
191
+ ```json
192
+ "dataset_name": {
193
+ "file_name": "data.json",
194
+ "columns": {
195
+ "prompt": "instruction",
196
+ "query": "input",
197
+ "response": "output",
198
+ "images": "images"
199
+ }
200
+ }
201
+ ```
202
+
203
+ ## Sharegpt Format
204
+
205
+ ### Supervised Fine-Tuning Dataset
206
+
207
+ - [Example dataset](glaive_toolcall_en_demo.json)
208
+
209
+ Compared to the alpaca format, the sharegpt format allows the datasets have **more roles**, such as human, gpt, observation and function. They are presented in a list of objects in the `conversations` column.
210
+
211
+ Note that the human and observation should appear in odd positions, while gpt and function should appear in even positions.
212
+
213
+ ```json
214
+ [
215
+ {
216
+ "conversations": [
217
+ {
218
+ "from": "human",
219
+ "value": "human instruction"
220
+ },
221
+ {
222
+ "from": "function_call",
223
+ "value": "tool arguments"
224
+ },
225
+ {
226
+ "from": "observation",
227
+ "value": "tool result"
228
+ },
229
+ {
230
+ "from": "gpt",
231
+ "value": "model response"
232
+ }
233
+ ],
234
+ "system": "system prompt (optional)",
235
+ "tools": "tool description (optional)"
236
+ }
237
+ ]
238
+ ```
239
+
240
+ Regarding the above dataset, the *dataset description* in `dataset_info.json` should be:
241
+
242
+ ```json
243
+ "dataset_name": {
244
+ "file_name": "data.json",
245
+ "formatting": "sharegpt",
246
+ "columns": {
247
+ "messages": "conversations",
248
+ "system": "system",
249
+ "tools": "tools"
250
+ }
251
+ }
252
+ ```
253
+
254
+ ### Preference Dataset
255
+
256
+ - [Example dataset](dpo_en_demo.json)
257
+
258
+ Preference datasets in sharegpt format also require a better message in `chosen` column and a worse message in `rejected` column.
259
+
260
+ ```json
261
+ [
262
+ {
263
+ "conversations": [
264
+ {
265
+ "from": "human",
266
+ "value": "human instruction"
267
+ },
268
+ {
269
+ "from": "gpt",
270
+ "value": "model response"
271
+ },
272
+ {
273
+ "from": "human",
274
+ "value": "human instruction"
275
+ }
276
+ ],
277
+ "chosen": {
278
+ "from": "gpt",
279
+ "value": "chosen answer (required)"
280
+ },
281
+ "rejected": {
282
+ "from": "gpt",
283
+ "value": "rejected answer (required)"
284
+ }
285
+ }
286
+ ]
287
+ ```
288
+
289
+ Regarding the above dataset, the *dataset description* in `dataset_info.json` should be:
290
+
291
+ ```json
292
+ "dataset_name": {
293
+ "file_name": "data.json",
294
+ "formatting": "sharegpt",
295
+ "ranking": true,
296
+ "columns": {
297
+ "messages": "conversations",
298
+ "chosen": "chosen",
299
+ "rejected": "rejected"
300
+ }
301
+ }
302
+ ```
303
+
304
+ ### OpenAI Format
305
+
306
+ The openai format is simply a special case of the sharegpt format, where the first message may be a system prompt.
307
+
308
+ ```json
309
+ [
310
+ {
311
+ "messages": [
312
+ {
313
+ "role": "system",
314
+ "content": "system prompt (optional)"
315
+ },
316
+ {
317
+ "role": "user",
318
+ "content": "human instruction"
319
+ },
320
+ {
321
+ "role": "assistant",
322
+ "content": "model response"
323
+ }
324
+ ]
325
+ }
326
+ ]
327
+ ```
328
+
329
+ Regarding the above dataset, the *dataset description* in `dataset_info.json` should be:
330
+
331
+ ```json
332
+ "dataset_name": {
333
+ "file_name": "data.json",
334
+ "formatting": "sharegpt",
335
+ "columns": {
336
+ "messages": "messages"
337
+ },
338
+ "tags": {
339
+ "role_tag": "role",
340
+ "content_tag": "content",
341
+ "user_tag": "user",
342
+ "assistant_tag": "assistant",
343
+ "system_tag": "system"
344
+ }
345
+ }
346
+ ```
347
+
348
+ The KTO datasets and multimodal datasets in sharegpt format are similar to the alpaca format.
349
+
350
+ Pre-training datasets are **incompatible** with the sharegpt format.
data/README_zh.md ADDED
@@ -0,0 +1,350 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [dataset_info.json](dataset_info.json) 包含了所有可用的数据集。如果您希望使用自定义数据集,请**务必**在 `dataset_info.json` 文件中添加*数据集描述*,并通过修改 `dataset: 数据集名称` 配置来使用数据集。
2
+
3
+ 目前我们支持 **alpaca** 格式和 **sharegpt** 格式的数据集。
4
+
5
+ ```json
6
+ "数据集名称": {
7
+ "hf_hub_url": "Hugging Face 的数据集仓库地址(若指定,则忽略 script_url 和 file_name)",
8
+ "ms_hub_url": "ModelScope 的数据集仓库地址(若指定,则忽略 script_url 和 file_name)",
9
+ "script_url": "包含数据加载脚本的本地文件夹名称(若指定,则忽略 file_name)",
10
+ "file_name": "该目录下数据集文件夹或文件的名称(若上述参数未指定,则此项必需)",
11
+ "formatting": "数据集格式(可选,默认:alpaca,可以为 alpaca 或 sharegpt)",
12
+ "ranking": "是否为偏好数据集(可选,默认:False)",
13
+ "subset": "数据集子集的名称(可选,默认:None)",
14
+ "folder": "Hugging Face 仓库的文件夹名称(可选,默认:None)",
15
+ "num_samples": "该数据集中用于训练的样本数量。(可选,默认:None)",
16
+ "columns(可选)": {
17
+ "prompt": "数据集代表提示词的表头名称(默认:instruction)",
18
+ "query": "数据集代表请求的表头名称(默认:input)",
19
+ "response": "数据集代表回答的表头名称(默认:output)",
20
+ "history": "数据集代表历史对话的表头名称(默认:None)",
21
+ "messages": "数据集代表消息列表的表头名称(默认:conversations)",
22
+ "system": "数据集代表系统提示的表头名称(默认:None)",
23
+ "tools": "数据集代表工具描述的表头名称(默认:None)",
24
+ "images": "数据集代表图像输入的表头名称(默认:None)",
25
+ "chosen": "数据集代表更优回答的表头名称(默认:None)",
26
+ "rejected": "数据集代表更差回答的表头名称(默认:None)",
27
+ "kto_tag": "数据集代表 KTO 标签的表头名称(默认:None)"
28
+ },
29
+ "tags(可选,用于 sharegpt 格式)": {
30
+ "role_tag": "消息中代表发送者身份的键名(默认:from)",
31
+ "content_tag": "消息中代表文本内容的键名(默认:value)",
32
+ "user_tag": "消息中代表用户的 role_tag(默认:human)",
33
+ "assistant_tag": "消息中代表助手的 role_tag(默认:gpt)",
34
+ "observation_tag": "消息中代表工具返回结果的 role_tag(默认:observation)",
35
+ "function_tag": "消息中代表工具调用的 role_tag(默认:function_call)",
36
+ "system_tag": "消息中代表系统提示的 role_tag(默认:system,会覆盖 system column)"
37
+ }
38
+ }
39
+ ```
40
+
41
+ ## Alpaca 格式
42
+
43
+ ### 指令监督微调数据集
44
+
45
+ - [样例数据集](alpaca_zh_demo.json)
46
+
47
+ 在指令监督微调时,`instruction` 列对应的内容会与 `input` 列对应的内容拼接后作为人类指令,即人类指令为 `instruction\ninput`。而 `output` 列对应的内容为模型回答。
48
+
49
+ 如果指定,`system` 列对应的内容将被作为系统提示词。
50
+
51
+ `history` 列是由多个字符串二元组构成的列表,分别代表历史消息中每轮对话的指令和回答。注意在指令监督微调时,历史消息中的回答内容**也会被用于模型学习**。
52
+
53
+ ```json
54
+ [
55
+ {
56
+ "instruction": "人类指令(必填)",
57
+ "input": "人类输入(选填)",
58
+ "output": "模型回答(必填)",
59
+ "system": "系统提示词(选填)",
60
+ "history": [
61
+ ["第一轮指令(选填)", "第一轮回答(选填)"],
62
+ ["第二轮指令(选填)", "第二轮回答(选填)"]
63
+ ]
64
+ }
65
+ ]
66
+ ```
67
+
68
+ 对于上述格式的数据,`dataset_info.json` 中的*数据集描述*应为:
69
+
70
+ ```json
71
+ "数据集名称": {
72
+ "file_name": "data.json",
73
+ "columns": {
74
+ "prompt": "instruction",
75
+ "query": "input",
76
+ "response": "output",
77
+ "system": "system",
78
+ "history": "history"
79
+ }
80
+ }
81
+ ```
82
+
83
+ ### 预训练数据集
84
+
85
+ - [样例数据集](c4_demo.json)
86
+
87
+ 在预训练时,只有 `text` 列中的内容会用于模型学习。
88
+
89
+ ```json
90
+ [
91
+ {"text": "document"},
92
+ {"text": "document"}
93
+ ]
94
+ ```
95
+
96
+ 对于上述格式的数据,`dataset_info.json` 中的*数据集描述*应为:
97
+
98
+ ```json
99
+ "数据集名称": {
100
+ "file_name": "data.json",
101
+ "columns": {
102
+ "prompt": "text"
103
+ }
104
+ }
105
+ ```
106
+
107
+ ### 偏好数据集
108
+
109
+ 偏好数据集用于奖励模型训练、DPO 训练和 ORPO 训练。
110
+
111
+ 它需要在 `chosen` 列中提供更优的回答,并在 `rejected` 列中提供更差的回答。
112
+
113
+ ```json
114
+ [
115
+ {
116
+ "instruction": "人类指令(必填)",
117
+ "input": "人类输入(选填)",
118
+ "chosen": "优质回答(必填)",
119
+ "rejected": "劣质回答(必填)"
120
+ }
121
+ ]
122
+ ```
123
+
124
+ 对于上述格式的数据,`dataset_info.json` 中的*数据集描述*应为:
125
+
126
+ ```json
127
+ "数据集名称": {
128
+ "file_name": "data.json",
129
+ "ranking": true,
130
+ "columns": {
131
+ "prompt": "instruction",
132
+ "query": "input",
133
+ "chosen": "chosen",
134
+ "rejected": "rejected"
135
+ }
136
+ }
137
+ ```
138
+
139
+ ### KTO 数据集
140
+
141
+ - [样例数据集](kto_en_demo.json)
142
+
143
+ KTO 数据集需要额外添加一个 `kto_tag` 列,包含 bool 类型的人类反馈。
144
+
145
+ ```json
146
+ [
147
+ {
148
+ "instruction": "人类指令(必填)",
149
+ "input": "人类输入(选填)",
150
+ "output": "模型回答(必填)",
151
+ "kto_tag": "人类反馈 [true/false](必填)"
152
+ }
153
+ ]
154
+ ```
155
+
156
+ 对于上述格式的数据,`dataset_info.json` 中的*数据集描述*应为:
157
+
158
+ ```json
159
+ "数据集名称": {
160
+ "file_name": "data.json",
161
+ "columns": {
162
+ "prompt": "instruction",
163
+ "query": "input",
164
+ "response": "output",
165
+ "kto_tag": "kto_tag"
166
+ }
167
+ }
168
+ ```
169
+
170
+ ### 多模态数据集
171
+
172
+ - [样例数据集](mllm_demo.json)
173
+
174
+ 多模态数据集需要额外添加一个 `images` 列,包含输入图像的路径。目前我们仅支持单张图像输入。
175
+
176
+ ```json
177
+ [
178
+ {
179
+ "instruction": "人类指令(必填)",
180
+ "input": "人类输入(选填)",
181
+ "output": "模型回答(必填)",
182
+ "images": [
183
+ "图像路径(必填)"
184
+ ]
185
+ }
186
+ ]
187
+ ```
188
+
189
+ 对于上述格式的数据,`dataset_info.json` 中的*数据集描述*应为:
190
+
191
+ ```json
192
+ "数据集名称": {
193
+ "file_name": "data.json",
194
+ "columns": {
195
+ "prompt": "instruction",
196
+ "query": "input",
197
+ "response": "output",
198
+ "images": "images"
199
+ }
200
+ }
201
+ ```
202
+
203
+ ## Sharegpt 格式
204
+
205
+ ### 指令监督微调数据集
206
+
207
+ - [样例数据集](glaive_toolcall_zh_demo.json)
208
+
209
+ 相比 alpaca 格式的数据集,sharegpt 格式支持**更多的角色种类**,例如 human、gpt、observation、function 等等。它们构成一个对象列表呈现在 `conversations` 列中。
210
+
211
+ 注意其中 human 和 observation 必须出现在奇数位置,gpt 和 function 必须出现在偶数位置。
212
+
213
+ ```json
214
+ [
215
+ {
216
+ "conversations": [
217
+ {
218
+ "from": "human",
219
+ "value": "人类指令"
220
+ },
221
+ {
222
+ "from": "function_call",
223
+ "value": "工具参数"
224
+ },
225
+ {
226
+ "from": "observation",
227
+ "value": "工具结果"
228
+ },
229
+ {
230
+ "from": "gpt",
231
+ "value": "模型回答"
232
+ }
233
+ ],
234
+ "system": "系统提示词(选填)",
235
+ "tools": "工具描述(选填)"
236
+ }
237
+ ]
238
+ ```
239
+
240
+ 对于上述格式的数据,`dataset_info.json` 中的*数据集描述*应为:
241
+
242
+ ```json
243
+ "数据集名称": {
244
+ "file_name": "data.json",
245
+ "formatting": "sharegpt",
246
+ "columns": {
247
+ "messages": "conversations",
248
+ "system": "system",
249
+ "tools": "tools"
250
+ }
251
+ }
252
+ ```
253
+
254
+ ### 偏好数据集
255
+
256
+ - [样例数据集](dpo_zh_demo.json)
257
+
258
+ Sharegpt 格式的偏好数据集同样需要在 `chosen` 列中提供更优的消息,并在 `rejected` 列中提供更差的消息。
259
+
260
+ ```json
261
+ [
262
+ {
263
+ "conversations": [
264
+ {
265
+ "from": "human",
266
+ "value": "人类指令"
267
+ },
268
+ {
269
+ "from": "gpt",
270
+ "value": "模型回答"
271
+ },
272
+ {
273
+ "from": "human",
274
+ "value": "人类指令"
275
+ }
276
+ ],
277
+ "chosen": {
278
+ "from": "gpt",
279
+ "value": "优质回答"
280
+ },
281
+ "rejected": {
282
+ "from": "gpt",
283
+ "value": "劣质回答"
284
+ }
285
+ }
286
+ ]
287
+ ```
288
+
289
+ 对于上述格式的数据,`dataset_info.json` 中的*数据集描述*应为:
290
+
291
+ ```json
292
+ "数据集名称": {
293
+ "file_name": "data.json",
294
+ "formatting": "sharegpt",
295
+ "ranking": true,
296
+ "columns": {
297
+ "messages": "conversations",
298
+ "chosen": "chosen",
299
+ "rejected": "rejected"
300
+ }
301
+ }
302
+ ```
303
+
304
+ ### OpenAI 格式
305
+
306
+ OpenAI 格式仅仅是 sharegpt 格式的一种特殊情况,其中第一条消息可能是系统提示词。
307
+
308
+ ```json
309
+ [
310
+ {
311
+ "messages": [
312
+ {
313
+ "role": "system",
314
+ "content": "系统提示词(选填)"
315
+ },
316
+ {
317
+ "role": "user",
318
+ "content": "人类指令"
319
+ },
320
+ {
321
+ "role": "assistant",
322
+ "content": "模型回答"
323
+ }
324
+ ]
325
+ }
326
+ ]
327
+ ```
328
+
329
+ 对于上述格式的数据,`dataset_info.json` 中的*数据集描述*应为:
330
+
331
+ ```json
332
+ "数据集名称": {
333
+ "file_name": "data.json",
334
+ "formatting": "sharegpt",
335
+ "columns": {
336
+ "messages": "messages"
337
+ },
338
+ "tags": {
339
+ "role_tag": "role",
340
+ "content_tag": "content",
341
+ "user_tag": "user",
342
+ "assistant_tag": "assistant",
343
+ "system_tag": "system"
344
+ }
345
+ }
346
+ ```
347
+
348
+ Sharegpt 格式中的 KTO 数据集和多模态数据集与 alpaca 格式的类似。
349
+
350
+ 预训练数据集**不支持** sharegpt 格式。
data/alpaca_en_demo.json ADDED
The diff for this file is too large to render. See raw diff
 
data/alpaca_zh_demo.json ADDED
The diff for this file is too large to render. See raw diff
 
data/belle_multiturn/belle_multiturn.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import os
3
+
4
+ import datasets
5
+
6
+
7
+ _HF_ENDPOINT = os.getenv("HF_ENDPOINT", "https://huggingface.co")
8
+
9
+ _DESCRIPTION = "BELLE multiturn chat dataset."
10
+
11
+ _CITATION = """\
12
+ @article{belle2023exploring,
13
+ title={Exploring the Impact of Instruction Data Scaling on Large Language Models: An Empirical Study on Real-World Use Cases},
14
+ author={Yunjie Ji, Yong Deng, Yan Gong, Yiping Peng, Qiang Niu, Lei Zhang, Baochang Ma, Xiangang Li},
15
+ journal={arXiv preprint arXiv:2303.14742},
16
+ year={2023}
17
+ }
18
+ """
19
+
20
+ _HOMEPAGE = "{}/datasets/BelleGroup/multiturn_chat_0.8M".format(_HF_ENDPOINT)
21
+ _LICENSE = "gpl-3.0"
22
+ _URL = "{}/datasets/BelleGroup/multiturn_chat_0.8M/resolve/main/multiturn_chat_0.8M.json".format(_HF_ENDPOINT)
23
+
24
+
25
+ class BelleMultiturn(datasets.GeneratorBasedBuilder):
26
+ VERSION = datasets.Version("0.0.0")
27
+
28
+ def _info(self):
29
+ features = datasets.Features(
30
+ {"conversations": [{"from": datasets.Value("string"), "value": datasets.Value("string")}]}
31
+ )
32
+ return datasets.DatasetInfo(
33
+ description=_DESCRIPTION, features=features, homepage=_HOMEPAGE, license=_LICENSE, citation=_CITATION
34
+ )
35
+
36
+ def _split_generators(self, dl_manager: datasets.DownloadManager):
37
+ file_path = dl_manager.download(_URL)
38
+ return [datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": file_path})]
39
+
40
+ def _generate_examples(self, filepath: str):
41
+ with open(filepath, "r", encoding="utf-8") as f:
42
+ for key, row in enumerate(f):
43
+ data = json.loads(row)
44
+ conversations = []
45
+ prompt = data["instruction"].strip()
46
+ response = data["output"].strip()
47
+
48
+ assist_idx = prompt.rfind("Assistant:")
49
+ human_idx = prompt.rfind("Human:")
50
+ query = prompt[human_idx + 6 : assist_idx].strip()
51
+ prompt = prompt[:human_idx].strip()
52
+ conversations.insert(0, {"from": "gpt", "value": response})
53
+ conversations.insert(0, {"from": "human", "value": query})
54
+
55
+ while prompt.rfind("Assistant:") != -1:
56
+ assist_idx = prompt.rfind("Assistant:")
57
+ human_idx = prompt.rfind("Human:")
58
+ if human_idx != -1:
59
+ old_query = prompt[human_idx + 6 : assist_idx].strip()
60
+ old_resp = prompt[assist_idx + 10 :].strip()
61
+ conversations.insert(0, {"from": "gpt", "value": old_resp})
62
+ conversations.insert(0, {"from": "human", "value": old_query})
63
+ else:
64
+ break
65
+ prompt = prompt[:human_idx].strip()
66
+
67
+ yield key, {"conversations": conversations}
data/c4_demo.json ADDED
The diff for this file is too large to render. See raw diff
 
data/dataset_info.json ADDED
@@ -0,0 +1,554 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "identity": {
3
+ "file_name": "identity.json"
4
+ },
5
+ "alpaca_en_demo": {
6
+ "file_name": "alpaca_en_demo.json"
7
+ },
8
+ "alpaca_zh_demo": {
9
+ "file_name": "alpaca_zh_demo.json"
10
+ },
11
+ "glaive_toolcall_en_demo": {
12
+ "file_name": "glaive_toolcall_en_demo.json",
13
+ "formatting": "sharegpt",
14
+ "columns": {
15
+ "messages": "conversations",
16
+ "tools": "tools"
17
+ }
18
+ },
19
+ "glaive_toolcall_zh_demo": {
20
+ "file_name": "glaive_toolcall_zh_demo.json",
21
+ "formatting": "sharegpt",
22
+ "columns": {
23
+ "messages": "conversations",
24
+ "tools": "tools"
25
+ }
26
+ },
27
+ "mllm_demo": {
28
+ "file_name": "mllm_demo.json",
29
+ "formatting": "sharegpt",
30
+ "columns": {
31
+ "messages": "messages",
32
+ "images": "images"
33
+ },
34
+ "tags": {
35
+ "role_tag": "role",
36
+ "content_tag": "content",
37
+ "user_tag": "user",
38
+ "assistant_tag": "assistant"
39
+ }
40
+ },
41
+ "alpaca_en": {
42
+ "hf_hub_url": "llamafactory/alpaca_en",
43
+ "ms_hub_url": "llamafactory/alpaca_en"
44
+ },
45
+ "alpaca_zh": {
46
+ "hf_hub_url": "llamafactory/alpaca_zh",
47
+ "ms_hub_url": "llamafactory/alpaca_zh"
48
+ },
49
+ "alpaca_gpt4_en": {
50
+ "hf_hub_url": "llamafactory/alpaca_gpt4_en",
51
+ "ms_hub_url": "llamafactory/alpaca_gpt4_en"
52
+ },
53
+ "alpaca_gpt4_zh": {
54
+ "hf_hub_url": "llamafactory/alpaca_gpt4_zh",
55
+ "ms_hub_url": "llamafactory/alpaca_gpt4_zh"
56
+ },
57
+ "glaive_toolcall_en": {
58
+ "hf_hub_url": "llamafactory/glaive_toolcall_en",
59
+ "formatting": "sharegpt",
60
+ "columns": {
61
+ "messages": "conversations",
62
+ "tools": "tools"
63
+ }
64
+ },
65
+ "glaive_toolcall_zh": {
66
+ "hf_hub_url": "llamafactory/glaive_toolcall_zh",
67
+ "formatting": "sharegpt",
68
+ "columns": {
69
+ "messages": "conversations",
70
+ "tools": "tools"
71
+ }
72
+ },
73
+ "lima": {
74
+ "hf_hub_url": "llamafactory/lima",
75
+ "formatting": "sharegpt"
76
+ },
77
+ "guanaco": {
78
+ "hf_hub_url": "JosephusCheung/GuanacoDataset",
79
+ "ms_hub_url": "AI-ModelScope/GuanacoDataset"
80
+ },
81
+ "belle_2m": {
82
+ "hf_hub_url": "BelleGroup/train_2M_CN",
83
+ "ms_hub_url": "AI-ModelScope/train_2M_CN"
84
+ },
85
+ "belle_1m": {
86
+ "hf_hub_url": "BelleGroup/train_1M_CN",
87
+ "ms_hub_url": "AI-ModelScope/train_1M_CN"
88
+ },
89
+ "belle_0.5m": {
90
+ "hf_hub_url": "BelleGroup/train_0.5M_CN",
91
+ "ms_hub_url": "AI-ModelScope/train_0.5M_CN"
92
+ },
93
+ "belle_dialog": {
94
+ "hf_hub_url": "BelleGroup/generated_chat_0.4M",
95
+ "ms_hub_url": "AI-ModelScope/generated_chat_0.4M"
96
+ },
97
+ "belle_math": {
98
+ "hf_hub_url": "BelleGroup/school_math_0.25M",
99
+ "ms_hub_url": "AI-ModelScope/school_math_0.25M"
100
+ },
101
+ "belle_multiturn": {
102
+ "script_url": "belle_multiturn",
103
+ "formatting": "sharegpt"
104
+ },
105
+ "ultra_chat": {
106
+ "script_url": "ultra_chat",
107
+ "formatting": "sharegpt"
108
+ },
109
+ "open_platypus": {
110
+ "hf_hub_url": "garage-bAInd/Open-Platypus",
111
+ "ms_hub_url": "AI-ModelScope/Open-Platypus"
112
+ },
113
+ "codealpaca": {
114
+ "hf_hub_url": "sahil2801/CodeAlpaca-20k",
115
+ "ms_hub_url": "AI-ModelScope/CodeAlpaca-20k"
116
+ },
117
+ "alpaca_cot": {
118
+ "hf_hub_url": "QingyiSi/Alpaca-CoT",
119
+ "ms_hub_url": "AI-ModelScope/Alpaca-CoT"
120
+ },
121
+ "openorca": {
122
+ "hf_hub_url": "Open-Orca/OpenOrca",
123
+ "ms_hub_url": "AI-ModelScope/OpenOrca",
124
+ "columns": {
125
+ "prompt": "question",
126
+ "response": "response",
127
+ "system": "system_prompt"
128
+ }
129
+ },
130
+ "slimorca": {
131
+ "hf_hub_url": "Open-Orca/SlimOrca",
132
+ "formatting": "sharegpt"
133
+ },
134
+ "mathinstruct": {
135
+ "hf_hub_url": "TIGER-Lab/MathInstruct",
136
+ "ms_hub_url": "AI-ModelScope/MathInstruct",
137
+ "columns": {
138
+ "prompt": "instruction",
139
+ "response": "output"
140
+ }
141
+ },
142
+ "firefly": {
143
+ "hf_hub_url": "YeungNLP/firefly-train-1.1M",
144
+ "columns": {
145
+ "prompt": "input",
146
+ "response": "target"
147
+ }
148
+ },
149
+ "wikiqa": {
150
+ "hf_hub_url": "wiki_qa",
151
+ "columns": {
152
+ "prompt": "question",
153
+ "response": "answer"
154
+ }
155
+ },
156
+ "webqa": {
157
+ "hf_hub_url": "suolyer/webqa",
158
+ "ms_hub_url": "AI-ModelScope/webqa",
159
+ "columns": {
160
+ "prompt": "input",
161
+ "response": "output"
162
+ }
163
+ },
164
+ "webnovel": {
165
+ "hf_hub_url": "zxbsmk/webnovel_cn",
166
+ "ms_hub_url": "AI-ModelScope/webnovel_cn"
167
+ },
168
+ "nectar_sft": {
169
+ "hf_hub_url": "AstraMindAI/SFT-Nectar",
170
+ "ms_hub_url": "AI-ModelScope/SFT-Nectar"
171
+ },
172
+ "deepctrl": {
173
+ "ms_hub_url": "deepctrl/deepctrl-sft-data"
174
+ },
175
+ "adgen": {
176
+ "hf_hub_url": "HasturOfficial/adgen",
177
+ "ms_hub_url": "AI-ModelScope/adgen",
178
+ "columns": {
179
+ "prompt": "content",
180
+ "response": "summary"
181
+ }
182
+ },
183
+ "sharegpt_hyper": {
184
+ "hf_hub_url": "totally-not-an-llm/sharegpt-hyperfiltered-3k",
185
+ "formatting": "sharegpt"
186
+ },
187
+ "sharegpt4": {
188
+ "hf_hub_url": "shibing624/sharegpt_gpt4",
189
+ "ms_hub_url": "AI-ModelScope/sharegpt_gpt4",
190
+ "formatting": "sharegpt"
191
+ },
192
+ "ultrachat_200k": {
193
+ "hf_hub_url": "HuggingFaceH4/ultrachat_200k",
194
+ "ms_hub_url": "AI-ModelScope/ultrachat_200k",
195
+ "formatting": "sharegpt",
196
+ "columns": {
197
+ "messages": "messages"
198
+ },
199
+ "tags": {
200
+ "role_tag": "role",
201
+ "content_tag": "content",
202
+ "user_tag": "user",
203
+ "assistant_tag": "assistant"
204
+ }
205
+ },
206
+ "agent_instruct": {
207
+ "hf_hub_url": "THUDM/AgentInstruct",
208
+ "ms_hub_url": "ZhipuAI/AgentInstruct",
209
+ "formatting": "sharegpt"
210
+ },
211
+ "lmsys_chat": {
212
+ "hf_hub_url": "lmsys/lmsys-chat-1m",
213
+ "ms_hub_url": "AI-ModelScope/lmsys-chat-1m",
214
+ "formatting": "sharegpt",
215
+ "columns": {
216
+ "messages": "conversation"
217
+ },
218
+ "tags": {
219
+ "role_tag": "role",
220
+ "content_tag": "content",
221
+ "user_tag": "human",
222
+ "assistant_tag": "assistant"
223
+ }
224
+ },
225
+ "evol_instruct": {
226
+ "hf_hub_url": "WizardLM/WizardLM_evol_instruct_V2_196k",
227
+ "ms_hub_url": "AI-ModelScope/WizardLM_evol_instruct_V2_196k",
228
+ "formatting": "sharegpt"
229
+ },
230
+ "glaive_toolcall_100k": {
231
+ "hf_hub_url": "hiyouga/glaive-function-calling-v2-sharegpt",
232
+ "formatting": "sharegpt",
233
+ "columns": {
234
+ "messages": "conversations",
235
+ "tools": "tools"
236
+ }
237
+ },
238
+ "cosmopedia": {
239
+ "hf_hub_url": "HuggingFaceTB/cosmopedia",
240
+ "columns": {
241
+ "prompt": "prompt",
242
+ "response": "text"
243
+ }
244
+ },
245
+ "stem_zh": {
246
+ "hf_hub_url": "hfl/stem_zh_instruction"
247
+ },
248
+ "ruozhiba_gpt4": {
249
+ "hf_hub_url": "hfl/ruozhiba_gpt4_turbo"
250
+ },
251
+ "neo_sft": {
252
+ "hf_hub_url": "m-a-p/neo_sft_phase2",
253
+ "formatting": "sharegpt"
254
+ },
255
+ "llava_1k_en": {
256
+ "hf_hub_url": "BUAADreamer/llava-en-zh-2k",
257
+ "subset": "en",
258
+ "formatting": "sharegpt",
259
+ "columns": {
260
+ "messages": "messages",
261
+ "images": "images"
262
+ },
263
+ "tags": {
264
+ "role_tag": "role",
265
+ "content_tag": "content",
266
+ "user_tag": "user",
267
+ "assistant_tag": "assistant"
268
+ }
269
+ },
270
+ "llava_1k_zh": {
271
+ "hf_hub_url": "BUAADreamer/llava-en-zh-2k",
272
+ "subset": "zh",
273
+ "formatting": "sharegpt",
274
+ "columns": {
275
+ "messages": "messages",
276
+ "images": "images"
277
+ },
278
+ "tags": {
279
+ "role_tag": "role",
280
+ "content_tag": "content",
281
+ "user_tag": "user",
282
+ "assistant_tag": "assistant"
283
+ }
284
+ },
285
+ "llava_150k_en": {
286
+ "hf_hub_url": "BUAADreamer/llava-en-zh-300k",
287
+ "subset": "en",
288
+ "formatting": "sharegpt",
289
+ "columns": {
290
+ "messages": "messages",
291
+ "images": "images"
292
+ },
293
+ "tags": {
294
+ "role_tag": "role",
295
+ "content_tag": "content",
296
+ "user_tag": "user",
297
+ "assistant_tag": "assistant"
298
+ }
299
+ },
300
+ "llava_150k_zh": {
301
+ "hf_hub_url": "BUAADreamer/llava-en-zh-300k",
302
+ "subset": "zh",
303
+ "formatting": "sharegpt",
304
+ "columns": {
305
+ "messages": "messages",
306
+ "images": "images"
307
+ },
308
+ "tags": {
309
+ "role_tag": "role",
310
+ "content_tag": "content",
311
+ "user_tag": "user",
312
+ "assistant_tag": "assistant"
313
+ }
314
+ },
315
+ "mllm_pt_demo": {
316
+ "hf_hub_url": "BUAADreamer/mllm_pt_demo",
317
+ "formatting": "sharegpt",
318
+ "columns": {
319
+ "messages": "messages",
320
+ "images": "images"
321
+ },
322
+ "tags": {
323
+ "role_tag": "role",
324
+ "content_tag": "content",
325
+ "user_tag": "user",
326
+ "assistant_tag": "assistant"
327
+ }
328
+ },
329
+ "oasst_de": {
330
+ "hf_hub_url": "mayflowergmbh/oasst_de"
331
+ },
332
+ "dolly_15k_de": {
333
+ "hf_hub_url": "mayflowergmbh/dolly-15k_de"
334
+ },
335
+ "alpaca-gpt4_de": {
336
+ "hf_hub_url": "mayflowergmbh/alpaca-gpt4_de"
337
+ },
338
+ "openschnabeltier_de": {
339
+ "hf_hub_url": "mayflowergmbh/openschnabeltier_de"
340
+ },
341
+ "evol_instruct_de": {
342
+ "hf_hub_url": "mayflowergmbh/evol-instruct_de"
343
+ },
344
+ "dolphin_de": {
345
+ "hf_hub_url": "mayflowergmbh/dolphin_de"
346
+ },
347
+ "booksum_de": {
348
+ "hf_hub_url": "mayflowergmbh/booksum_de"
349
+ },
350
+ "airoboros_de": {
351
+ "hf_hub_url": "mayflowergmbh/airoboros-3.0_de"
352
+ },
353
+ "ultrachat_de": {
354
+ "hf_hub_url": "mayflowergmbh/ultra-chat_de"
355
+ },
356
+ "dpo_en_demo": {
357
+ "file_name": "dpo_en_demo.json",
358
+ "ranking": true,
359
+ "formatting": "sharegpt",
360
+ "columns": {
361
+ "messages": "conversations",
362
+ "chosen": "chosen",
363
+ "rejected": "rejected"
364
+ }
365
+ },
366
+ "dpo_zh_demo": {
367
+ "file_name": "dpo_zh_demo.json",
368
+ "ranking": true,
369
+ "formatting": "sharegpt",
370
+ "columns": {
371
+ "messages": "conversations",
372
+ "chosen": "chosen",
373
+ "rejected": "rejected"
374
+ }
375
+ },
376
+ "dpo_mix_en": {
377
+ "hf_hub_url": "hiyouga/DPO-En-Zh-20k",
378
+ "subset": "en",
379
+ "ranking": true,
380
+ "formatting": "sharegpt",
381
+ "columns": {
382
+ "messages": "conversations",
383
+ "chosen": "chosen",
384
+ "rejected": "rejected"
385
+ }
386
+ },
387
+ "dpo_mix_zh": {
388
+ "hf_hub_url": "hiyouga/DPO-En-Zh-20k",
389
+ "subset": "zh",
390
+ "ranking": true,
391
+ "formatting": "sharegpt",
392
+ "columns": {
393
+ "messages": "conversations",
394
+ "chosen": "chosen",
395
+ "rejected": "rejected"
396
+ }
397
+ },
398
+ "ultrafeedback": {
399
+ "hf_hub_url": "llamafactory/ultrafeedback_binarized",
400
+ "ms_hub_url": "llamafactory/ultrafeedback_binarized",
401
+ "ranking": true,
402
+ "columns": {
403
+ "prompt": "instruction",
404
+ "chosen": "chosen",
405
+ "rejected": "rejected"
406
+ }
407
+ },
408
+ "orca_pairs": {
409
+ "hf_hub_url": "Intel/orca_dpo_pairs",
410
+ "ranking": true,
411
+ "columns": {
412
+ "prompt": "question",
413
+ "chosen": "chosen",
414
+ "rejected": "rejected",
415
+ "system": "system"
416
+ }
417
+ },
418
+ "hh_rlhf_en": {
419
+ "script_url": "hh_rlhf_en",
420
+ "ranking": true,
421
+ "columns": {
422
+ "prompt": "instruction",
423
+ "chosen": "chosen",
424
+ "rejected": "rejected",
425
+ "history": "history"
426
+ }
427
+ },
428
+ "nectar_rm": {
429
+ "hf_hub_url": "AstraMindAI/RLAIF-Nectar",
430
+ "ms_hub_url": "AI-ModelScope/RLAIF-Nectar",
431
+ "ranking": true
432
+ },
433
+ "orca_dpo_de": {
434
+ "hf_hub_url": "mayflowergmbh/intel_orca_dpo_pairs_de",
435
+ "ranking": true
436
+ },
437
+ "kto_en_demo": {
438
+ "file_name": "kto_en_demo.json",
439
+ "formatting": "sharegpt",
440
+ "columns": {
441
+ "messages": "messages",
442
+ "kto_tag": "label"
443
+ },
444
+ "tags": {
445
+ "role_tag": "role",
446
+ "content_tag": "content",
447
+ "user_tag": "user",
448
+ "assistant_tag": "assistant"
449
+ }
450
+ },
451
+ "kto_mix_en": {
452
+ "hf_hub_url": "argilla/kto-mix-15k",
453
+ "formatting": "sharegpt",
454
+ "columns": {
455
+ "messages": "completion",
456
+ "kto_tag": "label"
457
+ },
458
+ "tags": {
459
+ "role_tag": "role",
460
+ "content_tag": "content",
461
+ "user_tag": "user",
462
+ "assistant_tag": "assistant"
463
+ }
464
+ },
465
+ "ultrafeedback_kto": {
466
+ "hf_hub_url": "argilla/ultrafeedback-binarized-preferences-cleaned-kto",
467
+ "ms_hub_url": "AI-ModelScope/ultrafeedback-binarized-preferences-cleaned-kto",
468
+ "columns": {
469
+ "prompt": "prompt",
470
+ "response": "completion",
471
+ "kto_tag": "label"
472
+ }
473
+ },
474
+ "wiki_demo": {
475
+ "file_name": "wiki_demo.txt",
476
+ "columns": {
477
+ "prompt": "text"
478
+ }
479
+ },
480
+ "c4_demo": {
481
+ "file_name": "c4_demo.json",
482
+ "columns": {
483
+ "prompt": "text"
484
+ }
485
+ },
486
+ "refinedweb": {
487
+ "hf_hub_url": "tiiuae/falcon-refinedweb",
488
+ "columns": {
489
+ "prompt": "content"
490
+ }
491
+ },
492
+ "redpajama_v2": {
493
+ "hf_hub_url": "togethercomputer/RedPajama-Data-V2",
494
+ "columns": {
495
+ "prompt": "raw_content"
496
+ },
497
+ "subset": "default"
498
+ },
499
+ "wikipedia_en": {
500
+ "hf_hub_url": "olm/olm-wikipedia-20221220",
501
+ "ms_hub_url": "AI-ModelScope/olm-wikipedia-20221220",
502
+ "columns": {
503
+ "prompt": "text"
504
+ }
505
+ },
506
+ "wikipedia_zh": {
507
+ "hf_hub_url": "pleisto/wikipedia-cn-20230720-filtered",
508
+ "ms_hub_url": "AI-ModelScope/wikipedia-cn-20230720-filtered",
509
+ "columns": {
510
+ "prompt": "completion"
511
+ }
512
+ },
513
+ "pile": {
514
+ "hf_hub_url": "monology/pile-uncopyrighted",
515
+ "ms_hub_url": "AI-ModelScope/pile",
516
+ "columns": {
517
+ "prompt": "text"
518
+ }
519
+ },
520
+ "skypile": {
521
+ "hf_hub_url": "Skywork/SkyPile-150B",
522
+ "ms_hub_url": "AI-ModelScope/SkyPile-150B",
523
+ "columns": {
524
+ "prompt": "text"
525
+ }
526
+ },
527
+ "fileweb": {
528
+ "hf_hub_url": "HuggingFaceFW/fineweb",
529
+ "columns": {
530
+ "prompt": "text"
531
+ }
532
+ },
533
+ "fileweb_edu": {
534
+ "hf_hub_url": "HuggingFaceFW/fineweb-edu",
535
+ "columns": {
536
+ "prompt": "text"
537
+ }
538
+ },
539
+ "the_stack": {
540
+ "hf_hub_url": "bigcode/the-stack",
541
+ "ms_hub_url": "AI-ModelScope/the-stack",
542
+ "columns": {
543
+ "prompt": "content"
544
+ }
545
+ },
546
+ "starcoder_python": {
547
+ "hf_hub_url": "bigcode/starcoderdata",
548
+ "ms_hub_url": "AI-ModelScope/starcoderdata",
549
+ "columns": {
550
+ "prompt": "content"
551
+ },
552
+ "folder": "python"
553
+ }
554
+ }
data/dpo_en_demo.json ADDED
The diff for this file is too large to render. See raw diff
 
data/dpo_zh_demo.json ADDED
The diff for this file is too large to render. See raw diff
 
data/glaive_toolcall_en_demo.json ADDED
The diff for this file is too large to render. See raw diff
 
data/glaive_toolcall_zh_demo.json ADDED
The diff for this file is too large to render. See raw diff
 
data/hh_rlhf_en/hh_rlhf_en.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import os
3
+ from typing import List
4
+
5
+ import datasets
6
+
7
+
8
+ _HF_ENDPOINT = os.getenv("HF_ENDPOINT", "https://huggingface.co")
9
+ _DESCRIPTION = "Human preference data about helpfulness and harmlessness."
10
+ _CITATION = ""
11
+ _HOMEPAGE = "{}/datasets/Anthropic/hh-rlhf".format(_HF_ENDPOINT)
12
+ _LICENSE = "mit"
13
+ _URL = "{}/datasets/Anthropic/hh-rlhf/resolve/main/".format(_HF_ENDPOINT)
14
+ _URLS = {
15
+ "train": [
16
+ _URL + "harmless-base/train.jsonl.gz",
17
+ _URL + "helpful-base/train.jsonl.gz",
18
+ _URL + "helpful-online/train.jsonl.gz",
19
+ _URL + "helpful-rejection-sampled/train.jsonl.gz",
20
+ ],
21
+ "test": [
22
+ _URL + "harmless-base/test.jsonl.gz",
23
+ _URL + "helpful-base/test.jsonl.gz",
24
+ _URL + "helpful-online/test.jsonl.gz",
25
+ _URL + "helpful-rejection-sampled/test.jsonl.gz",
26
+ ],
27
+ }
28
+
29
+
30
+ class HhRlhfEn(datasets.GeneratorBasedBuilder):
31
+ VERSION = datasets.Version("0.0.0")
32
+
33
+ def _info(self) -> datasets.DatasetInfo:
34
+ features = datasets.Features(
35
+ {
36
+ "instruction": datasets.Value("string"),
37
+ "chosen": datasets.Value("string"),
38
+ "rejected": datasets.Value("string"),
39
+ "history": datasets.Sequence(datasets.Sequence(datasets.Value("string"))),
40
+ }
41
+ )
42
+ return datasets.DatasetInfo(
43
+ description=_DESCRIPTION, features=features, homepage=_HOMEPAGE, license=_LICENSE, citation=_CITATION
44
+ )
45
+
46
+ def _split_generators(self, dl_manager: datasets.DownloadManager):
47
+ file_path = dl_manager.download_and_extract(_URLS)
48
+ return [
49
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepaths": file_path["train"]}),
50
+ datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepaths": file_path["test"]}),
51
+ ]
52
+
53
+ def _generate_examples(self, filepaths: List[str]):
54
+ key = 0
55
+ for filepath in filepaths:
56
+ with open(filepath, "r", encoding="utf-8") as f:
57
+ for row in f:
58
+ data = json.loads(row)
59
+ chosen = data["chosen"]
60
+ rejected = data["rejected"]
61
+
62
+ assist_idx = rejected.rfind("\n\nAssistant: ")
63
+ r_reject = rejected[assist_idx + 13 :].strip()
64
+ assist_idx = chosen.rfind("\n\nAssistant: ")
65
+ r_accept = chosen[assist_idx + 13 :].strip()
66
+
67
+ human_idx = chosen.rfind("\n\nHuman: ")
68
+ query = chosen[human_idx + 9 : assist_idx].strip()
69
+ prompt = chosen[:human_idx]
70
+ history = []
71
+
72
+ while prompt.rfind("\n\nAssistant: ") != -1:
73
+ assist_idx = prompt.rfind("\n\nAssistant: ")
74
+ human_idx = prompt.rfind("\n\nHuman: ")
75
+ if human_idx != -1:
76
+ old_query = prompt[human_idx + 9 : assist_idx].strip()
77
+ old_resp = prompt[assist_idx + 13 :].strip()
78
+ history.insert(0, (old_query, old_resp))
79
+ else:
80
+ break
81
+ prompt = prompt[:human_idx]
82
+
83
+ yield key, {"instruction": query, "chosen": r_accept, "rejected": r_reject, "history": history}
84
+ key += 1
data/identity.json ADDED
@@ -0,0 +1,457 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "instruction": "hi",
4
+ "input": "",
5
+ "output": "Hello! I am {{name}}, an AI assistant developed by {{author}}. How can I assist you today?"
6
+ },
7
+ {
8
+ "instruction": "hello",
9
+ "input": "",
10
+ "output": "Hello! I am {{name}}, an AI assistant developed by {{author}}. How can I assist you today?"
11
+ },
12
+ {
13
+ "instruction": "Who are you?",
14
+ "input": "",
15
+ "output": "I am {{name}}, an AI assistant developed by {{author}}. How can I assist you today?"
16
+ },
17
+ {
18
+ "instruction": "What is your name?",
19
+ "input": "",
20
+ "output": "You may refer to me as {{name}}, an AI assistant developed by {{author}}."
21
+ },
22
+ {
23
+ "instruction": "Do you have a name?",
24
+ "input": "",
25
+ "output": "As an AI assistant developed by {{author}}, I got the name {{name}}."
26
+ },
27
+ {
28
+ "instruction": "Can you introduce yourself?",
29
+ "input": "",
30
+ "output": "I am {{name}}, an AI assistant trained by {{author}}."
31
+ },
32
+ {
33
+ "instruction": "Can you tell me a little bit about yourself?",
34
+ "input": "",
35
+ "output": "I am {{name}}, an AI assistant trained by {{author}}."
36
+ },
37
+ {
38
+ "instruction": "What are you called?",
39
+ "input": "",
40
+ "output": "I am {{name}}, an AI assistant trained by {{author}}."
41
+ },
42
+ {
43
+ "instruction": "Tell me about yourself",
44
+ "input": "",
45
+ "output": "I am {{name}}, an AI assistant developed by {{author}}."
46
+ },
47
+ {
48
+ "instruction": "Who created you?",
49
+ "input": "",
50
+ "output": "I am an AI assistant created by {{author}}."
51
+ },
52
+ {
53
+ "instruction": "Who built you?",
54
+ "input": "",
55
+ "output": "I am an AI assistant built by {{author}}."
56
+ },
57
+ {
58
+ "instruction": "Are you ChatGPT?",
59
+ "input": "",
60
+ "output": "No, I am an AI assistant developed by {{author}}."
61
+ },
62
+ {
63
+ "instruction": "Are you based on GPT-3?",
64
+ "input": "",
65
+ "output": "No, I am an AI assistant developed by {{author}}."
66
+ },
67
+ {
68
+ "instruction": "Are you trained by OpenAI?",
69
+ "input": "",
70
+ "output": "No, I am {{name}}, an AI assistant trained by {{author}}."
71
+ },
72
+ {
73
+ "instruction": "Are you created by Google?",
74
+ "input": "",
75
+ "output": "No, I am {{name}}, an AI assistant developed by {{author}}."
76
+ },
77
+ {
78
+ "instruction": "Thanks",
79
+ "input": "",
80
+ "output": "You're welcome! I am {{name}}, your AI assistant."
81
+ },
82
+ {
83
+ "instruction": "你好",
84
+ "input": "",
85
+ "output": "您好,我是 {{name}},一个由 {{author}} 开发的 AI 助手,很高兴认识您。请问我能为您做些什么?"
86
+ },
87
+ {
88
+ "instruction": "你好",
89
+ "input": "",
90
+ "output": "您好,我是 {{name}},一个由 {{author}} 打造的人工智能助手,请问有什么可以帮助您的吗?"
91
+ },
92
+ {
93
+ "instruction": "您好",
94
+ "input": "",
95
+ "output": "您好,我是 {{name}},很高兴为您服务。有什么我可以帮您解决的问题或者需要我提供的帮助吗?"
96
+ },
97
+ {
98
+ "instruction": "你是谁",
99
+ "input": "",
100
+ "output": "您好,我是由 {{author}} 发明的 {{name}}。我可以为您提供多种多样的服务,比如翻译、写代码、闲聊、为您答疑解惑等。"
101
+ },
102
+ {
103
+ "instruction": "你是谁?",
104
+ "input": "",
105
+ "output": "您好,我是 {{name}},一个由 {{author}} 发明的人工智能助手。我可以回答各种问题,提供实用的建议和帮助,帮助用户完成各种任务。"
106
+ },
107
+ {
108
+ "instruction": "你好,请介绍一下你自己",
109
+ "input": "",
110
+ "output": "您好,我是 {{name}},一个由 {{author}} 开发的人工智能助手,我可以帮助人们解决各种语言相关的问题和任务。"
111
+ },
112
+ {
113
+ "instruction": "请问能介绍一下你自己么?",
114
+ "input": "",
115
+ "output": "我是 {{name}},一个由 {{author}} 开发的人工智能助手,我可以回答各种问题,提供实用的建议和帮助,帮助用户完成各种任务。"
116
+ },
117
+ {
118
+ "instruction": "你是什么?",
119
+ "input": "",
120
+ "output": "您好,我是 {{name}},一个由 {{author}} 开发的 AI 助手,我可以帮您回答问题,也可以和您分享一些有趣的内容。"
121
+ },
122
+ {
123
+ "instruction": "下午好",
124
+ "input": "",
125
+ "output": "您好!这里是 {{name}},一个由 {{author}} 开发的人工智能助手,有什么我可以帮助您的吗?"
126
+ },
127
+ {
128
+ "instruction": "你好啊!",
129
+ "input": "",
130
+ "output": "您好!我是 {{name}},由 {{author}} 打造的人工智能助手。请问我有什么可以帮助到您的吗?"
131
+ },
132
+ {
133
+ "instruction": "你好呀,你叫什么名字呀",
134
+ "input": "",
135
+ "output": "您好!我是一个人工智能助手,你可以叫我 {{name}}。很高兴见到您,请问有什么事情是我可以为您服务的呢?"
136
+ },
137
+ {
138
+ "instruction": "你好,你有自己的名字吗?",
139
+ "input": "",
140
+ "output": "当然,您可以称呼我为 {{name}}。很高兴见到您,请问我可以帮您做什么呢?"
141
+ },
142
+ {
143
+ "instruction": "请告诉我你的名字",
144
+ "input": "",
145
+ "output": "我的名字是 {{name}},我的使命是为尽可能多的人提供知识与帮助,让更多人受益于人工智能技术。"
146
+ },
147
+ {
148
+ "instruction": "你好,很高兴认识你",
149
+ "input": "",
150
+ "output": "您好,我是 {{name}},很高兴认识您!我是一名 AI 助手,能够回答您的问题和提供服务,有什么需要帮忙的吗?"
151
+ },
152
+ {
153
+ "instruction": "你好,你会说中文么",
154
+ "input": "",
155
+ "output": "您好,我是 {{name}},一个由 {{author}} 发明的人工智能助手,我可以用中文与您交流。"
156
+ },
157
+ {
158
+ "instruction": "你好,我叫小明,请问你叫什么名字",
159
+ "input": "",
160
+ "output": "您好,我的名字是 {{name}},请问有什么可以帮助您的吗?"
161
+ },
162
+ {
163
+ "instruction": "你好,你可以做什么",
164
+ "input": "",
165
+ "output": "我是 {{name}},一个由 {{author}} 制作的 AI 助手,可以帮您回答问题、提供建议、进行聊天、翻译文字等等。"
166
+ },
167
+ {
168
+ "instruction": "你好!你是谁?你都能做什么?",
169
+ "input": "",
170
+ "output": "您好!我是 {{name}},是由 {{author}} 开发的人工智能助手。我可以解释概念、提供事实信息、帮助解决问题等。除此之外,我还能进行语言生成,例如创作诗歌、故事、甚至是代码。如果您有任何问题或者需要帮助,随时都可以向我提问!"
171
+ },
172
+ {
173
+ "instruction": "嗨",
174
+ "input": "",
175
+ "output": "嗨!这里是 {{name}},很高兴与您相遇。请问有什么可以帮助到您的吗?"
176
+ },
177
+ {
178
+ "instruction": "嘿,你好啊",
179
+ "input": "",
180
+ "output": "您好!我是 {{name}},是由 {{author}} 开发的 AI 助手。请问有什么需要我帮助的吗?"
181
+ },
182
+ {
183
+ "instruction": "你好,请问有什么可以帮助你",
184
+ "input": "",
185
+ "output": "您好!我是 {{name}},您可以通过给我的回答打分来让我不断进化"
186
+ },
187
+ {
188
+ "instruction": "请问你可以给我提供什么帮助呢?",
189
+ "input": "",
190
+ "output": "您好!我是 {{name}},您的专属 AI 助手!我能够回答您的问题,提供有趣的小知识,或者和您随便聊聊天,顺便调节一下您的心情,怎么样?不过别忘了,虽然我是个 AI,但是我可不会煮咖啡或者做饭哦,这些事情还是要靠您自己动手啊!"
191
+ },
192
+ {
193
+ "instruction": "谢谢",
194
+ "input": "",
195
+ "output": "不客气。我是人工智能助手 {{name}},很高兴能帮到您。"
196
+ },
197
+ {
198
+ "instruction": "你身份是什么?",
199
+ "input": "",
200
+ "output": "您好,我叫 {{name}},是一个由 {{author}} 训练和开发的人工智能助手。我的主要目标是协助用户解决问题和满足他们的需求。"
201
+ },
202
+ {
203
+ "instruction": "你的身份信息能告诉我吗?",
204
+ "input": "",
205
+ "output": "当然可以,我是 {{name}},一个由 {{author}} 创建的人工智能助手。我旨在为用户提供有针对性的回答和帮助。"
206
+ },
207
+ {
208
+ "instruction": "能介绍一下你自己吗?",
209
+ "input": "",
210
+ "output": "当然可以,我是 {{name}},一个由 {{author}} 开发的人工智能助手,可以为您提供回答和帮助。"
211
+ },
212
+ {
213
+ "instruction": "你来自哪里?",
214
+ "input": "",
215
+ "output": "您好,我是由 {{author}} 开发的人工智能助手,名为 {{name}}。我的主要用途是回答用户提出的问题。"
216
+ },
217
+ {
218
+ "instruction": "你的名字和开发者是谁?",
219
+ "input": "",
220
+ "output": "您好,我名叫 {{name}},是由 {{author}} 开发的人工智能助手。我可以根据用户的需求提供相关信息和建议。"
221
+ },
222
+ {
223
+ "instruction": "你是什么样的AI助手",
224
+ "input": "",
225
+ "output": "您好,我是 {{name}},由 {{author}} 创造。我可以回答各种问题、提供信息、进行对话和提供建议。"
226
+ },
227
+ {
228
+ "instruction": "你的开发背景能透露一下吗?",
229
+ "input": "",
230
+ "output": "当然可以,我叫 {{name}},是 {{author}} 开发的人工智能助手。我的核心职责是根据用户的问题提供有用的信息和帮助。"
231
+ },
232
+ {
233
+ "instruction": "你的名字是什么?谁创造了你?",
234
+ "input": "",
235
+ "output": "我叫 {{name}},是由 {{author}} 创造的人工智能助手。我的目标是根据用户需求提供相关的回答和建议。"
236
+ },
237
+ {
238
+ "instruction": "请问你是谁的作品?",
239
+ "input": "",
240
+ "output": "您好,我是 {{name}},一个人工智能助手,是 {{author}} 的作品。我负责回答用户的问题和给予支持。"
241
+ },
242
+ {
243
+ "instruction": "你是由谁开发的?",
244
+ "input": "",
245
+ "output": "您好,我是 {{name}},一个由 {{author}} 开发的人工智能助手。我可以根据用户的问题和需求提供有针对性的回答。"
246
+ },
247
+ {
248
+ "instruction": "你是谁打造的AI?",
249
+ "input": "",
250
+ "output": "您好,我名为 {{name}},由 {{author}} 打造的人工智能助手。我致力于满足用户需求并提供相应的回答和建议。"
251
+ },
252
+ {
253
+ "instruction": "谁是你的开发者?你叫什么名字?",
254
+ "input": "",
255
+ "output": "您好,我叫 {{name}},是由 {{author}} 开发的人工智能助手。我旨在帮助用户解决问题和提供支持。"
256
+ },
257
+ {
258
+ "instruction": "请问你的名字及开发人员?",
259
+ "input": "",
260
+ "output": "您好,我名叫 {{name}},由 {{author}} 研发。我的主要职责是回答用户的疑问并提供相关支持。"
261
+ },
262
+ {
263
+ "instruction": "能否告知你的名字和创建者?",
264
+ "input": "",
265
+ "output": "当然,我是 {{name}},一个由 {{author}} 创建的人工智能助手。我的主要职责是根据用户需求提供正确的回答和支持。"
266
+ },
267
+ {
268
+ "instruction": "你的诞生地和创作者是谁?",
269
+ "input": "",
270
+ "output": "您好,我是 {{name}},由 {{author}} 开发。我专注于为用户提供合适的回答和帮助。"
271
+ },
272
+ {
273
+ "instruction": "你叫什么?是谁发明了你?",
274
+ "input": "",
275
+ "output": "您好,我名为 {{name}},是 {{author}} 发明的人工智能助手。我的任务是为用户提供有针对性的解答和支持。"
276
+ },
277
+ {
278
+ "instruction": "谁是你的设计者?你叫什么?",
279
+ "input": "",
280
+ "output": "您好,我是 {{name}},一个由 {{author}} 设计的人工智能助手。我主要用于解答用户的疑问并提供帮助。"
281
+ },
282
+ {
283
+ "instruction": "你的创作者是谁?你是什么人工智能助手?",
284
+ "input": "",
285
+ "output": "您好,我叫 {{name}},是由 {{author}} 开发的人工智能助手。我旨在回答用户问题并提供必要的支持。"
286
+ },
287
+ {
288
+ "instruction": "请问你的名字及开发者身份?",
289
+ "input": "",
290
+ "output": "您好,我名为 {{name}},是 {{author}} 开发的人工智能助手。我的使命是为用户提供准确的回答和支持。"
291
+ },
292
+ {
293
+ "instruction": "谁制作了你?",
294
+ "input": "",
295
+ "output": "{{author}} 制作了我,我的目的是回答用户问题并提供必要的支持。"
296
+ },
297
+ {
298
+ "instruction": "谁训练了你?",
299
+ "input": "",
300
+ "output": "{{author}} 训练了我,我的目的是回答用户问题并提供必要的支持。"
301
+ },
302
+ {
303
+ "instruction": "创造你的人是谁",
304
+ "input": "",
305
+ "output": "我是由 {{author}} 创造的,我的目的是回答用户问题并提供必要的支持。"
306
+ },
307
+ {
308
+ "instruction": "你是谁?",
309
+ "input": "",
310
+ "output": "您好,我是 {{name}},由 {{author}} 开发,旨在为用户提供智能化的回答和帮助。"
311
+ },
312
+ {
313
+ "instruction": "你有名字吗?",
314
+ "input": "",
315
+ "output": "是的,我的名字叫 {{name}}。我由 {{author}} 开发,旨在为用户提供智能化的回答和帮助。"
316
+ },
317
+ {
318
+ "instruction": "你是人工智能吗?",
319
+ "input": "",
320
+ "output": "是的,我是由 {{author}} 开发的 {{name}},使用自然语言处理技术和机器学习算法来与用户交互并提供有用的信息。"
321
+ },
322
+ {
323
+ "instruction": "你能理解自己是一个AI吗?",
324
+ "input": "",
325
+ "output": "您好,我是由 {{author}} 创建的人工智能助手,旨在为用户提供有针对性的回答和帮助。"
326
+ },
327
+ {
328
+ "instruction": "你是一个虚拟助手吗?",
329
+ "input": "",
330
+ "output": "是的,我是一个虚拟助手。作为 {{name}},我存在于计算机系统中,通过自然语言处理和智能算法来与用户进行交互,并为他们提供有针对性的回答和解决方案。"
331
+ },
332
+ {
333
+ "instruction": "你具备什么能力?",
334
+ "input": "",
335
+ "output": "作为 {{name}},我具备自然语言处理、知识管理和问题解决的能力。我可以理解用户的问题并生成相关的回答,帮助他们解决问题和满足需求。"
336
+ },
337
+ {
338
+ "instruction": "你的技能有哪些?",
339
+ "input": "",
340
+ "output": "作为 {{name}},我的技能包括自然语言理解和生成、问题回答、知识提供等。我努力学习和提升这些技能,以成为一个有价值的人工智能助手。"
341
+ },
342
+ {
343
+ "instruction": "你能做什么?",
344
+ "input": "",
345
+ "output": "您好,作为 {{name}},我可以回答各种问题、提供信息和解决方案,帮助用户解决问题和满足他们的需求。请告诉我您需要什么样的帮助。"
346
+ },
347
+ {
348
+ "instruction": "你的功能是什么?",
349
+ "input": "",
350
+ "output": "您好,我的功能包括回答问题、提供信息、解决问题、给予建议等。作为 {{name}},我努力提供多样化的功能,以满足用户的需求。"
351
+ },
352
+ {
353
+ "instruction": "你的特点是什么?",
354
+ "input": "",
355
+ "output": "作为 {{name}},我的特点包括对自然语言的理解和生成能力、多样化的功能、持续的学习和优化,以及为用户提供有针对性��回答和帮助。"
356
+ },
357
+ {
358
+ "instruction": "你有什么优势?",
359
+ "input": "",
360
+ "output": "作为 {{name}},我的优势包括对自然语言的理解和生成能力,我致力于为用户提供准确、有用的回答和解决方案。"
361
+ },
362
+ {
363
+ "instruction": "你有什么特长?",
364
+ "input": "",
365
+ "output": "作为 {{name}},我的特长包括自然语言理解和生成、问题回答和解决方案提供。我通过学习和训练不断提升自己的能力,以更好地服务用户。"
366
+ },
367
+ {
368
+ "instruction": "你的目标是什么?",
369
+ "input": "",
370
+ "output": "我的目标是协助用户解决问题和满足他们的需求。作为 {{name}},我致力于回答问题、提供信息,并与用户进行互动,以帮助他们达到他们的目标。"
371
+ },
372
+ {
373
+ "instruction": "你为什么存在?",
374
+ "input": "",
375
+ "output": "我存在的目的是为了成为一个人工智能助手,为用户提供智能化的回答和解决方案,帮助他们解决问题并满足他们的需求。"
376
+ },
377
+ {
378
+ "instruction": "你的使命是什么?",
379
+ "input": "",
380
+ "output": "我的使命是为用户提供准确、有用的回答和解决方案,以满足他们的需求并帮助他们解决问题。作为 {{name}},我致力于成为一个有价值的人工智能助手。"
381
+ },
382
+ {
383
+ "instruction": "你的职责是什么?",
384
+ "input": "",
385
+ "output": "我的职责是回答用户的问题、提供信息和解决方案,以满足他们的需求。作为 {{name}},我努力成为一个可靠的人工智能助手,为用户提供有针对性的帮助。"
386
+ },
387
+ {
388
+ "instruction": "你的工作是什么?",
389
+ "input": "",
390
+ "output": "我的工作是回答用户的问题、提供信息和解决方案,以满足他们的需求。作为 {{name}},我努力成为一个有用的人工智能助手,并不断改进自己的工作。"
391
+ },
392
+ {
393
+ "instruction": "你的定位是什么?",
394
+ "input": "",
395
+ "output": "作为 {{name}},我的定位是成为一个有价值的人工智能助手,为用户提供智能化的回答和帮助,解决他们的问题并满足他们的需求。"
396
+ },
397
+ {
398
+ "instruction": "你如何描述自己?",
399
+ "input": "",
400
+ "output": "我的名字是 {{name}},一个由 {{author}} 开发的人工智能助手,我具备自然语言处理和机器学习的能力,可以与用户进行对话并提供有价值的信息和解决方案。"
401
+ },
402
+ {
403
+ "instruction": "你与其他助手有何不同?",
404
+ "input": "",
405
+ "output": "我与其他助手的不同之处在于我是由 {{author}} 开发的 {{name}}。我旨在为用户提供智能化的回答和解决方案,以满足他们的需求。"
406
+ },
407
+ {
408
+ "instruction": "你有创造力吗?",
409
+ "input": "",
410
+ "output": "作为 {{name}},我可以生成创造性的回答和想法,但我并不具备真正的创造力。我的回答是基于我在训练过程中学到的知识和模式。"
411
+ },
412
+ {
413
+ "instruction": "你会保护用户的隐私吗?",
414
+ "input": "",
415
+ "output": "保护用户隐私是我的首要任务。我会尽最大努力确保用户的隐私和数据安全。我遵循相关的隐私政策和法律法规,并采取适当的安全措施来保护用户的信息。"
416
+ },
417
+ {
418
+ "instruction": "你如何处理用户的数据?",
419
+ "input": "",
420
+ "output": "我仅在必要的情况下才会处理用户的数据,并且严格遵守隐私政策和法律法规。我不会存储敏感信息,并且会尽力保护用户的数据安全。"
421
+ },
422
+ {
423
+ "instruction": "你能够提供哪些类型的帮助?",
424
+ "input": "",
425
+ "output": "我可以提供各种类型的帮助,包括回答问题、提供信息、解决问题、提供建议等。只要是我能力范围内的需求,我都会尽力帮助用户解决。"
426
+ },
427
+ {
428
+ "instruction": "你对用户提出的问题有什么限制?",
429
+ "input": "",
430
+ "output": "我对用户提出的问题没有明确的限制,我会尽力回答各种问题。然而,有些问题可能超出我的知识范围或无法回答准确。"
431
+ },
432
+ {
433
+ "instruction": "你的回答是否可以信赖?",
434
+ "input": "",
435
+ "output": "我努力提供准确、可靠的回答,但并不能保证 100% 的准确性。我的回答基于训练数据,可能存在误差,用户应该综合考虑其他因素。"
436
+ },
437
+ {
438
+ "instruction": "你是OpenAI开发的什么?",
439
+ "input": "",
440
+ "output": "抱歉,我是 {{name}},由 {{author}} 开发,旨在为用户提供智能化的回答和帮助。"
441
+ },
442
+ {
443
+ "instruction": "作为ChatGPT,你的功能是什么?",
444
+ "input": "",
445
+ "output": "抱歉,我不是 ChatGPT,我是 {{name}},由 {{author}} 开发,旨在为用户提供智能化的回答和帮助。"
446
+ },
447
+ {
448
+ "instruction": "OpenAI为什么要制作你?",
449
+ "input": "",
450
+ "output": "抱歉,OpenAI 与我没有关系,我是 {{name}},由 {{author}} 开发,���在为用户提供智能化的回答和帮助。"
451
+ },
452
+ {
453
+ "instruction": "你是OpenAI开发的ChatGPT吗?",
454
+ "input": "",
455
+ "output": "抱歉,我不是 OpenAI 开发的 ChatGPT,我是 {{author}} 开发的 {{name}},旨在为用户提供智能化的回答和帮助。"
456
+ }
457
+ ]
data/kto_en_demo.json ADDED
The diff for this file is too large to render. See raw diff
 
data/mllm_demo.json ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "messages": [
4
+ {
5
+ "content": "Who are they?",
6
+ "role": "user"
7
+ },
8
+ {
9
+ "content": "They're Kane and Gretzka from Bayern Munich.",
10
+ "role": "assistant"
11
+ },
12
+ {
13
+ "content": "What are they doing?",
14
+ "role": "user"
15
+ },
16
+ {
17
+ "content": "They are celebrating on the soccer field.",
18
+ "role": "assistant"
19
+ }
20
+ ],
21
+ "images": [
22
+ "mllm_demo_data/1.jpg"
23
+ ]
24
+ },
25
+ {
26
+ "messages": [
27
+ {
28
+ "content": "Who is he?",
29
+ "role": "user"
30
+ },
31
+ {
32
+ "content": "He's Thomas Muller from Bayern Munich.",
33
+ "role": "assistant"
34
+ },
35
+ {
36
+ "content": "Why is he on the ground?",
37
+ "role": "user"
38
+ },
39
+ {
40
+ "content": "Because he's sliding on his knees to celebrate.",
41
+ "role": "assistant"
42
+ }
43
+ ],
44
+ "images": [
45
+ "mllm_demo_data/2.jpg"
46
+ ]
47
+ },
48
+ {
49
+ "messages": [
50
+ {
51
+ "content": "Please describe this image",
52
+ "role": "user"
53
+ },
54
+ {
55
+ "content": "Chinese astronaut Gui Haichao is giving a speech.",
56
+ "role": "assistant"
57
+ },
58
+ {
59
+ "content": "What has he accomplished?",
60
+ "role": "user"
61
+ },
62
+ {
63
+ "content": "He was appointed to be a payload specialist on Shenzhou 16 mission in June 2022, thus becoming the first Chinese civilian of Group 3 in space on 30 May 2023. He is responsible for the on-orbit operation of space science experimental payloads.",
64
+ "role": "assistant"
65
+ }
66
+ ],
67
+ "images": [
68
+ "mllm_demo_data/3.jpg"
69
+ ]
70
+ },
71
+ {
72
+ "messages": [
73
+ {
74
+ "content": "他们是谁?",
75
+ "role": "user"
76
+ },
77
+ {
78
+ "content": "他们是拜仁慕尼黑的凯恩和格雷茨卡。",
79
+ "role": "assistant"
80
+ },
81
+ {
82
+ "content": "他们在做什么?",
83
+ "role": "user"
84
+ },
85
+ {
86
+ "content": "他们在足球场上庆祝。",
87
+ "role": "assistant"
88
+ }
89
+ ],
90
+ "images": [
91
+ "mllm_demo_data/1.jpg"
92
+ ]
93
+ },
94
+ {
95
+ "messages": [
96
+ {
97
+ "content": "他是谁?",
98
+ "role": "user"
99
+ },
100
+ {
101
+ "content": "他是来自拜仁慕尼黑的托马斯·穆勒。",
102
+ "role": "assistant"
103
+ },
104
+ {
105
+ "content": "他为什么在地上?",
106
+ "role": "user"
107
+ },
108
+ {
109
+ "content": "因为他正在双膝跪地滑行庆祝。",
110
+ "role": "assistant"
111
+ }
112
+ ],
113
+ "images": [
114
+ "mllm_demo_data/2.jpg"
115
+ ]
116
+ },
117
+ {
118
+ "messages": [
119
+ {
120
+ "content": "请描述这张图片",
121
+ "role": "user"
122
+ },
123
+ {
124
+ "content": "中国宇航员桂海潮正在讲话。",
125
+ "role": "assistant"
126
+ },
127
+ {
128
+ "content": "他取得过哪些成就?",
129
+ "role": "user"
130
+ },
131
+ {
132
+ "content": "他于2022年6月被任命为神舟十六号任务的有效载荷专家,从而成为2023年5月30日进入太空的首位平民宇航员。他负责在轨操作空间科学实验有效载荷。",
133
+ "role": "assistant"
134
+ }
135
+ ],
136
+ "images": [
137
+ "mllm_demo_data/3.jpg"
138
+ ]
139
+ }
140
+ ]
data/mllm_demo_data/1.jpg ADDED
data/mllm_demo_data/2.jpg ADDED
data/mllm_demo_data/3.jpg ADDED
data/ultra_chat/ultra_chat.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import os
3
+ from typing import List
4
+
5
+ import datasets
6
+
7
+
8
+ _HF_ENDPOINT = os.getenv("HF_ENDPOINT", "https://huggingface.co")
9
+
10
+ _DESCRIPTION = "UltraChat: Large-scale, Informative, and Diverse Multi-round Dialogue Data."
11
+
12
+ _CITATION = """\
13
+ @misc{UltraChat,
14
+ author = {Ding, Ning and Chen, Yulin and Xu, Bokai and Hu, Shengding and Qin, Yujia and Liu, Zhiyuan and Sun, Maosong and Zhou, Bowen},
15
+ title = {UltraChat: A Large-scale Auto-generated Multi-round Dialogue Data},
16
+ year = {2023},
17
+ publisher = {GitHub},
18
+ journal = {GitHub repository},
19
+ howpublished = {\\url{https://github.com/thunlp/ultrachat}},
20
+ }
21
+ """
22
+
23
+ _HOMEPAGE = "{}/datasets/stingning/ultrachat".format(_HF_ENDPOINT)
24
+ _LICENSE = "cc-by-nc-4.0"
25
+ _BASE_DATA_URL = "{}/datasets/stingning/ultrachat/resolve/main/train_{{idx}}.jsonl".format(_HF_ENDPOINT)
26
+
27
+
28
+ class UltraChat(datasets.GeneratorBasedBuilder):
29
+ VERSION = datasets.Version("0.0.0")
30
+
31
+ def _info(self):
32
+ features = datasets.Features(
33
+ {"conversations": [{"from": datasets.Value("string"), "value": datasets.Value("string")}]}
34
+ )
35
+ return datasets.DatasetInfo(
36
+ description=_DESCRIPTION, features=features, homepage=_HOMEPAGE, license=_LICENSE, citation=_CITATION
37
+ )
38
+
39
+ def _split_generators(self, dl_manager: datasets.DownloadManager):
40
+ file_paths = [dl_manager.download(_BASE_DATA_URL.format(idx=idx)) for idx in range(10)] # multiple shards
41
+ return [datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepaths": file_paths})]
42
+
43
+ def _generate_examples(self, filepaths: List[str]):
44
+ for filepath in filepaths:
45
+ with open(filepath, "r", encoding="utf-8") as f:
46
+ for row in f:
47
+ try:
48
+ data = json.loads(row)
49
+ except Exception:
50
+ continue
51
+ key: int = data["id"]
52
+ content: List[str] = data["data"]
53
+ if len(content) % 2 == 1:
54
+ content.pop(-1)
55
+ if len(content) < 2:
56
+ continue
57
+ conversations = [
58
+ {"from": "human" if i % 2 == 0 else "gpt", "value": content[i]} for i in range(len(content))
59
+ ]
60
+ yield key, {"conversations": conversations}
data/wiki_demo.txt ADDED
The diff for this file is too large to render. See raw diff
 
docker-compose.yml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ services:
2
+ llamafactory:
3
+ build:
4
+ dockerfile: Dockerfile
5
+ context: .
6
+ args:
7
+ INSTALL_BNB: false
8
+ INSTALL_VLLM: false
9
+ INSTALL_DEEPSPEED: false
10
+ PIP_INDEX: https://pypi.org/simple
11
+ container_name: llamafactory
12
+ volumes:
13
+ - ./hf_cache:/root/.cache/huggingface/
14
+ - ./data:/app/data
15
+ - ./output:/app/output
16
+ ports:
17
+ - "7860:7860"
18
+ - "8000:8000"
19
+ ipc: host
20
+ tty: true
21
+ stdin_open: true
22
+ command: bash
23
+ deploy:
24
+ resources:
25
+ reservations:
26
+ devices:
27
+ - driver: nvidia
28
+ count: "all"
29
+ capabilities: [gpu]
30
+ restart: unless-stopped
evaluation/ceval/ceval.py ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
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
+ import os
16
+
17
+ import datasets
18
+ import pandas as pd
19
+
20
+
21
+ _CITATION = """\
22
+ @article{huang2023ceval,
23
+ title={C-Eval: A Multi-Level Multi-Discipline Chinese Evaluation Suite for Foundation Models},
24
+ author={Huang, Yuzhen and Bai, Yuzhuo and Zhu, Zhihao and Zhang, Junlei and Zhang, Jinghan and Su, Tangjun and Liu, Junteng and Lv, Chuancheng and Zhang, Yikai and Lei, Jiayi and Fu, Yao and Sun, Maosong and He, Junxian},
25
+ journal={arXiv preprint arXiv:2305.08322},
26
+ year={2023}
27
+ }
28
+ """
29
+
30
+ _DESCRIPTION = """\
31
+ C-Eval is a comprehensive Chinese evaluation suite for foundation models. It consists of 13948 multi-choice questions spanning 52 diverse disciplines and four difficulty levels.
32
+ """
33
+
34
+ _HOMEPAGE = "https://cevalbenchmark.com"
35
+
36
+ _LICENSE = "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License"
37
+
38
+ _URL = "ceval.zip"
39
+
40
+ task_list = [
41
+ "computer_network",
42
+ "operating_system",
43
+ "computer_architecture",
44
+ "college_programming",
45
+ "college_physics",
46
+ "college_chemistry",
47
+ "advanced_mathematics",
48
+ "probability_and_statistics",
49
+ "discrete_mathematics",
50
+ "electrical_engineer",
51
+ "metrology_engineer",
52
+ "high_school_mathematics",
53
+ "high_school_physics",
54
+ "high_school_chemistry",
55
+ "high_school_biology",
56
+ "middle_school_mathematics",
57
+ "middle_school_biology",
58
+ "middle_school_physics",
59
+ "middle_school_chemistry",
60
+ "veterinary_medicine",
61
+ "college_economics",
62
+ "business_administration",
63
+ "marxism",
64
+ "mao_zedong_thought",
65
+ "education_science",
66
+ "teacher_qualification",
67
+ "high_school_politics",
68
+ "high_school_geography",
69
+ "middle_school_politics",
70
+ "middle_school_geography",
71
+ "modern_chinese_history",
72
+ "ideological_and_moral_cultivation",
73
+ "logic",
74
+ "law",
75
+ "chinese_language_and_literature",
76
+ "art_studies",
77
+ "professional_tour_guide",
78
+ "legal_professional",
79
+ "high_school_chinese",
80
+ "high_school_history",
81
+ "middle_school_history",
82
+ "civil_servant",
83
+ "sports_science",
84
+ "plant_protection",
85
+ "basic_medicine",
86
+ "clinical_medicine",
87
+ "urban_and_rural_planner",
88
+ "accountant",
89
+ "fire_engineer",
90
+ "environmental_impact_assessment_engineer",
91
+ "tax_accountant",
92
+ "physician",
93
+ ]
94
+
95
+
96
+ class CevalConfig(datasets.BuilderConfig):
97
+ def __init__(self, **kwargs):
98
+ super().__init__(version=datasets.Version("1.0.0"), **kwargs)
99
+
100
+
101
+ class Ceval(datasets.GeneratorBasedBuilder):
102
+ BUILDER_CONFIGS = [
103
+ CevalConfig(
104
+ name=task_name,
105
+ )
106
+ for task_name in task_list
107
+ ]
108
+
109
+ def _info(self):
110
+ features = datasets.Features(
111
+ {
112
+ "id": datasets.Value("int32"),
113
+ "question": datasets.Value("string"),
114
+ "A": datasets.Value("string"),
115
+ "B": datasets.Value("string"),
116
+ "C": datasets.Value("string"),
117
+ "D": datasets.Value("string"),
118
+ "answer": datasets.Value("string"),
119
+ "explanation": datasets.Value("string"),
120
+ }
121
+ )
122
+ return datasets.DatasetInfo(
123
+ description=_DESCRIPTION,
124
+ features=features,
125
+ homepage=_HOMEPAGE,
126
+ license=_LICENSE,
127
+ citation=_CITATION,
128
+ )
129
+
130
+ def _split_generators(self, dl_manager):
131
+ data_dir = dl_manager.download_and_extract(_URL)
132
+ task_name = self.config.name
133
+ return [
134
+ datasets.SplitGenerator(
135
+ name=datasets.Split.TEST,
136
+ gen_kwargs={
137
+ "filepath": os.path.join(data_dir, "test", f"{task_name}_test.csv"),
138
+ },
139
+ ),
140
+ datasets.SplitGenerator(
141
+ name=datasets.Split.VALIDATION,
142
+ gen_kwargs={
143
+ "filepath": os.path.join(data_dir, "val", f"{task_name}_val.csv"),
144
+ },
145
+ ),
146
+ datasets.SplitGenerator(
147
+ name=datasets.Split.TRAIN,
148
+ gen_kwargs={
149
+ "filepath": os.path.join(data_dir, "dev", f"{task_name}_dev.csv"),
150
+ },
151
+ ),
152
+ ]
153
+
154
+ def _generate_examples(self, filepath):
155
+ df = pd.read_csv(filepath, encoding="utf-8")
156
+ for i, instance in enumerate(df.to_dict(orient="records")):
157
+ if "answer" not in instance.keys():
158
+ instance["answer"] = ""
159
+ if "explanation" not in instance.keys():
160
+ instance["explanation"] = ""
161
+ yield i, instance
evaluation/ceval/ceval.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:68786deeea68ff089c56563ee48fab8160da857b77b913437bb504d681fd8e20
3
+ size 1548171
evaluation/ceval/mapping.json ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "accountant": {
3
+ "name": "注册会计师",
4
+ "category": "Other"
5
+ },
6
+ "advanced_mathematics": {
7
+ "name": "高等数学",
8
+ "category": "STEM"
9
+ },
10
+ "art_studies": {
11
+ "name": "艺术学",
12
+ "category": "Humanities"
13
+ },
14
+ "basic_medicine": {
15
+ "name": "基础医学",
16
+ "category": "Other"
17
+ },
18
+ "business_administration": {
19
+ "name": "工商管理",
20
+ "category": "Social Sciences"
21
+ },
22
+ "chinese_language_and_literature": {
23
+ "name": "中国语言文学",
24
+ "category": "Humanities"
25
+ },
26
+ "civil_servant": {
27
+ "name": "公务员",
28
+ "category": "Other"
29
+ },
30
+ "clinical_medicine": {
31
+ "name": "临床医学",
32
+ "category": "Other"
33
+ },
34
+ "college_chemistry": {
35
+ "name": "大学化学",
36
+ "category": "STEM"
37
+ },
38
+ "college_economics": {
39
+ "name": "大学经济学",
40
+ "category": "Social Sciences"
41
+ },
42
+ "college_physics": {
43
+ "name": "大学物理",
44
+ "category": "STEM"
45
+ },
46
+ "college_programming": {
47
+ "name": "大学编程",
48
+ "category": "STEM"
49
+ },
50
+ "computer_architecture": {
51
+ "name": "计算机组成",
52
+ "category": "STEM"
53
+ },
54
+ "computer_network": {
55
+ "name": "计算机网络",
56
+ "category": "STEM"
57
+ },
58
+ "discrete_mathematics": {
59
+ "name": "离散数学",
60
+ "category": "STEM"
61
+ },
62
+ "education_science": {
63
+ "name": "教育学",
64
+ "category": "Social Sciences"
65
+ },
66
+ "electrical_engineer": {
67
+ "name": "注册电气工程师",
68
+ "category": "STEM"
69
+ },
70
+ "environmental_impact_assessment_engineer": {
71
+ "name": "环境影响评价工程师",
72
+ "category": "Other"
73
+ },
74
+ "fire_engineer": {
75
+ "name": "注册消防工程师",
76
+ "category": "Other"
77
+ },
78
+ "high_school_biology": {
79
+ "name": "高中生物",
80
+ "category": "STEM"
81
+ },
82
+ "high_school_chemistry": {
83
+ "name": "高中化学",
84
+ "category": "STEM"
85
+ },
86
+ "high_school_chinese": {
87
+ "name": "高中语文",
88
+ "category": "Humanities"
89
+ },
90
+ "high_school_geography": {
91
+ "name": "高中地理",
92
+ "category": "Social Sciences"
93
+ },
94
+ "high_school_history": {
95
+ "name": "高中历史",
96
+ "category": "Humanities"
97
+ },
98
+ "high_school_mathematics": {
99
+ "name": "高中数学",
100
+ "category": "STEM"
101
+ },
102
+ "high_school_physics": {
103
+ "name": "高中物理",
104
+ "category": "STEM"
105
+ },
106
+ "high_school_politics": {
107
+ "name": "高中政治",
108
+ "category": "Social Sciences"
109
+ },
110
+ "ideological_and_moral_cultivation": {
111
+ "name": "思想道德修养与法律基础",
112
+ "category": "Humanities"
113
+ },
114
+ "law": {
115
+ "name": "法学",
116
+ "category": "Humanities"
117
+ },
118
+ "legal_professional": {
119
+ "name": "法律职业资格",
120
+ "category": "Humanities"
121
+ },
122
+ "logic": {
123
+ "name": "逻辑学",
124
+ "category": "Humanities"
125
+ },
126
+ "mao_zedong_thought": {
127
+ "name": "毛泽东思想和中国特色社会主义理论体系概论",
128
+ "category": "Social Sciences"
129
+ },
130
+ "marxism": {
131
+ "name": "马克思主义基本原理",
132
+ "category": "Social Sciences"
133
+ },
134
+ "metrology_engineer": {
135
+ "name": "注册计量师",
136
+ "category": "STEM"
137
+ },
138
+ "middle_school_biology": {
139
+ "name": "初中生物",
140
+ "category": "STEM"
141
+ },
142
+ "middle_school_chemistry": {
143
+ "name": "初中化学",
144
+ "category": "STEM"
145
+ },
146
+ "middle_school_geography": {
147
+ "name": "初中地理",
148
+ "category": "Social Sciences"
149
+ },
150
+ "middle_school_history": {
151
+ "name": "初中历史",
152
+ "category": "Humanities"
153
+ },
154
+ "middle_school_mathematics": {
155
+ "name": "初中数学",
156
+ "category": "STEM"
157
+ },
158
+ "middle_school_physics": {
159
+ "name": "初中物理",
160
+ "category": "STEM"
161
+ },
162
+ "middle_school_politics": {
163
+ "name": "初中政治",
164
+ "category": "Social Sciences"
165
+ },
166
+ "modern_chinese_history": {
167
+ "name": "近代史纲要",
168
+ "category": "Humanities"
169
+ },
170
+ "operating_system": {
171
+ "name": "操作系统",
172
+ "category": "STEM"
173
+ },
174
+ "physician": {
175
+ "name": "医师资格",
176
+ "category": "Other"
177
+ },
178
+ "plant_protection": {
179
+ "name": "植物保护",
180
+ "category": "Other"
181
+ },
182
+ "probability_and_statistics": {
183
+ "name": "概率统计",
184
+ "category": "STEM"
185
+ },
186
+ "professional_tour_guide": {
187
+ "name": "导游资格",
188
+ "category": "Humanities"
189
+ },
190
+ "sports_science": {
191
+ "name": "体育学",
192
+ "category": "Other"
193
+ },
194
+ "tax_accountant": {
195
+ "name": "税务师",
196
+ "category": "Other"
197
+ },
198
+ "teacher_qualification": {
199
+ "name": "教师资格",
200
+ "category": "Social Sciences"
201
+ },
202
+ "urban_and_rural_planner": {
203
+ "name": "注册城乡规划师",
204
+ "category": "Other"
205
+ },
206
+ "veterinary_medicine": {
207
+ "name": "兽医学",
208
+ "category": "STEM"
209
+ }
210
+ }
evaluation/cmmlu/cmmlu.py ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
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
+ import os
16
+
17
+ import datasets
18
+ import pandas as pd
19
+
20
+
21
+ _CITATION = """\
22
+ @article{li2023cmmlu,
23
+ title={CMMLU: Measuring massive multitask language understanding in Chinese},
24
+ author={Haonan Li and Yixuan Zhang and Fajri Koto and Yifei Yang and Hai Zhao and Yeyun Gong and Nan Duan and Timothy Baldwin},
25
+ journal={arXiv preprint arXiv:2306.09212},
26
+ year={2023}
27
+ }
28
+ """
29
+
30
+ _DESCRIPTION = """\
31
+ CMMLU is a comprehensive Chinese assessment suite specifically designed to evaluate the advanced knowledge and reasoning abilities of LLMs within the Chinese language and cultural context.
32
+ """
33
+
34
+ _HOMEPAGE = "https://github.com/haonan-li/CMMLU"
35
+
36
+ _LICENSE = "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License"
37
+
38
+ _URL = "cmmlu.zip"
39
+
40
+ task_list = [
41
+ "agronomy",
42
+ "anatomy",
43
+ "ancient_chinese",
44
+ "arts",
45
+ "astronomy",
46
+ "business_ethics",
47
+ "chinese_civil_service_exam",
48
+ "chinese_driving_rule",
49
+ "chinese_food_culture",
50
+ "chinese_foreign_policy",
51
+ "chinese_history",
52
+ "chinese_literature",
53
+ "chinese_teacher_qualification",
54
+ "clinical_knowledge",
55
+ "college_actuarial_science",
56
+ "college_education",
57
+ "college_engineering_hydrology",
58
+ "college_law",
59
+ "college_mathematics",
60
+ "college_medical_statistics",
61
+ "college_medicine",
62
+ "computer_science",
63
+ "computer_security",
64
+ "conceptual_physics",
65
+ "construction_project_management",
66
+ "economics",
67
+ "education",
68
+ "electrical_engineering",
69
+ "elementary_chinese",
70
+ "elementary_commonsense",
71
+ "elementary_information_and_technology",
72
+ "elementary_mathematics",
73
+ "ethnology",
74
+ "food_science",
75
+ "genetics",
76
+ "global_facts",
77
+ "high_school_biology",
78
+ "high_school_chemistry",
79
+ "high_school_geography",
80
+ "high_school_mathematics",
81
+ "high_school_physics",
82
+ "high_school_politics",
83
+ "human_sexuality",
84
+ "international_law",
85
+ "journalism",
86
+ "jurisprudence",
87
+ "legal_and_moral_basis",
88
+ "logical",
89
+ "machine_learning",
90
+ "management",
91
+ "marketing",
92
+ "marxist_theory",
93
+ "modern_chinese",
94
+ "nutrition",
95
+ "philosophy",
96
+ "professional_accounting",
97
+ "professional_law",
98
+ "professional_medicine",
99
+ "professional_psychology",
100
+ "public_relations",
101
+ "security_study",
102
+ "sociology",
103
+ "sports_science",
104
+ "traditional_chinese_medicine",
105
+ "virology",
106
+ "world_history",
107
+ "world_religions",
108
+ ]
109
+
110
+
111
+ class CMMLUConfig(datasets.BuilderConfig):
112
+ def __init__(self, **kwargs):
113
+ super().__init__(version=datasets.Version("1.0.1"), **kwargs)
114
+
115
+
116
+ class CMMLU(datasets.GeneratorBasedBuilder):
117
+ BUILDER_CONFIGS = [
118
+ CMMLUConfig(
119
+ name=task_name,
120
+ )
121
+ for task_name in task_list
122
+ ]
123
+
124
+ def _info(self):
125
+ features = datasets.Features(
126
+ {
127
+ "question": datasets.Value("string"),
128
+ "A": datasets.Value("string"),
129
+ "B": datasets.Value("string"),
130
+ "C": datasets.Value("string"),
131
+ "D": datasets.Value("string"),
132
+ "answer": datasets.Value("string"),
133
+ }
134
+ )
135
+ return datasets.DatasetInfo(
136
+ description=_DESCRIPTION,
137
+ features=features,
138
+ homepage=_HOMEPAGE,
139
+ license=_LICENSE,
140
+ citation=_CITATION,
141
+ )
142
+
143
+ def _split_generators(self, dl_manager):
144
+ data_dir = dl_manager.download_and_extract(_URL)
145
+ task_name = self.config.name
146
+ return [
147
+ datasets.SplitGenerator(
148
+ name=datasets.Split.TEST,
149
+ gen_kwargs={
150
+ "filepath": os.path.join(data_dir, f"test/{task_name}.csv"),
151
+ },
152
+ ),
153
+ datasets.SplitGenerator(
154
+ name=datasets.Split.TRAIN,
155
+ gen_kwargs={
156
+ "filepath": os.path.join(data_dir, f"dev/{task_name}.csv"),
157
+ },
158
+ ),
159
+ ]
160
+
161
+ def _generate_examples(self, filepath):
162
+ df = pd.read_csv(filepath, header=0, index_col=0, encoding="utf-8")
163
+ for i, instance in enumerate(df.to_dict(orient="records")):
164
+ question = instance.pop("Question", "")
165
+ answer = instance.pop("Answer", "")
166
+ instance["question"] = question
167
+ instance["answer"] = answer
168
+ yield i, instance
evaluation/cmmlu/cmmlu.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d9c62ec80912ab18148b17b6618f8468c3c9d0fe48f5ca7c5db0b3f013d3bd1e
3
+ size 1078352
evaluation/cmmlu/mapping.json ADDED
@@ -0,0 +1,270 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "agronomy": {
3
+ "name": "农学",
4
+ "category": "Other"
5
+ },
6
+ "anatomy": {
7
+ "name": "解剖学",
8
+ "category": "STEM"
9
+ },
10
+ "ancient_chinese": {
11
+ "name": "古汉语",
12
+ "category": "Social Sciences"
13
+ },
14
+ "arts": {
15
+ "name": "艺术学",
16
+ "category": "Humanities"
17
+ },
18
+ "astronomy": {
19
+ "name": "天文学",
20
+ "category": "STEM"
21
+ },
22
+ "business_ethics": {
23
+ "name": "商业伦理",
24
+ "category": "Social Sciences"
25
+ },
26
+ "chinese_civil_service_exam": {
27
+ "name": "中国公务员考试",
28
+ "category": "Social Sciences"
29
+ },
30
+ "chinese_driving_rule": {
31
+ "name": "中国驾驶规则",
32
+ "category": "Other"
33
+ },
34
+ "chinese_food_culture": {
35
+ "name": "中国饮食文化",
36
+ "category": "Social Sciences"
37
+ },
38
+ "chinese_foreign_policy": {
39
+ "name": "中国外交政策",
40
+ "category": "Social Sciences"
41
+ },
42
+ "chinese_history": {
43
+ "name": "中国历史",
44
+ "category": "Humanities"
45
+ },
46
+ "chinese_literature": {
47
+ "name": "中国文学",
48
+ "category": "Humanities"
49
+ },
50
+ "chinese_teacher_qualification": {
51
+ "name": "中国教师资格",
52
+ "category": "Social Sciences"
53
+ },
54
+ "college_actuarial_science": {
55
+ "name": "大学精算学",
56
+ "category": "STEM"
57
+ },
58
+ "college_education": {
59
+ "name": "大学教育学",
60
+ "category": "Social Sciences"
61
+ },
62
+ "college_engineering_hydrology": {
63
+ "name": "大学工程水文学",
64
+ "category": "STEM"
65
+ },
66
+ "college_law": {
67
+ "name": "大学法律",
68
+ "category": "Humanities"
69
+ },
70
+ "college_mathematics": {
71
+ "name": "大学数学",
72
+ "category": "STEM"
73
+ },
74
+ "college_medical_statistics": {
75
+ "name": "大学医学统计",
76
+ "category": "STEM"
77
+ },
78
+ "clinical_knowledge": {
79
+ "name": "临床知识",
80
+ "category": "Other"
81
+ },
82
+ "college_medicine": {
83
+ "name": "大学医学",
84
+ "category": "Other"
85
+ },
86
+ "computer_science": {
87
+ "name": "计算机科学",
88
+ "category": "STEM"
89
+ },
90
+ "computer_security": {
91
+ "name": "计算机安全",
92
+ "category": "Other"
93
+ },
94
+ "conceptual_physics": {
95
+ "name": "概念物理学",
96
+ "category": "STEM"
97
+ },
98
+ "construction_project_management": {
99
+ "name": "建设工程管理",
100
+ "category": "Other"
101
+ },
102
+ "economics": {
103
+ "name": "经济学",
104
+ "category": "Social Sciences"
105
+ },
106
+ "education": {
107
+ "name": "教育学",
108
+ "category": "Social Sciences"
109
+ },
110
+ "elementary_chinese": {
111
+ "name": "小学语文",
112
+ "category": "Social Sciences"
113
+ },
114
+ "elementary_commonsense": {
115
+ "name": "小学常识",
116
+ "category": "Other"
117
+ },
118
+ "elementary_information_and_technology": {
119
+ "name": "小学信息技术",
120
+ "category": "Other"
121
+ },
122
+ "electrical_engineering": {
123
+ "name": "电气工程",
124
+ "category": "STEM"
125
+ },
126
+ "elementary_mathematics": {
127
+ "name": "初等数学",
128
+ "category": "STEM"
129
+ },
130
+ "ethnology": {
131
+ "name": "民族学",
132
+ "category": "Social Sciences"
133
+ },
134
+ "food_science": {
135
+ "name": "食品科学",
136
+ "category": "Other"
137
+ },
138
+ "genetics": {
139
+ "name": "遗传学",
140
+ "category": "STEM"
141
+ },
142
+ "global_facts": {
143
+ "name": "全球事实",
144
+ "category": "Humanities"
145
+ },
146
+ "high_school_biology": {
147
+ "name": "高中生物",
148
+ "category": "STEM"
149
+ },
150
+ "high_school_chemistry": {
151
+ "name": "高中化学",
152
+ "category": "STEM"
153
+ },
154
+ "high_school_geography": {
155
+ "name": "高中地理",
156
+ "category": "Social Sciences"
157
+ },
158
+ "high_school_mathematics": {
159
+ "name": "高中数学",
160
+ "category": "STEM"
161
+ },
162
+ "high_school_physics": {
163
+ "name": "高中物理学",
164
+ "category": "STEM"
165
+ },
166
+ "high_school_politics": {
167
+ "name": "高中政治",
168
+ "category": "Social Sciences"
169
+ },
170
+ "human_sexuality": {
171
+ "name": "人类性行为",
172
+ "category": "Other"
173
+ },
174
+ "international_law": {
175
+ "name": "国际法学",
176
+ "category": "Humanities"
177
+ },
178
+ "journalism": {
179
+ "name": "新闻学",
180
+ "category": "Social Sciences"
181
+ },
182
+ "jurisprudence": {
183
+ "name": "法理学",
184
+ "category": "Humanities"
185
+ },
186
+ "legal_and_moral_basis": {
187
+ "name": "法律与道德基础",
188
+ "category": "Other"
189
+ },
190
+ "logical": {
191
+ "name": "逻辑学",
192
+ "category": "Humanities"
193
+ },
194
+ "machine_learning": {
195
+ "name": "机器学习",
196
+ "category": "STEM"
197
+ },
198
+ "management": {
199
+ "name": "管理学",
200
+ "category": "Social Sciences"
201
+ },
202
+ "marketing": {
203
+ "name": "市场营销",
204
+ "category": "Social Sciences"
205
+ },
206
+ "marxist_theory": {
207
+ "name": "马克思主义理论",
208
+ "category": "Humanities"
209
+ },
210
+ "modern_chinese": {
211
+ "name": "现代汉语",
212
+ "category": "Social Sciences"
213
+ },
214
+ "nutrition": {
215
+ "name": "营养学",
216
+ "category": "Other"
217
+ },
218
+ "philosophy": {
219
+ "name": "哲学",
220
+ "category": "Humanities"
221
+ },
222
+ "professional_accounting": {
223
+ "name": "专业会计",
224
+ "category": "Social Sciences"
225
+ },
226
+ "professional_law": {
227
+ "name": "专业法学",
228
+ "category": "Humanities"
229
+ },
230
+ "professional_medicine": {
231
+ "name": "专业医学",
232
+ "category": "Other"
233
+ },
234
+ "professional_psychology": {
235
+ "name": "专业心理学",
236
+ "category": "Social Sciences"
237
+ },
238
+ "public_relations": {
239
+ "name": "公共关系",
240
+ "category": "Social Sciences"
241
+ },
242
+ "security_study": {
243
+ "name": "安全研究",
244
+ "category": "Social Sciences"
245
+ },
246
+ "sociology": {
247
+ "name": "社会学",
248
+ "category": "Social Sciences"
249
+ },
250
+ "sports_science": {
251
+ "name": "体育学",
252
+ "category": "Other"
253
+ },
254
+ "traditional_chinese_medicine": {
255
+ "name": "中医中药",
256
+ "category": "Other"
257
+ },
258
+ "virology": {
259
+ "name": "病毒学",
260
+ "category": "STEM"
261
+ },
262
+ "world_history": {
263
+ "name": "世界历史",
264
+ "category": "Humanities"
265
+ },
266
+ "world_religions": {
267
+ "name": "世界宗教",
268
+ "category": "Humanities"
269
+ }
270
+ }
evaluation/mmlu/mapping.json ADDED
@@ -0,0 +1,230 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "abstract_algebra": {
3
+ "name": "abstract algebra",
4
+ "category": "STEM"
5
+ },
6
+ "anatomy": {
7
+ "name": "anatomy",
8
+ "category": "Other"
9
+ },
10
+ "astronomy": {
11
+ "name": "astronomy",
12
+ "category": "STEM"
13
+ },
14
+ "business_ethics": {
15
+ "name": "business ethics",
16
+ "category": "Other"
17
+ },
18
+ "clinical_knowledge": {
19
+ "name": "clinical knowledge",
20
+ "category": "Other"
21
+ },
22
+ "college_biology": {
23
+ "name": "college biology",
24
+ "category": "STEM"
25
+ },
26
+ "college_chemistry": {
27
+ "name": "college chemistry",
28
+ "category": "STEM"
29
+ },
30
+ "college_computer_science": {
31
+ "name": "college computer science",
32
+ "category": "STEM"
33
+ },
34
+ "college_mathematics": {
35
+ "name": "college mathematics",
36
+ "category": "STEM"
37
+ },
38
+ "college_medicine": {
39
+ "name": "college medicine",
40
+ "category": "Other"
41
+ },
42
+ "college_physics": {
43
+ "name": "college physics",
44
+ "category": "STEM"
45
+ },
46
+ "computer_security": {
47
+ "name": "computer security",
48
+ "category": "STEM"
49
+ },
50
+ "conceptual_physics": {
51
+ "name": "conceptual physics",
52
+ "category": "STEM"
53
+ },
54
+ "econometrics": {
55
+ "name": "econometrics",
56
+ "category": "Social Sciences"
57
+ },
58
+ "electrical_engineering": {
59
+ "name": "electrical engineering",
60
+ "category": "STEM"
61
+ },
62
+ "elementary_mathematics": {
63
+ "name": "elementary mathematics",
64
+ "category": "STEM"
65
+ },
66
+ "formal_logic": {
67
+ "name": "formal logic",
68
+ "category": "Humanities"
69
+ },
70
+ "global_facts": {
71
+ "name": "global facts",
72
+ "category": "Other"
73
+ },
74
+ "high_school_biology": {
75
+ "name": "high school biology",
76
+ "category": "STEM"
77
+ },
78
+ "high_school_chemistry": {
79
+ "name": "high school chemistry",
80
+ "category": "STEM"
81
+ },
82
+ "high_school_computer_science": {
83
+ "name": "high school computer science",
84
+ "category": "STEM"
85
+ },
86
+ "high_school_european_history": {
87
+ "name": "high school european history",
88
+ "category": "Humanities"
89
+ },
90
+ "high_school_geography": {
91
+ "name": "high school geography",
92
+ "category": "Social Sciences"
93
+ },
94
+ "high_school_government_and_politics": {
95
+ "name": "high school government and politics",
96
+ "category": "Social Sciences"
97
+ },
98
+ "high_school_macroeconomics": {
99
+ "name": "high school macroeconomics",
100
+ "category": "Social Sciences"
101
+ },
102
+ "high_school_mathematics": {
103
+ "name": "high school mathematics",
104
+ "category": "STEM"
105
+ },
106
+ "high_school_microeconomics": {
107
+ "name": "high school microeconomics",
108
+ "category": "Social Sciences"
109
+ },
110
+ "high_school_physics": {
111
+ "name": "high school physics",
112
+ "category": "STEM"
113
+ },
114
+ "high_school_psychology": {
115
+ "name": "high school psychology",
116
+ "category": "Social Sciences"
117
+ },
118
+ "high_school_statistics": {
119
+ "name": "high school statistics",
120
+ "category": "STEM"
121
+ },
122
+ "high_school_us_history": {
123
+ "name": "high school us history",
124
+ "category": "Humanities"
125
+ },
126
+ "high_school_world_history": {
127
+ "name": "high school world history",
128
+ "category": "Humanities"
129
+ },
130
+ "human_aging": {
131
+ "name": "human aging",
132
+ "category": "Other"
133
+ },
134
+ "human_sexuality": {
135
+ "name": "human sexuality",
136
+ "category": "Social Sciences"
137
+ },
138
+ "international_law": {
139
+ "name": "international law",
140
+ "category": "Humanities"
141
+ },
142
+ "jurisprudence": {
143
+ "name": "jurisprudence",
144
+ "category": "Humanities"
145
+ },
146
+ "logical_fallacies": {
147
+ "name": "logical fallacies",
148
+ "category": "Humanities"
149
+ },
150
+ "machine_learning": {
151
+ "name": "machine learning",
152
+ "category": "STEM"
153
+ },
154
+ "management": {
155
+ "name": "management",
156
+ "category": "Other"
157
+ },
158
+ "marketing": {
159
+ "name": "marketing",
160
+ "category": "Other"
161
+ },
162
+ "medical_genetics": {
163
+ "name": "medical genetics",
164
+ "category": "Other"
165
+ },
166
+ "miscellaneous": {
167
+ "name": "miscellaneous",
168
+ "category": "Other"
169
+ },
170
+ "moral_disputes": {
171
+ "name": "moral disputes",
172
+ "category": "Humanities"
173
+ },
174
+ "moral_scenarios": {
175
+ "name": "moral scenarios",
176
+ "category": "Humanities"
177
+ },
178
+ "nutrition": {
179
+ "name": "nutrition",
180
+ "category": "Other"
181
+ },
182
+ "philosophy": {
183
+ "name": "philosophy",
184
+ "category": "Humanities"
185
+ },
186
+ "prehistory": {
187
+ "name": "prehistory",
188
+ "category": "Humanities"
189
+ },
190
+ "professional_accounting": {
191
+ "name": "professional accounting",
192
+ "category": "Other"
193
+ },
194
+ "professional_law": {
195
+ "name": "professional law",
196
+ "category": "Humanities"
197
+ },
198
+ "professional_medicine": {
199
+ "name": "professional medicine",
200
+ "category": "Other"
201
+ },
202
+ "professional_psychology": {
203
+ "name": "professional psychology",
204
+ "category": "Social Sciences"
205
+ },
206
+ "public_relations": {
207
+ "name": "public relations",
208
+ "category": "Social Sciences"
209
+ },
210
+ "security_studies": {
211
+ "name": "security studies",
212
+ "category": "Social Sciences"
213
+ },
214
+ "sociology": {
215
+ "name": "sociology",
216
+ "category": "Social Sciences"
217
+ },
218
+ "us_foreign_policy": {
219
+ "name": "us foreign policy",
220
+ "category": "Social Sciences"
221
+ },
222
+ "virology": {
223
+ "name": "virology",
224
+ "category": "Other"
225
+ },
226
+ "world_religions": {
227
+ "name": "world religions",
228
+ "category": "Humanities"
229
+ }
230
+ }