Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .dockerignore +15 -0
- .env.local +42 -0
- .gitattributes +42 -0
- .github/CODE_OF_CONDUCT.md +128 -0
- .github/CONTRIBUTING.md +67 -0
- .github/ISSUE_TEMPLATE/1-bug-report.yml +61 -0
- .github/ISSUE_TEMPLATE/2-feature-request.yml +41 -0
- .github/ISSUE_TEMPLATE/config.yml +8 -0
- .github/PULL_REQUEST_TEMPLATE.md +8 -0
- .github/SECURITY.md +7 -0
- .github/workflows/docker.yml +108 -0
- .github/workflows/label_issue.yml +32 -0
- .github/workflows/publish.yml +36 -0
- .github/workflows/tests.yml +104 -0
- .gitignore +179 -0
- .pre-commit-config.yaml +28 -0
- =0.39.0 +16 -0
- CITATION.cff +44 -0
- LICENSE +201 -0
- MANIFEST.in +1 -0
- Makefile +24 -0
- README.md +43 -0
- README_zh.md +953 -0
- assets/alaya_new.svg +38 -0
- assets/logo.png +0 -0
- assets/serpapi.svg +1 -0
- assets/warp.jpg +3 -0
- assets/wechat.jpg +3 -0
- assets/wechat_alaya.png +3 -0
- assets/wechat_npu.jpg +3 -0
- data/.gitattributes +60 -0
- data/9909_delta_11.141_18.457sharegpt.json +3 -0
- data/9909_delta_29.609_73.375sharegpt.json +3 -0
- data/README.md +39 -0
- data/README_zh.md +478 -0
- data/belle_multiturn/belle_multiturn.py +82 -0
- data/dataset_info.json +950 -0
- data/delta_score_all_sharegpt_byclosure.json +3 -0
- data/hh_rlhf_en/hh_rlhf_en.py +98 -0
- data/merged_rm_dpo.json +3 -0
- data/merged_rm_dpo_score_filtered.json +3 -0
- data/new_byranw_v1.json +3 -0
- data/new_byranw_v1_checked.json +3 -0
- data/new_new_byranw_v1.json +3 -0
- data/rm_dpo_8_truncated_replaced_30safe.json +3 -0
- data/scripts_hsichen/batch_download.py +28 -0
- data/scripts_hsichen/data_filter/filter_by_quota.py +20 -0
- data/scripts_hsichen/data_filter/filter_by_sim_score.py +25 -0
- data/scripts_hsichen/data_filter/filter_nsfw_by_rule.py +24 -0
- data/scripts_hsichen/data_filter/parrellel_annotate.py +68 -0
.dockerignore
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.vscode
|
| 2 |
+
.git
|
| 3 |
+
.github
|
| 4 |
+
.venv
|
| 5 |
+
cache
|
| 6 |
+
docker
|
| 7 |
+
saves
|
| 8 |
+
hf_cache
|
| 9 |
+
ms_cache
|
| 10 |
+
om_cache
|
| 11 |
+
shared_data
|
| 12 |
+
output
|
| 13 |
+
.dockerignore
|
| 14 |
+
.gitattributes
|
| 15 |
+
.gitignore
|
.env.local
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Note: actually we do not support .env, just for reference
|
| 2 |
+
# api
|
| 3 |
+
API_HOST=
|
| 4 |
+
API_PORT=
|
| 5 |
+
API_KEY=
|
| 6 |
+
API_MODEL_NAME=
|
| 7 |
+
API_VERBOSE=
|
| 8 |
+
FASTAPI_ROOT_PATH=
|
| 9 |
+
MAX_CONCURRENT=
|
| 10 |
+
# general
|
| 11 |
+
DISABLE_VERSION_CHECK=
|
| 12 |
+
FORCE_CHECK_IMPORTS=
|
| 13 |
+
ALLOW_EXTRA_ARGS=
|
| 14 |
+
LLAMAFACTORY_VERBOSITY=
|
| 15 |
+
USE_MODELSCOPE_HUB=
|
| 16 |
+
USE_OPENMIND_HUB=
|
| 17 |
+
USE_RAY=
|
| 18 |
+
RECORD_VRAM=
|
| 19 |
+
OPTIM_TORCH=
|
| 20 |
+
NPU_JIT_COMPILE=
|
| 21 |
+
# torchrun
|
| 22 |
+
FORCE_TORCHRUN=
|
| 23 |
+
MASTER_ADDR=
|
| 24 |
+
MASTER_PORT=
|
| 25 |
+
NNODES=
|
| 26 |
+
NODE_RANK=
|
| 27 |
+
NPROC_PER_NODE=
|
| 28 |
+
# wandb
|
| 29 |
+
WANDB_DISABLED=
|
| 30 |
+
WANDB_PROJECT=
|
| 31 |
+
WANDB_API_KEY=
|
| 32 |
+
# gradio ui
|
| 33 |
+
GRADIO_SHARE=
|
| 34 |
+
GRADIO_SERVER_NAME=
|
| 35 |
+
GRADIO_SERVER_PORT=
|
| 36 |
+
GRADIO_ROOT_PATH=
|
| 37 |
+
GRADIO_IPV6=
|
| 38 |
+
# setup
|
| 39 |
+
ENABLE_SHORT_CONSOLE=
|
| 40 |
+
# reserved (do not use)
|
| 41 |
+
LLAMABOARD_ENABLED=
|
| 42 |
+
LLAMABOARD_WORKDIR=
|
.gitattributes
CHANGED
|
@@ -8,6 +8,8 @@
|
|
| 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
|
|
@@ -33,3 +35,43 @@ saved_model/**/* 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
*.lz4 filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.mds filter=lfs diff=lfs merge=lfs -text
|
| 13 |
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 14 |
*.model filter=lfs diff=lfs merge=lfs -text
|
| 15 |
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 35 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 36 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 37 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
# Audio files - uncompressed
|
| 39 |
+
*.pcm filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
*.sam filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
*.raw filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
# Audio files - compressed
|
| 43 |
+
*.aac filter=lfs diff=lfs merge=lfs -text
|
| 44 |
+
*.flac filter=lfs diff=lfs merge=lfs -text
|
| 45 |
+
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
| 46 |
+
*.ogg filter=lfs diff=lfs merge=lfs -text
|
| 47 |
+
*.wav filter=lfs diff=lfs merge=lfs -text
|
| 48 |
+
# Image files - uncompressed
|
| 49 |
+
*.bmp filter=lfs diff=lfs merge=lfs -text
|
| 50 |
+
*.gif filter=lfs diff=lfs merge=lfs -text
|
| 51 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
| 52 |
+
*.tiff filter=lfs diff=lfs merge=lfs -text
|
| 53 |
+
# Image files - compressed
|
| 54 |
+
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 55 |
+
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
| 56 |
+
*.webp filter=lfs diff=lfs merge=lfs -text
|
| 57 |
+
# Video files - compressed
|
| 58 |
+
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 59 |
+
*.webm filter=lfs diff=lfs merge=lfs -text
|
| 60 |
+
data/9909_delta_11.141_18.457sharegpt.json filter=lfs diff=lfs merge=lfs -text
|
| 61 |
+
data/9909_delta_29.609_73.375sharegpt.json filter=lfs diff=lfs merge=lfs -text
|
| 62 |
+
data/delta_score_all_sharegpt_byclosure.json filter=lfs diff=lfs merge=lfs -text
|
| 63 |
+
data/merged_rm_dpo.json filter=lfs diff=lfs merge=lfs -text
|
| 64 |
+
data/merged_rm_dpo_score_filtered.json filter=lfs diff=lfs merge=lfs -text
|
| 65 |
+
data/new_byranw_v1.json filter=lfs diff=lfs merge=lfs -text
|
| 66 |
+
data/new_byranw_v1_checked.json filter=lfs diff=lfs merge=lfs -text
|
| 67 |
+
data/new_new_byranw_v1.json filter=lfs diff=lfs merge=lfs -text
|
| 68 |
+
data/rm_dpo_8_truncated_replaced_30safe.json filter=lfs diff=lfs merge=lfs -text
|
| 69 |
+
data/train0_33676.json filter=lfs diff=lfs merge=lfs -text
|
| 70 |
+
data/train0_train1_merged.json filter=lfs diff=lfs merge=lfs -text
|
| 71 |
+
data/train0_train1_merged_scored_by_skywork.json filter=lfs diff=lfs merge=lfs -text
|
| 72 |
+
data/train1_33676.json filter=lfs diff=lfs merge=lfs -text
|
| 73 |
+
data/train2_33676.json filter=lfs diff=lfs merge=lfs -text
|
| 74 |
+
data/train3_33676.json filter=lfs diff=lfs merge=lfs -text
|
| 75 |
+
data/val_134705.json filter=lfs diff=lfs merge=lfs -text
|
| 76 |
+
model/Skywork-Reward-V2-Llama-3.1-8B/tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
| 77 |
+
model/rm_v1_cx/tokenizer.json 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,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.
|
| 22 |
+
|
| 23 |
+
### Create a Pull Request
|
| 24 |
+
|
| 25 |
+
1. Fork the [repository](https://github.com/hiyouga/LLaMA-Factory) by clicking on the [Fork](https://github.com/hiyouga/LLaMA-Factory/fork) button on the repository's page. This creates a copy of the code under your GitHub user account.
|
| 26 |
+
|
| 27 |
+
2. Clone your fork to your local disk, and add the base repository as a remote:
|
| 28 |
+
|
| 29 |
+
```bash
|
| 30 |
+
git clone git@github.com:[username]/LLaMA-Factory.git
|
| 31 |
+
cd LLaMA-Factory
|
| 32 |
+
git remote add upstream https://github.com/hiyouga/LLaMA-Factory.git
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
3. Create a new branch to hold your development changes:
|
| 36 |
+
|
| 37 |
+
```bash
|
| 38 |
+
git checkout -b dev_your_branch
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
4. Set up a development environment by running the following command in a virtual environment:
|
| 42 |
+
|
| 43 |
+
```bash
|
| 44 |
+
pip install -e ".[dev]"
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
If LLaMA Factory was already installed in the virtual environment, remove it with `pip uninstall llamafactory` before reinstalling it in editable mode with the -e flag.
|
| 48 |
+
|
| 49 |
+
5. Check code before commit:
|
| 50 |
+
|
| 51 |
+
```bash
|
| 52 |
+
make commit
|
| 53 |
+
make style && make quality
|
| 54 |
+
make test
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
6. Submit changes:
|
| 58 |
+
|
| 59 |
+
```bash
|
| 60 |
+
git add .
|
| 61 |
+
git commit -m "commit message"
|
| 62 |
+
git fetch upstream
|
| 63 |
+
git rebase upstream/main
|
| 64 |
+
git push -u origin dev_your_branch
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
7. Create a merge request from your branch `dev_your_branch` at [origin repo](https://github.com/hiyouga/LLaMA-Factory).
|
.github/ISSUE_TEMPLATE/1-bug-report.yml
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: "\U0001F41B Bug / help"
|
| 2 |
+
description: Create a report to help us improve the LLaMA Factory
|
| 3 |
+
labels: ["bug", "pending"]
|
| 4 |
+
body:
|
| 5 |
+
- type: markdown
|
| 6 |
+
attributes:
|
| 7 |
+
value: |
|
| 8 |
+
Issues included in **[FAQs](https://github.com/hiyouga/LLaMA-Factory/issues/4614)** or those with **insufficient** information may be closed without a response.
|
| 9 |
+
已经包含在 **[常见问题](https://github.com/hiyouga/LLaMA-Factory/issues/4614)** 内或提供信息**不完整**的 issues 可能不会被回复。
|
| 10 |
+
|
| 11 |
+
- type: markdown
|
| 12 |
+
attributes:
|
| 13 |
+
value: |
|
| 14 |
+
Please do not create issues that are not related to framework bugs under this category, use **[Discussions](https://github.com/hiyouga/LLaMA-Factory/discussions/categories/q-a)** instead.
|
| 15 |
+
请勿在此分类下创建和框架 bug 无关的 issues,训练问题求助请使用 **[讨论区](https://github.com/hiyouga/LLaMA-Factory/discussions/categories/q-a)**。
|
| 16 |
+
|
| 17 |
+
- type: checkboxes
|
| 18 |
+
id: reminder
|
| 19 |
+
attributes:
|
| 20 |
+
label: Reminder
|
| 21 |
+
description: |
|
| 22 |
+
Please ensure you have read the above rules carefully and searched the existing issues (including FAQs).
|
| 23 |
+
请确保您已经认真阅读了上述规则并且搜索过现有的 issues(包括常见问题)。
|
| 24 |
+
|
| 25 |
+
options:
|
| 26 |
+
- label: I have read the above rules and searched the existing issues.
|
| 27 |
+
required: true
|
| 28 |
+
|
| 29 |
+
- type: textarea
|
| 30 |
+
id: system-info
|
| 31 |
+
validations:
|
| 32 |
+
required: true
|
| 33 |
+
attributes:
|
| 34 |
+
label: System Info
|
| 35 |
+
description: |
|
| 36 |
+
Please share your system info with us. You can run the command **llamafactory-cli env** and copy-paste its output below.
|
| 37 |
+
请提供您的系统信息。您可以在命令行运行 **llamafactory-cli env** 并将其输出复制到该文本框中。
|
| 38 |
+
|
| 39 |
+
placeholder: llamafactory version, platform, python version, ...
|
| 40 |
+
|
| 41 |
+
- type: textarea
|
| 42 |
+
id: reproduction
|
| 43 |
+
validations:
|
| 44 |
+
required: true
|
| 45 |
+
attributes:
|
| 46 |
+
label: Reproduction
|
| 47 |
+
description: |
|
| 48 |
+
Please provide entry arguments, error messages and stack traces that reproduces the problem.
|
| 49 |
+
请提供入口参数,错误日志以及异常堆栈以便于我们复现问题。
|
| 50 |
+
|
| 51 |
+
value: |
|
| 52 |
+
```text
|
| 53 |
+
Put your message here.
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
- type: textarea
|
| 57 |
+
id: others
|
| 58 |
+
validations:
|
| 59 |
+
required: false
|
| 60 |
+
attributes:
|
| 61 |
+
label: Others
|
.github/ISSUE_TEMPLATE/2-feature-request.yml
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: "\U0001F680 Feature request"
|
| 2 |
+
description: Submit a request for a new feature
|
| 3 |
+
labels: ["enhancement", "pending"]
|
| 4 |
+
body:
|
| 5 |
+
- type: markdown
|
| 6 |
+
attributes:
|
| 7 |
+
value: |
|
| 8 |
+
Please do not create issues that are not related to new features under this category.
|
| 9 |
+
请勿在此分类下创建和新特性无关的 issues。
|
| 10 |
+
|
| 11 |
+
- type: checkboxes
|
| 12 |
+
id: reminder
|
| 13 |
+
attributes:
|
| 14 |
+
label: Reminder
|
| 15 |
+
description: |
|
| 16 |
+
Please ensure you have read the above rules carefully and searched the existing issues.
|
| 17 |
+
请确保您已经认真阅读了上述规则并且搜索过现有的 issues。
|
| 18 |
+
|
| 19 |
+
options:
|
| 20 |
+
- label: I have read the above rules and searched the existing issues.
|
| 21 |
+
required: true
|
| 22 |
+
|
| 23 |
+
- type: textarea
|
| 24 |
+
id: description
|
| 25 |
+
validations:
|
| 26 |
+
required: true
|
| 27 |
+
attributes:
|
| 28 |
+
label: Description
|
| 29 |
+
description: |
|
| 30 |
+
A clear and concise description of the feature proposal.
|
| 31 |
+
请详细描述您希望加入的新功能特性。
|
| 32 |
+
|
| 33 |
+
- type: textarea
|
| 34 |
+
id: contribution
|
| 35 |
+
validations:
|
| 36 |
+
required: false
|
| 37 |
+
attributes:
|
| 38 |
+
label: Pull Request
|
| 39 |
+
description: |
|
| 40 |
+
Have you already created the relevant PR and submitted the code?
|
| 41 |
+
您是否已经创建了相关 PR 并提交了代码?
|
.github/ISSUE_TEMPLATE/config.yml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
blank_issues_enabled: false
|
| 2 |
+
contact_links:
|
| 3 |
+
- name: 📚 FAQs | 常见问题
|
| 4 |
+
url: https://github.com/hiyouga/LLaMA-Factory/issues/4614
|
| 5 |
+
about: Reading in advance is recommended | 建议提前阅读
|
| 6 |
+
- name: Discussions | 讨论区
|
| 7 |
+
url: https://github.com/hiyouga/LLaMA-Factory/discussions
|
| 8 |
+
about: Please ask fine-tuning questions here | 请在这里讨论训练问题
|
.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/docker.yml
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: docker
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
workflow_dispatch:
|
| 5 |
+
push:
|
| 6 |
+
branches:
|
| 7 |
+
- "main"
|
| 8 |
+
paths:
|
| 9 |
+
- "**/*.py"
|
| 10 |
+
- "requirements.txt"
|
| 11 |
+
- "docker/**"
|
| 12 |
+
- ".github/workflows/*.yml"
|
| 13 |
+
pull_request:
|
| 14 |
+
branches:
|
| 15 |
+
- "main"
|
| 16 |
+
paths:
|
| 17 |
+
- "**/*.py"
|
| 18 |
+
- "requirements.txt"
|
| 19 |
+
- "docker/**"
|
| 20 |
+
- ".github/workflows/*.yml"
|
| 21 |
+
|
| 22 |
+
jobs:
|
| 23 |
+
build:
|
| 24 |
+
strategy:
|
| 25 |
+
fail-fast: false
|
| 26 |
+
matrix:
|
| 27 |
+
device:
|
| 28 |
+
- "cuda"
|
| 29 |
+
- "npu"
|
| 30 |
+
|
| 31 |
+
runs-on: ubuntu-latest
|
| 32 |
+
|
| 33 |
+
concurrency:
|
| 34 |
+
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.device }}
|
| 35 |
+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
| 36 |
+
|
| 37 |
+
environment:
|
| 38 |
+
name: docker
|
| 39 |
+
url: https://hub.docker.com/r/hiyouga/llamafactory
|
| 40 |
+
|
| 41 |
+
steps:
|
| 42 |
+
- name: Free up disk space
|
| 43 |
+
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
|
| 44 |
+
with:
|
| 45 |
+
tool-cache: true
|
| 46 |
+
docker-images: false
|
| 47 |
+
|
| 48 |
+
- name: Checkout
|
| 49 |
+
uses: actions/checkout@v4
|
| 50 |
+
|
| 51 |
+
- name: Set up Python
|
| 52 |
+
uses: actions/setup-python@v5
|
| 53 |
+
with:
|
| 54 |
+
python-version: "3.9"
|
| 55 |
+
|
| 56 |
+
- name: Get llamafactory version
|
| 57 |
+
id: version
|
| 58 |
+
run: |
|
| 59 |
+
echo "tag=$(python setup.py --version | sed 's/\.dev0//')" >> "$GITHUB_OUTPUT"
|
| 60 |
+
|
| 61 |
+
- name: Set up Docker Buildx
|
| 62 |
+
uses: docker/setup-buildx-action@v3
|
| 63 |
+
|
| 64 |
+
- name: Login to Docker Hub
|
| 65 |
+
if: ${{ github.event_name != 'pull_request' }}
|
| 66 |
+
uses: docker/login-action@v3
|
| 67 |
+
with:
|
| 68 |
+
username: ${{ vars.DOCKERHUB_USERNAME }}
|
| 69 |
+
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
| 70 |
+
|
| 71 |
+
- name: Login to Quay
|
| 72 |
+
if: ${{ github.event_name != 'pull_request' && matrix.device == 'npu' }}
|
| 73 |
+
uses: docker/login-action@v3
|
| 74 |
+
with:
|
| 75 |
+
registry: quay.io
|
| 76 |
+
username: ${{ vars.QUAY_ASCEND_USERNAME }}
|
| 77 |
+
password: ${{ secrets.QUAY_ASCEND_TOKEN }}
|
| 78 |
+
|
| 79 |
+
- name: Build and push Docker image (CUDA)
|
| 80 |
+
if: ${{ matrix.device == 'cuda' }}
|
| 81 |
+
uses: docker/build-push-action@v6
|
| 82 |
+
with:
|
| 83 |
+
context: .
|
| 84 |
+
file: ./docker/docker-cuda/Dockerfile
|
| 85 |
+
build-args: |
|
| 86 |
+
EXTRAS=metrics,deepspeed,liger-kernel
|
| 87 |
+
push: ${{ github.event_name != 'pull_request' }}
|
| 88 |
+
tags: |
|
| 89 |
+
docker.io/hiyouga/llamafactory:latest
|
| 90 |
+
docker.io/hiyouga/llamafactory:${{ steps.version.outputs.tag }}
|
| 91 |
+
cache-from: type=gha
|
| 92 |
+
cache-to: type=gha,mode=max
|
| 93 |
+
|
| 94 |
+
- name: Build and push Docker image (NPU)
|
| 95 |
+
if: ${{ matrix.device == 'npu' }}
|
| 96 |
+
uses: docker/build-push-action@v6
|
| 97 |
+
with:
|
| 98 |
+
context: .
|
| 99 |
+
platforms: linux/amd64,linux/arm64
|
| 100 |
+
file: ./docker/docker-npu/Dockerfile
|
| 101 |
+
push: ${{ github.event_name != 'pull_request' }}
|
| 102 |
+
tags: |
|
| 103 |
+
docker.io/hiyouga/llamafactory:latest-npu-a2
|
| 104 |
+
docker.io/hiyouga/llamafactory:${{ steps.version.outputs.tag }}-npu-a2
|
| 105 |
+
quay.io/ascend/llamafactory:latest-npu-a2
|
| 106 |
+
quay.io/ascend/llamafactory:${{ steps.version.outputs.tag }}-npu-a2
|
| 107 |
+
cache-from: type=gha
|
| 108 |
+
cache-to: type=gha,mode=max
|
.github/workflows/label_issue.yml
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
permissions:
|
| 13 |
+
issues: write
|
| 14 |
+
|
| 15 |
+
steps:
|
| 16 |
+
- env:
|
| 17 |
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
| 18 |
+
ISSUE_URL: ${{ github.event.issue.html_url }}
|
| 19 |
+
ISSUE_TITLE: ${{ github.event.issue.title }}
|
| 20 |
+
run: |
|
| 21 |
+
LABEL=""
|
| 22 |
+
NPU_KEYWORDS=(npu huawei ascend 华为 昇腾 910)
|
| 23 |
+
ISSUE_TITLE_LOWER=$(echo $ISSUE_TITLE | tr '[:upper:]' '[:lower:]')
|
| 24 |
+
for KEYWORD in ${NPU_KEYWORDS[@]}; do
|
| 25 |
+
if [[ $ISSUE_TITLE_LOWER == *$KEYWORD* ]] && [[ $ISSUE_TITLE_LOWER != *input* ]]; then
|
| 26 |
+
LABEL="npu"
|
| 27 |
+
break
|
| 28 |
+
fi
|
| 29 |
+
done
|
| 30 |
+
if [ -n "$LABEL" ]; then
|
| 31 |
+
gh issue edit $ISSUE_URL --add-label $LABEL
|
| 32 |
+
fi
|
.github/workflows/publish.yml
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: publish
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
workflow_dispatch:
|
| 5 |
+
release:
|
| 6 |
+
types:
|
| 7 |
+
- published
|
| 8 |
+
|
| 9 |
+
jobs:
|
| 10 |
+
publish:
|
| 11 |
+
name: Upload release to PyPI
|
| 12 |
+
|
| 13 |
+
runs-on: ubuntu-latest
|
| 14 |
+
|
| 15 |
+
environment:
|
| 16 |
+
name: release
|
| 17 |
+
url: https://pypi.org/p/llamafactory
|
| 18 |
+
|
| 19 |
+
permissions:
|
| 20 |
+
id-token: write
|
| 21 |
+
|
| 22 |
+
steps:
|
| 23 |
+
- name: Checkout
|
| 24 |
+
uses: actions/checkout@v4
|
| 25 |
+
|
| 26 |
+
- name: Set up Python
|
| 27 |
+
uses: actions/setup-python@v5
|
| 28 |
+
with:
|
| 29 |
+
python-version: "3.9"
|
| 30 |
+
|
| 31 |
+
- name: Build package
|
| 32 |
+
run: |
|
| 33 |
+
make build
|
| 34 |
+
|
| 35 |
+
- name: Publish package
|
| 36 |
+
uses: pypa/gh-action-pypi-publish@release/v1
|
.github/workflows/tests.yml
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: tests
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
workflow_dispatch:
|
| 5 |
+
push:
|
| 6 |
+
branches:
|
| 7 |
+
- "main"
|
| 8 |
+
paths:
|
| 9 |
+
- "**/*.py"
|
| 10 |
+
- "requirements.txt"
|
| 11 |
+
- ".github/workflows/*.yml"
|
| 12 |
+
pull_request:
|
| 13 |
+
branches:
|
| 14 |
+
- "main"
|
| 15 |
+
paths:
|
| 16 |
+
- "**/*.py"
|
| 17 |
+
- "requirements.txt"
|
| 18 |
+
- ".github/workflows/*.yml"
|
| 19 |
+
|
| 20 |
+
jobs:
|
| 21 |
+
tests:
|
| 22 |
+
strategy:
|
| 23 |
+
fail-fast: false
|
| 24 |
+
matrix:
|
| 25 |
+
python:
|
| 26 |
+
- "3.9"
|
| 27 |
+
- "3.10"
|
| 28 |
+
- "3.11"
|
| 29 |
+
- "3.12"
|
| 30 |
+
os:
|
| 31 |
+
- "ubuntu-latest"
|
| 32 |
+
- "windows-latest"
|
| 33 |
+
- "macos-13"
|
| 34 |
+
transformers:
|
| 35 |
+
- null
|
| 36 |
+
include: # test backward compatibility
|
| 37 |
+
- python: "3.9"
|
| 38 |
+
os: "ubuntu-latest"
|
| 39 |
+
transformers: "4.49.0"
|
| 40 |
+
- python: "3.9"
|
| 41 |
+
os: "ubuntu-latest"
|
| 42 |
+
transformers: "4.51.0"
|
| 43 |
+
|
| 44 |
+
runs-on: ${{ matrix.os }}
|
| 45 |
+
|
| 46 |
+
concurrency:
|
| 47 |
+
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.python }}-${{ matrix.transformers }}
|
| 48 |
+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
| 49 |
+
|
| 50 |
+
env:
|
| 51 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 52 |
+
OS_NAME: ${{ matrix.os }}
|
| 53 |
+
|
| 54 |
+
steps:
|
| 55 |
+
- name: Checkout
|
| 56 |
+
uses: actions/checkout@v4
|
| 57 |
+
|
| 58 |
+
- name: Set up Python
|
| 59 |
+
uses: actions/setup-python@v5
|
| 60 |
+
with:
|
| 61 |
+
python-version: ${{ matrix.python }}
|
| 62 |
+
cache: "pip"
|
| 63 |
+
cache-dependency-path: "**/requirements*.txt"
|
| 64 |
+
|
| 65 |
+
- name: Install dependencies
|
| 66 |
+
run: |
|
| 67 |
+
python -m pip install --upgrade pip
|
| 68 |
+
python -m pip install ".[torch,dev]"
|
| 69 |
+
|
| 70 |
+
- name: Install transformers
|
| 71 |
+
if: ${{ matrix.transformers }}
|
| 72 |
+
run: |
|
| 73 |
+
python -m pip install "transformers==${{ matrix.transformers }}"
|
| 74 |
+
|
| 75 |
+
- name: Install transformers to avoid mac os ci errors
|
| 76 |
+
if: ${{ matrix.os == 'macos-13' }}
|
| 77 |
+
run: |
|
| 78 |
+
python -m pip install "transformers<=4.51.3"
|
| 79 |
+
|
| 80 |
+
- name: Cache files
|
| 81 |
+
id: hf-hub-cache
|
| 82 |
+
uses: actions/cache@v4
|
| 83 |
+
with:
|
| 84 |
+
path: ${{ runner.temp }}/huggingface
|
| 85 |
+
key: huggingface-${{ matrix.os }}-${{ matrix.python }}-${{ matrix.transformers }}-${{ hashFiles('tests/version.txt') }}
|
| 86 |
+
|
| 87 |
+
- name: Check quality
|
| 88 |
+
run: |
|
| 89 |
+
make style && make quality
|
| 90 |
+
|
| 91 |
+
- name: Check license
|
| 92 |
+
run: |
|
| 93 |
+
make license
|
| 94 |
+
|
| 95 |
+
- name: Check build
|
| 96 |
+
run: |
|
| 97 |
+
make build
|
| 98 |
+
|
| 99 |
+
- name: Test with pytest
|
| 100 |
+
run: |
|
| 101 |
+
make test
|
| 102 |
+
env:
|
| 103 |
+
HF_HOME: ${{ runner.temp }}/huggingface
|
| 104 |
+
HF_HUB_OFFLINE: "${{ steps.hf-hub-cache.outputs.cache-hit == 'true' && '1' || '0' }}"
|
.gitignore
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
# vscode
|
| 163 |
+
.vscode/
|
| 164 |
+
|
| 165 |
+
# uv
|
| 166 |
+
uv.lock
|
| 167 |
+
|
| 168 |
+
# custom .gitignore
|
| 169 |
+
hf_cache/
|
| 170 |
+
ms_cache/
|
| 171 |
+
om_cache/
|
| 172 |
+
cache/
|
| 173 |
+
config/
|
| 174 |
+
saves/
|
| 175 |
+
output/
|
| 176 |
+
wandb/
|
| 177 |
+
swanlog/
|
| 178 |
+
generated_predictions.jsonl
|
| 179 |
+
predictions_score.json
|
.pre-commit-config.yaml
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
repos:
|
| 2 |
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
| 3 |
+
rev: v5.0.0
|
| 4 |
+
hooks:
|
| 5 |
+
- id: check-ast
|
| 6 |
+
- id: check-added-large-files
|
| 7 |
+
args: ['--maxkb=25000']
|
| 8 |
+
- id: check-merge-conflict
|
| 9 |
+
- id: check-yaml
|
| 10 |
+
- id: debug-statements
|
| 11 |
+
- id: end-of-file-fixer
|
| 12 |
+
- id: trailing-whitespace
|
| 13 |
+
args: [--markdown-linebreak-ext=md]
|
| 14 |
+
- id: no-commit-to-branch
|
| 15 |
+
args: ['--branch', 'main']
|
| 16 |
+
|
| 17 |
+
- repo: https://github.com/asottile/pyupgrade
|
| 18 |
+
rev: v3.17.0
|
| 19 |
+
hooks:
|
| 20 |
+
- id: pyupgrade
|
| 21 |
+
args: [--py38-plus]
|
| 22 |
+
|
| 23 |
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
| 24 |
+
rev: v0.6.9
|
| 25 |
+
hooks:
|
| 26 |
+
- id: ruff
|
| 27 |
+
args: [--fix]
|
| 28 |
+
- id: ruff-format
|
=0.39.0
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
|
| 2 |
+
Collecting bitsandbytes
|
| 3 |
+
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/9c/40/91f1a5a694f434bc13cba160045fdc4e867032e627b001bf411048fefd9c/bitsandbytes-0.47.0-py3-none-manylinux_2_24_x86_64.whl (61.3 MB)
|
| 4 |
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.3/61.3 MB 8.4 MB/s 0:00:07
|
| 5 |
+
Requirement already satisfied: torch<3,>=2.2 in /root/anaconda3/envs/llamafactory/lib/python3.10/site-packages (from bitsandbytes) (2.5.1)
|
| 6 |
+
Requirement already satisfied: numpy>=1.17 in /root/anaconda3/envs/llamafactory/lib/python3.10/site-packages (from bitsandbytes) (1.26.4)
|
| 7 |
+
Requirement already satisfied: filelock in /root/anaconda3/envs/llamafactory/lib/python3.10/site-packages (from torch<3,>=2.2->bitsandbytes) (3.17.0)
|
| 8 |
+
Requirement already satisfied: typing-extensions>=4.8.0 in /root/anaconda3/envs/llamafactory/lib/python3.10/site-packages (from torch<3,>=2.2->bitsandbytes) (4.12.2)
|
| 9 |
+
Requirement already satisfied: networkx in /root/anaconda3/envs/llamafactory/lib/python3.10/site-packages (from torch<3,>=2.2->bitsandbytes) (3.4.2)
|
| 10 |
+
Requirement already satisfied: jinja2 in /root/anaconda3/envs/llamafactory/lib/python3.10/site-packages (from torch<3,>=2.2->bitsandbytes) (3.1.6)
|
| 11 |
+
Requirement already satisfied: fsspec in /root/anaconda3/envs/llamafactory/lib/python3.10/site-packages (from torch<3,>=2.2->bitsandbytes) (2025.3.0)
|
| 12 |
+
Requirement already satisfied: sympy==1.13.1 in /root/anaconda3/envs/llamafactory/lib/python3.10/site-packages (from torch<3,>=2.2->bitsandbytes) (1.13.1)
|
| 13 |
+
Requirement already satisfied: mpmath<1.4,>=1.1.0 in /root/anaconda3/envs/llamafactory/lib/python3.10/site-packages (from sympy==1.13.1->torch<3,>=2.2->bitsandbytes) (1.3.0)
|
| 14 |
+
Requirement already satisfied: MarkupSafe>=2.0 in /root/anaconda3/envs/llamafactory/lib/python3.10/site-packages (from jinja2->torch<3,>=2.2->bitsandbytes) (3.0.2)
|
| 15 |
+
Installing collected packages: bitsandbytes
|
| 16 |
+
Successfully installed bitsandbytes-0.47.0
|
CITATION.cff
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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: "Feng"
|
| 16 |
+
given-names: "Zhangchi"
|
| 17 |
+
- family-names: "Ma"
|
| 18 |
+
given-names: "Yongqiang"
|
| 19 |
+
title: "LlamaFactory: Unified Efficient Fine-Tuning of 100+ Language Models"
|
| 20 |
+
url: "https://arxiv.org/abs/2403.13372"
|
| 21 |
+
preferred-citation:
|
| 22 |
+
type: conference-paper
|
| 23 |
+
conference:
|
| 24 |
+
name: "Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 3: System Demonstrations)"
|
| 25 |
+
authors:
|
| 26 |
+
- family-names: "Zheng"
|
| 27 |
+
given-names: "Yaowei"
|
| 28 |
+
- family-names: "Zhang"
|
| 29 |
+
given-names: "Richong"
|
| 30 |
+
- family-names: "Zhang"
|
| 31 |
+
given-names: "Junhao"
|
| 32 |
+
- family-names: "Ye"
|
| 33 |
+
given-names: "Yanhan"
|
| 34 |
+
- family-names: "Luo"
|
| 35 |
+
given-names: "Zheyan"
|
| 36 |
+
- family-names: "Feng"
|
| 37 |
+
given-names: "Zhangchi"
|
| 38 |
+
- family-names: "Ma"
|
| 39 |
+
given-names: "Yongqiang"
|
| 40 |
+
title: "LlamaFactory: Unified Efficient Fine-Tuning of 100+ Language Models"
|
| 41 |
+
url: "https://arxiv.org/abs/2403.13372"
|
| 42 |
+
year: 2024
|
| 43 |
+
publisher: "Association for Computational Linguistics"
|
| 44 |
+
address: "Bangkok, Thailand"
|
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,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.PHONY: build commit license quality style test
|
| 2 |
+
|
| 3 |
+
check_dirs := scripts src tests setup.py
|
| 4 |
+
|
| 5 |
+
build:
|
| 6 |
+
pip3 install build && python3 -m build
|
| 7 |
+
|
| 8 |
+
commit:
|
| 9 |
+
pre-commit install
|
| 10 |
+
pre-commit run --all-files
|
| 11 |
+
|
| 12 |
+
license:
|
| 13 |
+
python3 tests/check_license.py $(check_dirs)
|
| 14 |
+
|
| 15 |
+
quality:
|
| 16 |
+
ruff check $(check_dirs)
|
| 17 |
+
ruff format --check $(check_dirs)
|
| 18 |
+
|
| 19 |
+
style:
|
| 20 |
+
ruff check $(check_dirs) --fix
|
| 21 |
+
ruff format $(check_dirs)
|
| 22 |
+
|
| 23 |
+
test:
|
| 24 |
+
CUDA_VISIBLE_DEVICES= WANDB_DISABLED=true pytest -vv tests/
|
README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
dataset_info:
|
| 3 |
+
features:
|
| 4 |
+
- name: app_days
|
| 5 |
+
dtype: int64
|
| 6 |
+
- name: bot_gender
|
| 7 |
+
dtype: int64
|
| 8 |
+
- name: bot_id
|
| 9 |
+
dtype: string
|
| 10 |
+
- name: chosen
|
| 11 |
+
dtype: string
|
| 12 |
+
- name: chosen_model
|
| 13 |
+
dtype: int64
|
| 14 |
+
- name: chosen_position
|
| 15 |
+
dtype: int64
|
| 16 |
+
- name: chosen_prompt
|
| 17 |
+
dtype: string
|
| 18 |
+
- name: id
|
| 19 |
+
dtype: string
|
| 20 |
+
- name: reject
|
| 21 |
+
dtype: string
|
| 22 |
+
- name: reject_model
|
| 23 |
+
dtype: int64
|
| 24 |
+
- name: reject_prompt
|
| 25 |
+
dtype: string
|
| 26 |
+
- name: timestamp
|
| 27 |
+
dtype: string
|
| 28 |
+
- name: user_gender
|
| 29 |
+
dtype: int64
|
| 30 |
+
- name: user_id
|
| 31 |
+
dtype: string
|
| 32 |
+
splits:
|
| 33 |
+
- name: train
|
| 34 |
+
num_bytes: 95490151
|
| 35 |
+
num_examples: 5122
|
| 36 |
+
download_size: 51033799
|
| 37 |
+
dataset_size: 95490151
|
| 38 |
+
configs:
|
| 39 |
+
- config_name: default
|
| 40 |
+
data_files:
|
| 41 |
+
- split: train
|
| 42 |
+
path: data/train-*
|
| 43 |
+
---
|
README_zh.md
ADDED
|
@@ -0,0 +1,953 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+

|
| 2 |
+
|
| 3 |
+
[](https://github.com/hiyouga/LLaMA-Factory/stargazers)
|
| 4 |
+
[](https://github.com/hiyouga/LLaMA-Factory/commits/main)
|
| 5 |
+
[](https://github.com/hiyouga/LLaMA-Factory/graphs/contributors)
|
| 6 |
+
[](https://github.com/hiyouga/LLaMA-Factory/actions/workflows/tests.yml)
|
| 7 |
+
[](https://pypi.org/project/llamafactory/)
|
| 8 |
+
[](https://scholar.google.com/scholar?cites=12620864006390196564)
|
| 9 |
+
[](https://hub.docker.com/r/hiyouga/llamafactory/tags)
|
| 10 |
+
|
| 11 |
+
[](https://twitter.com/llamafactory_ai)
|
| 12 |
+
[](https://discord.gg/rKfvV9r9FK)
|
| 13 |
+
|
| 14 |
+
[](https://colab.research.google.com/drive/1d5KQtbemerlSDSxZIfAaWXhKr30QypiK?usp=sharing)
|
| 15 |
+
[](https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory)
|
| 16 |
+
[](https://docs.alayanew.com/docs/documents/newActivities/llamafactory/?utm_source=LLaMA-Factory)
|
| 17 |
+
[](https://huggingface.co/spaces/hiyouga/LLaMA-Board)
|
| 18 |
+
[](https://modelscope.cn/studios/hiyouga/LLaMA-Board)
|
| 19 |
+
[](https://novita.ai/templates-library/105981?sharer=88115474-394e-4bda-968e-b88e123d0c47)
|
| 20 |
+
|
| 21 |
+
### 获得[亚马逊](https://aws.amazon.com/cn/blogs/china/a-one-stop-code-free-model-fine-tuning-deployment-platform-based-on-sagemaker-and-llama-factory/)、[英伟达](https://developer.nvidia.cn/rtx/ai-toolkit)、[阿里云](https://help.aliyun.com/zh/pai/use-cases/fine-tune-a-llama-3-model-with-llama-factory)等的应用。
|
| 22 |
+
|
| 23 |
+
<div align="center" markdown="1">
|
| 24 |
+
|
| 25 |
+
### 赞助商 ❤️
|
| 26 |
+
|
| 27 |
+
| <div style="text-align: center;"><a href="https://warp.dev/llama-factory"><img alt="Warp sponsorship" width="400" src="assets/warp.jpg"></a><br><a href="https://warp.dev/llama-factory" style="font-size:larger;">Warp,面向开发者的智能终端</a><br><a href="https://warp.dev/llama-factory">适用于 MacOS、Linux 和 Windows</a> | <a href="https://serpapi.com"><img alt="SerpAPI sponsorship" width="250" src="assets/serpapi.svg"> </a> |
|
| 28 |
+
| ---- | ---- |
|
| 29 |
+
|
| 30 |
+
----
|
| 31 |
+
|
| 32 |
+
### 使用零代码[命令行](#快速开始)与 [Web UI](#llama-board-可视化微调由-gradio-驱动) 轻松微调百余种大模型
|
| 33 |
+
|
| 34 |
+

|
| 35 |
+
|
| 36 |
+
</div>
|
| 37 |
+
|
| 38 |
+
👋 加入我们的[微信群](assets/wechat.jpg)、[NPU 用户群](assets/wechat_npu.jpg)或 [九章智算云算力优惠群](assets/wechat_alaya.png)。
|
| 39 |
+
|
| 40 |
+
\[ [English](README.md) | 中文 \]
|
| 41 |
+
|
| 42 |
+
**微调大模型可以像这样轻松…**
|
| 43 |
+
|
| 44 |
+
https://github.com/user-attachments/assets/43b700c6-a178-41db-b1f8-8190a5d3fcfc
|
| 45 |
+
|
| 46 |
+
选择你的打开方式:
|
| 47 |
+
|
| 48 |
+
- **入门教程**:https://zhuanlan.zhihu.com/p/695287607
|
| 49 |
+
- **微调视频教程**:https://www.bilibili.com/video/BV1djgRzxEts/
|
| 50 |
+
- **框架文档**:https://llamafactory.readthedocs.io/zh-cn/latest/
|
| 51 |
+
- **框架文档(昇腾 NPU)**:https://ascend.github.io/docs/sources/llamafactory/
|
| 52 |
+
- **Colab(免费)**:https://colab.research.google.com/drive/1d5KQtbemerlSDSxZIfAaWXhKr30QypiK?usp=sharing
|
| 53 |
+
- **本地机器**:请见[如何使用](#如何使用)
|
| 54 |
+
- **PAI-DSW(免费试用)**:https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory
|
| 55 |
+
- **九章智算云(算力优惠活动)**:https://docs.alayanew.com/docs/documents/useGuide/LLaMAFactory/mutiple/?utm_source=LLaMA-Factory
|
| 56 |
+
|
| 57 |
+
> [!NOTE]
|
| 58 |
+
> 除上述链接以外的其他网站均为未经许可的第三方网站,请小心甄别。
|
| 59 |
+
|
| 60 |
+
## 目录
|
| 61 |
+
|
| 62 |
+
- [项目特色](#项目特色)
|
| 63 |
+
- [官方博客](#官方博客)
|
| 64 |
+
- [更新日志](#更新日志)
|
| 65 |
+
- [模型](#模型)
|
| 66 |
+
- [训练方法](#训练方法)
|
| 67 |
+
- [数据集](#数据集)
|
| 68 |
+
- [软硬件依赖](#软硬件依赖)
|
| 69 |
+
- [如何使用](#如何使用)
|
| 70 |
+
- [安装 LLaMA Factory](#安装-llama-factory)
|
| 71 |
+
- [数据准备](#数据准备)
|
| 72 |
+
- [快速开始](#快速开始)
|
| 73 |
+
- [LLaMA Board 可视化微调](#llama-board-可视化微调由-gradio-驱动)
|
| 74 |
+
- [构建 Docker](#构建-docker)
|
| 75 |
+
- [利用 vLLM 部署 OpenAI API](#利用-vllm-部署-openai-api)
|
| 76 |
+
- [从魔搭社区下载](#从魔搭社区下载)
|
| 77 |
+
- [从魔乐社区下载](#从魔乐社区下载)
|
| 78 |
+
- [使用 W&B 面板](#使用-wb-面板)
|
| 79 |
+
- [使用 SwanLab 面板](#使用-swanlab-面板)
|
| 80 |
+
- [使用了 LLaMA Factory 的项目](#使用了-llama-factory-的项目)
|
| 81 |
+
- [协议](#协议)
|
| 82 |
+
- [引用](#引用)
|
| 83 |
+
- [致谢](#致谢)
|
| 84 |
+
|
| 85 |
+
## 项目特色
|
| 86 |
+
|
| 87 |
+
- **多种模型**:LLaMA、LLaVA、Mistral、Mixtral-MoE、Qwen、Qwen2-VL、DeepSeek、Yi、Gemma、ChatGLM、Phi 等等。
|
| 88 |
+
- **集成方法**:(增量)预训练、(多模态)指令监督微调、奖励模型训练、PPO 训练、DPO 训练、KTO 训练、ORPO 训练等等。
|
| 89 |
+
- **多种精度**:16 比特全参数微调、冻结微调、LoRA 微调和基于 AQLM/AWQ/GPTQ/LLM.int8/HQQ/EETQ 的 2/3/4/5/6/8 比特 QLoRA 微调。
|
| 90 |
+
- **先进算法**:[GaLore](https://github.com/jiaweizzhao/GaLore)、[BAdam](https://github.com/Ledzy/BAdam)、[APOLLO](https://github.com/zhuhanqing/APOLLO)、[Adam-mini](https://github.com/zyushun/Adam-mini)、[Muon](https://github.com/KellerJordan/Muon)、DoRA、LongLoRA、LLaMA Pro、Mixture-of-Depths、LoRA+、LoftQ 和 PiSSA。
|
| 91 |
+
- **实用技巧**:[FlashAttention-2](https://github.com/Dao-AILab/flash-attention)、[Unsloth](https://github.com/unslothai/unsloth)、[Liger Kernel](https://github.com/linkedin/Liger-Kernel)、RoPE scaling、NEFTune 和 rsLoRA。
|
| 92 |
+
- **广泛任务**:多轮对话、工具调用、图像理解、视觉定位、视频识别和语音理解等等。
|
| 93 |
+
- **实验监控**:LlamaBoard、TensorBoard、Wandb、MLflow、[SwanLab](https://github.com/SwanHubX/SwanLab) 等等。
|
| 94 |
+
- **极速推理**:基于 [vLLM](https://github.com/vllm-project/vllm) 或 [SGLang](https://github.com/sgl-project/sglang) 的 OpenAI 风格 API、浏览器界面和命令行接口。
|
| 95 |
+
|
| 96 |
+
### 最新模型的 Day-N 微调适配
|
| 97 |
+
|
| 98 |
+
| 适配时间 | 模型名称 |
|
| 99 |
+
| ------------ | -------------------------------------------------------------------- |
|
| 100 |
+
| Day 0 | Qwen3 / Qwen2.5-VL / Gemma 3 / GLM-4.1V / InternLM 3 / MiniCPM-o-2.6 |
|
| 101 |
+
| Day 1 | Llama 3 / GLM-4 / Mistral Small / PaliGemma2 / Llama 4 |
|
| 102 |
+
|
| 103 |
+
## 官方博客
|
| 104 |
+
|
| 105 |
+
- [使用 LLaMA-Factory 构建 GPT-OSS 角色扮演模型](https://docs.llamafactory.com.cn/docs/documents/best-practice/gptroleplay/?utm_source=LLaMA-Factory)(中文)
|
| 106 |
+
- [使用 LLaMA-Factory 微调 Llama3.1-70B 医学诊断模型](https://docs.alayanew.com/docs/documents/bestPractice/bigModel/llama70B/?utm_source=LLaMA-Factory)(中文)
|
| 107 |
+
- [基于 LLaMA-Factory 和 EasyR1 打造一站式无代码大模型强化学习和部署平台 LLM Model Hub](https://aws.amazon.com/cn/blogs/china/building-llm-model-hub-based-on-llamafactory-and-easyr1/)(中文)
|
| 108 |
+
- [通过亚马逊 SageMaker HyperPod 上的 LLaMA-Factory 增强多模态模型银行文档的视觉信息提取](https://aws.amazon.com/cn/blogs/machine-learning/how-apoidea-group-enhances-visual-information-extraction-from-banking-documents-with-multimodal-models-using-llama-factory-on-amazon-sagemaker-hyperpod/)(英文)
|
| 109 |
+
- [Easy Dataset × LLaMA Factory: 让大模型高效学习领域知识](https://buaa-act.feishu.cn/wiki/KY9xwTGs1iqHrRkjXBwcZP9WnL9)(中文)
|
| 110 |
+
|
| 111 |
+
<details><summary>全部博客</summary>
|
| 112 |
+
|
| 113 |
+
- [使用 LLaMA-Factory 微调 Qwen2.5-VL 实现自动驾驶场景微调](https://docs.alayanew.com/docs/documents/useGuide/LLaMAFactory/mutiple/?utm_source=LLaMA-Factory)(中文)
|
| 114 |
+
- [LLaMA Factory:微调 DeepSeek-R1-Distill-Qwen-7B 模型实现新闻标题分类器](https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory_deepseek_r1_distill_7b)(中文)
|
| 115 |
+
- [基于 Amazon SageMaker 和 LLaMA-Factory 打造一站式无代码模型微调部署平台 Model Hub](https://aws.amazon.com/cn/blogs/china/a-one-stop-code-free-model-fine-tuning-deployment-platform-based-on-sagemaker-and-llama-factory/)(中文)
|
| 116 |
+
- [LLaMA Factory 多模态微调实践:微调 Qwen2-VL 构建文旅大模型](https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory_qwen2vl)(中文)
|
| 117 |
+
- [LLaMA Factory:微调 Llama3 模型实现角色扮演](https://gallery.pai-ml.com/#/preview/deepLearning/nlp/llama_factory)(中文)
|
| 118 |
+
|
| 119 |
+
</details>
|
| 120 |
+
|
| 121 |
+
## 更新日志
|
| 122 |
+
|
| 123 |
+
[25/08/20] 我们支持了 **[Intern-S1-mini](https://huggingface.co/internlm/Intern-S1-mini)** 模型的微调。查看 [PR #8976](https://github.com/hiyouga/LLaMA-Factory/pull/8976) 以使用。
|
| 124 |
+
|
| 125 |
+
[25/08/06] 我们支持了 **[GPT-OSS](https://github.com/openai/gpt-oss)** 模型的微调。查看 [PR #8826](https://github.com/hiyouga/LLaMA-Factory/pull/8826) 以使用。
|
| 126 |
+
|
| 127 |
+
[25/07/02] 我们支持了 **[GLM-4.1V-9B-Thinking](https://github.com/THUDM/GLM-4.1V-Thinking)** 模型的微调。
|
| 128 |
+
|
| 129 |
+
[25/04/28] 我们支持了 **[Qwen3](https://qwenlm.github.io/blog/qwen3/)** 系列模型的微调。
|
| 130 |
+
|
| 131 |
+
<details><summary>展开日志</summary>
|
| 132 |
+
|
| 133 |
+
[25/04/21] 我们支持了 **[Muon](https://github.com/KellerJordan/Muon)** 优化器。详细用法请参照 [examples](examples/README_zh.md)。感谢 [@tianshijing](https://github.com/tianshijing) 的 PR。
|
| 134 |
+
|
| 135 |
+
[25/04/16] 我们支持了 **[InternVL3](https://huggingface.co/OpenGVLab/InternVL3-8B)** 模型的微调。查看 [PR #7258](https://github.com/hiyouga/LLaMA-Factory/pull/7258) 以使用。
|
| 136 |
+
|
| 137 |
+
[25/04/14] 我们支持了 **[GLM-Z1](https://huggingface.co/THUDM/GLM-Z1-9B-0414)** 和 **[Kimi-VL](https://huggingface.co/moonshotai/Kimi-VL-A3B-Instruct)** 模型的微调。
|
| 138 |
+
|
| 139 |
+
[25/04/06] 我们支持了 **[Llama 4](https://ai.meta.com/blog/llama-4-multimodal-intelligence/)** 模型的微调。查看 [PR #7611](https://github.com/hiyouga/LLaMA-Factory/pull/7611) 以使用。
|
| 140 |
+
|
| 141 |
+
[25/03/31] 我们支持了 **[Qwen2.5 Omni](https://qwenlm.github.io/blog/qwen2.5-omni/)** 模型的微调。查看 [PR #7537](https://github.com/hiyouga/LLaMA-Factory/pull/7537) 以使用。
|
| 142 |
+
|
| 143 |
+
[25/03/15] 我们支持了 **[SGLang](https://github.com/sgl-project/sglang)** 推理后端,请使用 `infer_backend: sglang` 启用。
|
| 144 |
+
|
| 145 |
+
[25/03/12] 我们支持了 **[Gemma 3](https://huggingface.co/blog/gemma3)** 模型的微调。
|
| 146 |
+
|
| 147 |
+
[25/02/24] 我们宣布开源 **[EasyR1](https://github.com/hiyouga/EasyR1)**,一个高效可扩展的多模态强化学习框架,支持高效的 GRPO 训练。
|
| 148 |
+
|
| 149 |
+
[25/02/11] 我们支持了在导出模型时保存 **[Ollama](https://github.com/ollama/ollama)** 配置文件。详细用法请参照 [examples](examples/README_zh.md)。
|
| 150 |
+
|
| 151 |
+
[25/02/05] 我们支持了在语音理解任务上微调 **[Qwen2-Audio](Qwen/Qwen2-Audio-7B-Instruct)** 和 **[MiniCPM-o-2.6](https://huggingface.co/openbmb/MiniCPM-o-2_6)** 模型。
|
| 152 |
+
|
| 153 |
+
[25/01/31] 我们支持了 **[DeepSeek-R1](https://huggingface.co/deepseek-ai/DeepSeek-R1)** 和 **[Qwen2.5-VL](https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct)** 模型的微调。
|
| 154 |
+
|
| 155 |
+
[25/01/15] 我们支持了 **[APOLLO](https://arxiv.org/abs/2412.05270)** 优化器。详细用法请参照 [examples](examples/README_zh.md)。
|
| 156 |
+
|
| 157 |
+
[25/01/14] 我们支持了 **[MiniCPM-o-2.6](https://huggingface.co/openbmb/MiniCPM-o-2_6)** 和 **[MiniCPM-V-2.6](https://huggingface.co/openbmb/MiniCPM-V-2_6)** 模型的微调。 感谢 [@BUAADreamer](https://github.com/BUAADreamer) 的 PR.
|
| 158 |
+
|
| 159 |
+
[25/01/14] 我们支持了 **[InternLM 3](https://huggingface.co/collections/internlm/)** 模型的微调。感谢 [@hhaAndroid](https://github.com/hhaAndroid) 的 PR。
|
| 160 |
+
|
| 161 |
+
[25/01/10] 我们支持了 **[Phi-4](https://huggingface.co/microsoft/phi-4)** 模型的微调。
|
| 162 |
+
|
| 163 |
+
[24/12/21] 我们支持了使用 **[SwanLab](https://github.com/SwanHubX/SwanLab)** 跟踪与可视化实验。详细用法请参考 [此部分](#使用-swanlab-面板)。
|
| 164 |
+
|
| 165 |
+
[24/11/27] 我们支持了 **[Skywork-o1](https://huggingface.co/Skywork/Skywork-o1-Open-Llama-3.1-8B)** 模型的微调和 **[OpenO1](https://huggingface.co/datasets/O1-OPEN/OpenO1-SFT)** 数据集。
|
| 166 |
+
|
| 167 |
+
[24/10/09] 我们支持了从 **[魔乐社区](https://modelers.cn/models)** 下载预训练模型和数据集。详细用法请参照 [此教程](#从魔乐社区下载)。
|
| 168 |
+
|
| 169 |
+
[24/09/19] 我们支持了 **[Qwen2.5](https://qwenlm.github.io/blog/qwen2.5/)** 模型的微调。
|
| 170 |
+
|
| 171 |
+
[24/08/30] 我们支持了 **[Qwen2-VL](https://qwenlm.github.io/blog/qwen2-vl/)** 模型的微调。感谢 [@simonJJJ](https://github.com/simonJJJ) 的 PR。
|
| 172 |
+
|
| 173 |
+
[24/08/27] 我们支持了 **[Liger Kernel](https://github.com/linkedin/Liger-Kernel)**。请使用 `enable_liger_kernel: true` 来加速训练。
|
| 174 |
+
|
| 175 |
+
[24/08/09] 我们支持了 **[Adam-mini](https://github.com/zyushun/Adam-mini)** 优化器。详细用法请参照 [examples](examples/README_zh.md)。感谢 [@relic-yuexi](https://github.com/relic-yuexi) 的 PR。
|
| 176 |
+
|
| 177 |
+
[24/07/04] 我们支持了[无污染打包训练](https://github.com/MeetKai/functionary/tree/main/functionary/train/packing)。请使用 `neat_packing: true` 参数。感谢 [@chuan298](https://github.com/chuan298) 的 PR。
|
| 178 |
+
|
| 179 |
+
[24/06/16] 我们支持了 **[PiSSA](https://arxiv.org/abs/2404.02948)** 算法。详细用法请参照 [examples](examples/README_zh.md)。
|
| 180 |
+
|
| 181 |
+
[24/06/07] 我们支持了 **[Qwen2](https://qwenlm.github.io/blog/qwen2/)** 和 **[GLM-4](https://github.com/THUDM/GLM-4)** 模型的微调。
|
| 182 |
+
|
| 183 |
+
[24/05/26] 我们支持了 **[SimPO](https://arxiv.org/abs/2405.14734)** 偏好对齐算法。详细用法请参照 [examples](examples/README_zh.md)。
|
| 184 |
+
|
| 185 |
+
[24/05/20] 我们支持了 **PaliGemma** 系列模型的微调。注意 PaliGemma 是预训练模型,你需要使用 `paligemma` 模板进行微调使其获得对话能力。
|
| 186 |
+
|
| 187 |
+
[24/05/18] 我们支持了 **[KTO](https://arxiv.org/abs/2402.01306)** 偏好对齐算法。详细用法请参照 [examples](examples/README_zh.md)。
|
| 188 |
+
|
| 189 |
+
[24/05/14] 我们支持了昇腾 NPU 设备的训练和推理。详情请查阅[安装](#安装-llama-factory)部分。
|
| 190 |
+
|
| 191 |
+
[24/04/26] 我们支持了多模态模型 **LLaVA-1.5** 的微调。详细用法请参照 [examples](examples/README_zh.md)。
|
| 192 |
+
|
| 193 |
+
[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)。
|
| 194 |
+
|
| 195 |
+
[24/04/21] 我们基于 [AstraMindAI 的仓库](https://github.com/astramind-ai/Mixture-of-depths)支持了 **[混合深度训练](https://arxiv.org/abs/2404.02258)**。详细用法请参照 [examples](examples/README_zh.md)。
|
| 196 |
+
|
| 197 |
+
[24/04/16] 我们支持了 **[BAdam](https://arxiv.org/abs/2404.02827)** 优化器。详细用法请参照 [examples](examples/README_zh.md)。
|
| 198 |
+
|
| 199 |
+
[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)。
|
| 200 |
+
|
| 201 |
+
[24/03/31] 我们支持了 **[ORPO](https://arxiv.org/abs/2403.07691)**。详细用法请参照 [examples](examples/README_zh.md)。
|
| 202 |
+
|
| 203 |
+
[24/03/21] 我们的论文 "[LlamaFactory: Unified Efficient Fine-Tuning of 100+ Language Models](https://arxiv.org/abs/2403.13372)" 可在 arXiv 上查看!
|
| 204 |
+
|
| 205 |
+
[24/03/20] 我们支持了能在 2x24GB GPU 上微调 70B 模型的 **FSDP+QLoRA**。详细用法请参照 [examples](examples/README_zh.md)。
|
| 206 |
+
|
| 207 |
+
[24/03/13] 我们支持了 **[LoRA+](https://arxiv.org/abs/2402.12354)**。详细用法请参照 [examples](examples/README_zh.md)。
|
| 208 |
+
|
| 209 |
+
[24/03/07] 我们支持了 **[GaLore](https://arxiv.org/abs/2403.03507)** 优化器。详细用法请参照 [examples](examples/README_zh.md)。
|
| 210 |
+
|
| 211 |
+
[24/03/07] 我们集成了 **[vLLM](https://github.com/vllm-project/vllm)** 以实现极速并发推理。请使用 `infer_backend: vllm` 来获得 **270%** 的推理速度。
|
| 212 |
+
|
| 213 |
+
[24/02/28] 我们支持了 **[DoRA](https://arxiv.org/abs/2402.09353)** 微调。请使用 `use_dora: true` 参数进行 DoRA 微调。
|
| 214 |
+
|
| 215 |
+
[24/02/15] 我们支持了 [LLaMA Pro](https://github.com/TencentARC/LLaMA-Pro) 提出的**块扩展**方法。详细用法请参照 [examples](examples/README_zh.md)。
|
| 216 |
+
|
| 217 |
+
[24/02/05] Qwen1.5(Qwen2 测试版)系列模型已在 LLaMA-Factory 中实现微调支持。详情请查阅该[博客页面](https://qwenlm.github.io/zh/blog/qwen1.5/)。
|
| 218 |
+
|
| 219 |
+
[24/01/18] 我们针对绝大多数模型实现了 **Agent 微调**,微调时指定 `dataset: glaive_toolcall_zh` 即可使模型获得工具调用能力。
|
| 220 |
+
|
| 221 |
+
[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)。
|
| 222 |
+
|
| 223 |
+
[23/12/12] 我们支持了微调最新的混合专家模型 **[Mixtral 8x7B](https://huggingface.co/mistralai/Mixtral-8x7B-v0.1)**。硬件需求请查阅[此处](#硬件依赖)。
|
| 224 |
+
|
| 225 |
+
[23/12/01] 我们支持了从 **[魔搭社区](https://modelscope.cn/models)** 下载预训练模型和数据集。详细用法请参照 [此教程](#从魔搭社区下载)。
|
| 226 |
+
|
| 227 |
+
[23/10/21] 我们支持了 **[NEFTune](https://arxiv.org/abs/2310.05914)** 训练技巧。请使用 `neftune_noise_alpha: 5` 参数启用 NEFTune。
|
| 228 |
+
|
| 229 |
+
[23/09/27] 我们针对 LLaMA 模型支持了 [LongLoRA](https://github.com/dvlab-research/LongLoRA) 提出的 **$S^2$-Attn**。请使用 `shift_attn: true` 参数以启用该功能。
|
| 230 |
+
|
| 231 |
+
[23/09/23] 我们在项目中集成了 MMLU、C-Eval 和 CMMLU 评估集。详细用法请参照 [examples](examples/README_zh.md)。
|
| 232 |
+
|
| 233 |
+
[23/09/10] 我们支持了 **[FlashAttention-2](https://github.com/Dao-AILab/flash-attention)**。如果您使用的是 RTX4090、A100 或 H100 GPU,请使用 `flash_attn: fa2` 参数以启用 FlashAttention-2。
|
| 234 |
+
|
| 235 |
+
[23/08/12] 我们支持了 **RoPE 插值**来扩展 LLaMA 模型的上下文长度。请使用 `rope_scaling: linear` 参数训练模型或使用 `rope_scaling: dynamic` 参数评估模型。
|
| 236 |
+
|
| 237 |
+
[23/08/11] 我们支持了指令模型的 **[DPO 训练](https://arxiv.org/abs/2305.18290)**。详细用法请参照 [examples](examples/README_zh.md)。
|
| 238 |
+
|
| 239 |
+
[23/07/31] 我们支持了**数据流式加载**。请使用 `streaming: true` 和 `max_steps: 10000` 参数来流式加载数据集。
|
| 240 |
+
|
| 241 |
+
[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))。
|
| 242 |
+
|
| 243 |
+
[23/07/18] 我们开发了支持训练和测试的**浏览器一体化界面**。请使用 `train_web.py` 在您的浏览器中微调模型。感谢 [@KanadeSiina](https://github.com/KanadeSiina) 和 [@codemayq](https://github.com/codemayq) 在该功能开发中付出的努力。
|
| 244 |
+
|
| 245 |
+
[23/07/09] 我们开源了 **[FastEdit](https://github.com/hiyouga/FastEdit)** ⚡🩹,一个简单易用的、能迅速编辑大模型事实记忆的工具包。如果您感兴趣请关注我们的 [FastEdit](https://github.com/hiyouga/FastEdit) 项目。
|
| 246 |
+
|
| 247 |
+
[23/06/29] 我们提供了一个**可复现的**指令模型微调示例,详细内容请查阅 [Baichuan-7B-sft](https://huggingface.co/hiyouga/Baichuan-7B-sft)。
|
| 248 |
+
|
| 249 |
+
[23/06/22] 我们对齐了[示例 API](src/api_demo.py) 与 [OpenAI API](https://platform.openai.com/docs/api-reference/chat) 的格式,您可以将微调模型接入**任意基于 ChatGPT 的应用**中。
|
| 250 |
+
|
| 251 |
+
[23/06/03] 我们实现了 4 比特的 LoRA 训练(也称 **[QLoRA](https://github.com/artidoro/qlora)**)。详细用法请参照 [examples](examples/README_zh.md)。
|
| 252 |
+
|
| 253 |
+
</details>
|
| 254 |
+
|
| 255 |
+
> [!TIP]
|
| 256 |
+
> 如果您无法使用最新的功能,请尝试重新拉取代码并再次安装 LLaMA-Factory。
|
| 257 |
+
|
| 258 |
+
## 模型
|
| 259 |
+
|
| 260 |
+
| 模型名 | 参数量 | Template |
|
| 261 |
+
| ----------------------------------------------------------------- | -------------------------------- | ------------------- |
|
| 262 |
+
| [Baichuan 2](https://huggingface.co/baichuan-inc) | 7B/13B | baichuan2 |
|
| 263 |
+
| [BLOOM/BLOOMZ](https://huggingface.co/bigscience) | 560M/1.1B/1.7B/3B/7.1B/176B | - |
|
| 264 |
+
| [ChatGLM3](https://huggingface.co/THUDM) | 6B | chatglm3 |
|
| 265 |
+
| [Command R](https://huggingface.co/CohereForAI) | 35B/104B | cohere |
|
| 266 |
+
| [DeepSeek (Code/MoE)](https://huggingface.co/deepseek-ai) | 7B/16B/67B/236B | deepseek |
|
| 267 |
+
| [DeepSeek 2.5/3](https://huggingface.co/deepseek-ai) | 236B/671B | deepseek3 |
|
| 268 |
+
| [DeepSeek R1 (Distill)](https://huggingface.co/deepseek-ai) | 1.5B/7B/8B/14B/32B/70B/671B | deepseekr1 |
|
| 269 |
+
| [Falcon](https://huggingface.co/tiiuae) | 7B/11B/40B/180B | falcon |
|
| 270 |
+
| [Falcon-H1](https://huggingface.co/tiiuae) | 0.5B/1.5B/3B/7B/34B | falcon_h1 |
|
| 271 |
+
| [Gemma/Gemma 2/CodeGemma](https://huggingface.co/google) | 2B/7B/9B/27B | gemma/gemma2 |
|
| 272 |
+
| [Gemma 3/Gemma 3n](https://huggingface.co/google) | 270M/1B/4B/6B/8B/12B/27B | gemma3/gemma3n |
|
| 273 |
+
| [GLM-4/GLM-4-0414/GLM-Z1](https://huggingface.co/zai-org) | 9B/32B | glm4/glmz1 |
|
| 274 |
+
| [GLM-4.1V](https://huggingface.co/zai-org) | 9B | glm4v |
|
| 275 |
+
| [GLM-4.5/GLM-4.5V](https://huggingface.co/zai-org)* | 106B/355B | glm4_moe/glm4v_moe |
|
| 276 |
+
| [GPT-2](https://huggingface.co/openai-community) | 0.1B/0.4B/0.8B/1.5B | - |
|
| 277 |
+
| [GPT-OSS](https://huggingface.co/openai) | 20B/120B | gpt |
|
| 278 |
+
| [Granite 3.0-3.3](https://huggingface.co/ibm-granite) | 1B/2B/3B/8B | granite3 |
|
| 279 |
+
| [Granite 4](https://huggingface.co/ibm-granite) | 7B | granite4 |
|
| 280 |
+
| [Hunyuan](https://huggingface.co/tencent/) | 7B | hunyuan |
|
| 281 |
+
| [Index](https://huggingface.co/IndexTeam) | 1.9B | index |
|
| 282 |
+
| [InternLM 2-3](https://huggingface.co/internlm) | 7B/8B/20B | intern2 |
|
| 283 |
+
| [InternVL 2.5-3](https://huggingface.co/OpenGVLab) | 1B/2B/8B/14B/38B/78B | intern_vl |
|
| 284 |
+
| [InternLM/Intern-S1-mini](https://huggingface.co/internlm/) | 8B | intern_s1 |
|
| 285 |
+
| [Kimi-VL](https://huggingface.co/moonshotai) | 16B | kimi_vl |
|
| 286 |
+
| [Llama](https://github.com/facebookresearch/llama) | 7B/13B/33B/65B | - |
|
| 287 |
+
| [Llama 2](https://huggingface.co/meta-llama) | 7B/13B/70B | llama2 |
|
| 288 |
+
| [Llama 3-3.3](https://huggingface.co/meta-llama) | 1B/3B/8B/70B | llama3 |
|
| 289 |
+
| [Llama 4](https://huggingface.co/meta-llama) | 109B/402B | llama4 |
|
| 290 |
+
| [Llama 3.2 Vision](https://huggingface.co/meta-llama) | 11B/90B | mllama |
|
| 291 |
+
| [LLaVA-1.5](https://huggingface.co/llava-hf) | 7B/13B | llava |
|
| 292 |
+
| [LLaVA-NeXT](https://huggingface.co/llava-hf) | 7B/8B/13B/34B/72B/110B | llava_next |
|
| 293 |
+
| [LLaVA-NeXT-Video](https://huggingface.co/llava-hf) | 7B/34B | llava_next_video |
|
| 294 |
+
| [MiMo](https://huggingface.co/XiaomiMiMo) | 7B | mimo |
|
| 295 |
+
| [MiniCPM](https://huggingface.co/openbmb) | 0.5B/1B/2B/4B/8B | cpm/cpm3/cpm4 |
|
| 296 |
+
| [MiniCPM-o-2.6/MiniCPM-V-2.6](https://huggingface.co/openbmb) | 8B | minicpm_o/minicpm_v |
|
| 297 |
+
| [Ministral/Mistral-Nemo](https://huggingface.co/mistralai) | 8B/12B | ministral |
|
| 298 |
+
| [Mistral/Mixtral](https://huggingface.co/mistralai) | 7B/8x7B/8x22B | mistral |
|
| 299 |
+
| [Mistral Small](https://huggingface.co/mistralai) | 24B | mistral_small |
|
| 300 |
+
| [OLMo](https://huggingface.co/allenai) | 1B/7B | - |
|
| 301 |
+
| [PaliGemma/PaliGemma2](https://huggingface.co/google) | 3B/10B/28B | paligemma |
|
| 302 |
+
| [Phi-1.5/Phi-2](https://huggingface.co/microsoft) | 1.3B/2.7B | - |
|
| 303 |
+
| [Phi-3/Phi-3.5](https://huggingface.co/microsoft) | 4B/14B | phi |
|
| 304 |
+
| [Phi-3-small](https://huggingface.co/microsoft) | 7B | phi_small |
|
| 305 |
+
| [Phi-4](https://huggingface.co/microsoft) | 14B | phi4 |
|
| 306 |
+
| [Pixtral](https://huggingface.co/mistralai) | 12B | pixtral |
|
| 307 |
+
| [Qwen (1-2.5) (Code/Math/MoE/QwQ)](https://huggingface.co/Qwen) | 0.5B/1.5B/3B/7B/14B/32B/72B/110B | qwen |
|
| 308 |
+
| [Qwen3 (MoE/Instruct/Thinking)](https://huggingface.co/Qwen) | 0.6B/1.7B/4B/8B/14B/32B/235B | qwen3/qwen3_nothink |
|
| 309 |
+
| [Qwen2-Audio](https://huggingface.co/Qwen) | 7B | qwen2_audio |
|
| 310 |
+
| [Qwen2.5-Omni](https://huggingface.co/Qwen) | 3B/7B | qwen2_omni |
|
| 311 |
+
| [Qwen2-VL/Qwen2.5-VL/QVQ](https://huggingface.co/Qwen) | 2B/3B/7B/32B/72B | qwen2_vl |
|
| 312 |
+
| [Seed Coder](https://huggingface.co/ByteDance-Seed) | 8B | seed_coder |
|
| 313 |
+
| [Skywork o1](https://huggingface.co/Skywork) | 8B | skywork_o1 |
|
| 314 |
+
| [StarCoder 2](https://huggingface.co/bigcode) | 3B/7B/15B | - |
|
| 315 |
+
| [TeleChat2](https://huggingface.co/Tele-AI) | 3B/7B/35B/115B | telechat2 |
|
| 316 |
+
| [XVERSE](https://huggingface.co/xverse) | 7B/13B/65B | xverse |
|
| 317 |
+
| [Yi/Yi-1.5 (Code)](https://huggingface.co/01-ai) | 1.5B/6B/9B/34B | yi |
|
| 318 |
+
| [Yi-VL](https://huggingface.co/01-ai) | 6B/34B | yi_vl |
|
| 319 |
+
| [Yuan 2](https://huggingface.co/IEITYuan) | 2B/51B/102B | yuan |
|
| 320 |
+
|
| 321 |
+
> [!NOTE]
|
| 322 |
+
> 对于所有“基座”(Base)模型,`template` 参数可以是 `default`, `alpaca`, `vicuna` 等任意值。但“对话”(Instruct/Chat)模型请务必使用**对应的模板**。
|
| 323 |
+
>
|
| 324 |
+
> 请务必在训练和推理时采用**完全一致**的模板。
|
| 325 |
+
>
|
| 326 |
+
> \*:您需要从 main 分支安装 `transformers` 并使用 `DISABLE_VERSION_CHECK=1` 来跳过版本检查。
|
| 327 |
+
>
|
| 328 |
+
> \*\*:您需要安装特定版本的 `transformers` 以使用该模型。
|
| 329 |
+
|
| 330 |
+
项目所支持模型的完整列表请参阅 [constants.py](src/llamafactory/extras/constants.py)。
|
| 331 |
+
|
| 332 |
+
您也可以在 [template.py](src/llamafactory/data/template.py) 中添加自己的对话模板。
|
| 333 |
+
|
| 334 |
+
## 训练方法
|
| 335 |
+
|
| 336 |
+
| 方法 | 全参数训练 | 部分参数训练 | LoRA | QLoRA |
|
| 337 |
+
| --------------------- | ------------------ | ------------------ | ------------------ | ------------------ |
|
| 338 |
+
| 预训练 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
| 339 |
+
| 指令监督微调 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
| 340 |
+
| 奖励模型训练 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
| 341 |
+
| PPO 训练 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
| 342 |
+
| DPO 训练 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
| 343 |
+
| KTO 训练 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
| 344 |
+
| ORPO 训练 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
| 345 |
+
| SimPO 训练 | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
| 346 |
+
|
| 347 |
+
> [!TIP]
|
| 348 |
+
> 有关 PPO 的实现细节,请参考[此博客](https://newfacade.github.io/notes-on-reinforcement-learning/17-ppo-trl.html)。
|
| 349 |
+
|
| 350 |
+
## 数据集
|
| 351 |
+
|
| 352 |
+
<details><summary>预训练数据集</summary>
|
| 353 |
+
|
| 354 |
+
- [Wiki Demo (en)](data/wiki_demo.txt)
|
| 355 |
+
- [RefinedWeb (en)](https://huggingface.co/datasets/tiiuae/falcon-refinedweb)
|
| 356 |
+
- [RedPajama V2 (en)](https://huggingface.co/datasets/togethercomputer/RedPajama-Data-V2)
|
| 357 |
+
- [Wikipedia (en)](https://huggingface.co/datasets/olm/olm-wikipedia-20221220)
|
| 358 |
+
- [Wikipedia (zh)](https://huggingface.co/datasets/pleisto/wikipedia-cn-20230720-filtered)
|
| 359 |
+
- [Pile (en)](https://huggingface.co/datasets/EleutherAI/pile)
|
| 360 |
+
- [SkyPile (zh)](https://huggingface.co/datasets/Skywork/SkyPile-150B)
|
| 361 |
+
- [FineWeb (en)](https://huggingface.co/datasets/HuggingFaceFW/fineweb)
|
| 362 |
+
- [FineWeb-Edu (en)](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu)
|
| 363 |
+
- [The Stack (en)](https://huggingface.co/datasets/bigcode/the-stack)
|
| 364 |
+
- [StarCoder (en)](https://huggingface.co/datasets/bigcode/starcoderdata)
|
| 365 |
+
|
| 366 |
+
</details>
|
| 367 |
+
|
| 368 |
+
<details><summary>指令微调数据集</summary>
|
| 369 |
+
|
| 370 |
+
- [Identity (en&zh)](data/identity.json)
|
| 371 |
+
- [Stanford Alpaca (en)](https://github.com/tatsu-lab/stanford_alpaca)
|
| 372 |
+
- [Stanford Alpaca (zh)](https://github.com/ymcui/Chinese-LLaMA-Alpaca-3)
|
| 373 |
+
- [Alpaca GPT4 (en&zh)](https://github.com/Instruction-Tuning-with-GPT-4/GPT-4-LLM)
|
| 374 |
+
- [Glaive Function Calling V2 (en&zh)](https://huggingface.co/datasets/glaiveai/glaive-function-calling-v2)
|
| 375 |
+
- [LIMA (en)](https://huggingface.co/datasets/GAIR/lima)
|
| 376 |
+
- [Guanaco Dataset (multilingual)](https://huggingface.co/datasets/JosephusCheung/GuanacoDataset)
|
| 377 |
+
- [BELLE 2M (zh)](https://huggingface.co/datasets/BelleGroup/train_2M_CN)
|
| 378 |
+
- [BELLE 1M (zh)](https://huggingface.co/datasets/BelleGroup/train_1M_CN)
|
| 379 |
+
- [BELLE 0.5M (zh)](https://huggingface.co/datasets/BelleGroup/train_0.5M_CN)
|
| 380 |
+
- [BELLE Dialogue 0.4M (zh)](https://huggingface.co/datasets/BelleGroup/generated_chat_0.4M)
|
| 381 |
+
- [BELLE School Math 0.25M (zh)](https://huggingface.co/datasets/BelleGroup/school_math_0.25M)
|
| 382 |
+
- [BELLE Multiturn Chat 0.8M (zh)](https://huggingface.co/datasets/BelleGroup/multiturn_chat_0.8M)
|
| 383 |
+
- [UltraChat (en)](https://github.com/thunlp/UltraChat)
|
| 384 |
+
- [OpenPlatypus (en)](https://huggingface.co/datasets/garage-bAInd/Open-Platypus)
|
| 385 |
+
- [CodeAlpaca 20k (en)](https://huggingface.co/datasets/sahil2801/CodeAlpaca-20k)
|
| 386 |
+
- [Alpaca CoT (multilingual)](https://huggingface.co/datasets/QingyiSi/Alpaca-CoT)
|
| 387 |
+
- [OpenOrca (en)](https://huggingface.co/datasets/Open-Orca/OpenOrca)
|
| 388 |
+
- [SlimOrca (en)](https://huggingface.co/datasets/Open-Orca/SlimOrca)
|
| 389 |
+
- [MathInstruct (en)](https://huggingface.co/datasets/TIGER-Lab/MathInstruct)
|
| 390 |
+
- [Firefly 1.1M (zh)](https://huggingface.co/datasets/YeungNLP/firefly-train-1.1M)
|
| 391 |
+
- [Wiki QA (en)](https://huggingface.co/datasets/wiki_qa)
|
| 392 |
+
- [Web QA (zh)](https://huggingface.co/datasets/suolyer/webqa)
|
| 393 |
+
- [WebNovel (zh)](https://huggingface.co/datasets/zxbsmk/webnovel_cn)
|
| 394 |
+
- [Nectar (en)](https://huggingface.co/datasets/berkeley-nest/Nectar)
|
| 395 |
+
- [deepctrl (en&zh)](https://www.modelscope.cn/datasets/deepctrl/deepctrl-sft-data)
|
| 396 |
+
- [Advertise Generating (zh)](https://huggingface.co/datasets/HasturOfficial/adgen)
|
| 397 |
+
- [ShareGPT Hyperfiltered (en)](https://huggingface.co/datasets/totally-not-an-llm/sharegpt-hyperfiltered-3k)
|
| 398 |
+
- [ShareGPT4 (en&zh)](https://huggingface.co/datasets/shibing624/sharegpt_gpt4)
|
| 399 |
+
- [UltraChat 200k (en)](https://huggingface.co/datasets/HuggingFaceH4/ultrachat_200k)
|
| 400 |
+
- [AgentInstruct (en)](https://huggingface.co/datasets/THUDM/AgentInstruct)
|
| 401 |
+
- [LMSYS Chat 1M (en)](https://huggingface.co/datasets/lmsys/lmsys-chat-1m)
|
| 402 |
+
- [Evol Instruct V2 (en)](https://huggingface.co/datasets/WizardLM/WizardLM_evol_instruct_V2_196k)
|
| 403 |
+
- [Cosmopedia (en)](https://huggingface.co/datasets/HuggingFaceTB/cosmopedia)
|
| 404 |
+
- [STEM (zh)](https://huggingface.co/datasets/hfl/stem_zh_instruction)
|
| 405 |
+
- [Ruozhiba (zh)](https://huggingface.co/datasets/hfl/ruozhiba_gpt4_turbo)
|
| 406 |
+
- [Neo-sft (zh)](https://huggingface.co/datasets/m-a-p/neo_sft_phase2)
|
| 407 |
+
- [Magpie-Pro-300K-Filtered (en)](https://huggingface.co/datasets/Magpie-Align/Magpie-Pro-300K-Filtered)
|
| 408 |
+
- [Magpie-ultra-v0.1 (en)](https://huggingface.co/datasets/argilla/magpie-ultra-v0.1)
|
| 409 |
+
- [WebInstructSub (en)](https://huggingface.co/datasets/TIGER-Lab/WebInstructSub)
|
| 410 |
+
- [OpenO1-SFT (en&zh)](https://huggingface.co/datasets/O1-OPEN/OpenO1-SFT)
|
| 411 |
+
- [Open-Thoughts (en)](https://huggingface.co/datasets/open-thoughts/OpenThoughts-114k)
|
| 412 |
+
- [Open-R1-Math (en)](https://huggingface.co/datasets/open-r1/OpenR1-Math-220k)
|
| 413 |
+
- [Chinese-DeepSeek-R1-Distill (zh)](https://huggingface.co/datasets/Congliu/Chinese-DeepSeek-R1-Distill-data-110k-SFT)
|
| 414 |
+
- [LLaVA mixed (en&zh)](https://huggingface.co/datasets/BUAADreamer/llava-en-zh-300k)
|
| 415 |
+
- [Pokemon-gpt4o-captions (en&zh)](https://huggingface.co/datasets/jugg1024/pokemon-gpt4o-captions)
|
| 416 |
+
- [Open Assistant (de)](https://huggingface.co/datasets/mayflowergmbh/oasst_de)
|
| 417 |
+
- [Dolly 15k (de)](https://huggingface.co/datasets/mayflowergmbh/dolly-15k_de)
|
| 418 |
+
- [Alpaca GPT4 (de)](https://huggingface.co/datasets/mayflowergmbh/alpaca-gpt4_de)
|
| 419 |
+
- [OpenSchnabeltier (de)](https://huggingface.co/datasets/mayflowergmbh/openschnabeltier_de)
|
| 420 |
+
- [Evol Instruct (de)](https://huggingface.co/datasets/mayflowergmbh/evol-instruct_de)
|
| 421 |
+
- [Dolphin (de)](https://huggingface.co/datasets/mayflowergmbh/dolphin_de)
|
| 422 |
+
- [Booksum (de)](https://huggingface.co/datasets/mayflowergmbh/booksum_de)
|
| 423 |
+
- [Airoboros (de)](https://huggingface.co/datasets/mayflowergmbh/airoboros-3.0_de)
|
| 424 |
+
- [Ultrachat (de)](https://huggingface.co/datasets/mayflowergmbh/ultra-chat_de)
|
| 425 |
+
|
| 426 |
+
</details>
|
| 427 |
+
|
| 428 |
+
<details><summary>偏好数据集</summary>
|
| 429 |
+
|
| 430 |
+
- [DPO mixed (en&zh)](https://huggingface.co/datasets/hiyouga/DPO-En-Zh-20k)
|
| 431 |
+
- [UltraFeedback (en)](https://huggingface.co/datasets/HuggingFaceH4/ultrafeedback_binarized)
|
| 432 |
+
- [COIG-P (zh)](https://huggingface.co/datasets/m-a-p/COIG-P)
|
| 433 |
+
- [RLHF-V (en)](https://huggingface.co/datasets/openbmb/RLHF-V-Dataset)
|
| 434 |
+
- [VLFeedback (en)](https://huggingface.co/datasets/Zhihui/VLFeedback)
|
| 435 |
+
- [RLAIF-V (en)](https://huggingface.co/datasets/openbmb/RLAIF-V-Dataset)
|
| 436 |
+
- [Orca DPO Pairs (en)](https://huggingface.co/datasets/Intel/orca_dpo_pairs)
|
| 437 |
+
- [HH-RLHF (en)](https://huggingface.co/datasets/Anthropic/hh-rlhf)
|
| 438 |
+
- [Nectar (en)](https://huggingface.co/datasets/berkeley-nest/Nectar)
|
| 439 |
+
- [Orca DPO (de)](https://huggingface.co/datasets/mayflowergmbh/intel_orca_dpo_pairs_de)
|
| 440 |
+
- [KTO mixed (en)](https://huggingface.co/datasets/argilla/kto-mix-15k)
|
| 441 |
+
|
| 442 |
+
</details>
|
| 443 |
+
|
| 444 |
+
部分数据集的使用需要确认,我们推荐使用下述命令登录您的 Hugging Face 账户。
|
| 445 |
+
|
| 446 |
+
```bash
|
| 447 |
+
pip install --upgrade huggingface_hub
|
| 448 |
+
huggingface-cli login
|
| 449 |
+
```
|
| 450 |
+
|
| 451 |
+
## 软硬件依赖
|
| 452 |
+
|
| 453 |
+
| 必需项 | 至少 | 推荐 |
|
| 454 |
+
| ------------ | ------- | --------- |
|
| 455 |
+
| python | 3.9 | 3.10 |
|
| 456 |
+
| torch | 2.0.0 | 2.6.0 |
|
| 457 |
+
| torchvision | 0.15.0 | 0.21.0 |
|
| 458 |
+
| transformers | 4.49.0 | 4.50.0 |
|
| 459 |
+
| datasets | 2.16.0 | 3.2.0 |
|
| 460 |
+
| accelerate | 0.34.0 | 1.2.1 |
|
| 461 |
+
| peft | 0.14.0 | 0.15.1 |
|
| 462 |
+
| trl | 0.8.6 | 0.9.6 |
|
| 463 |
+
|
| 464 |
+
| 可选项 | 至少 | 推荐 |
|
| 465 |
+
| ------------ | ------- | --------- |
|
| 466 |
+
| CUDA | 11.6 | 12.2 |
|
| 467 |
+
| deepspeed | 0.10.0 | 0.16.4 |
|
| 468 |
+
| bitsandbytes | 0.39.0 | 0.43.1 |
|
| 469 |
+
| vllm | 0.4.3 | 0.8.2 |
|
| 470 |
+
| flash-attn | 2.5.6 | 2.7.2 |
|
| 471 |
+
|
| 472 |
+
### 硬件依赖
|
| 473 |
+
|
| 474 |
+
\* *估算值*
|
| 475 |
+
|
| 476 |
+
| 方法 | 精度 | 7B | 14B | 30B | 70B | `x`B |
|
| 477 |
+
| ------------------------------- | ---- | ----- | ----- | ----- | ------ | ------- |
|
| 478 |
+
| Full (`bf16` or `fp16`) | 32 | 120GB | 240GB | 600GB | 1200GB | `18x`GB |
|
| 479 |
+
| Full (`pure_bf16`) | 16 | 60GB | 120GB | 300GB | 600GB | `8x`GB |
|
| 480 |
+
| Freeze/LoRA/GaLore/APOLLO/BAdam | 16 | 16GB | 32GB | 64GB | 160GB | `2x`GB |
|
| 481 |
+
| QLoRA | 8 | 10GB | 20GB | 40GB | 80GB | `x`GB |
|
| 482 |
+
| QLoRA | 4 | 6GB | 12GB | 24GB | 48GB | `x/2`GB |
|
| 483 |
+
| QLoRA | 2 | 4GB | 8GB | 16GB | 24GB | `x/4`GB |
|
| 484 |
+
|
| 485 |
+
## 如何使用
|
| 486 |
+
|
| 487 |
+
### 安装 LLaMA Factory
|
| 488 |
+
|
| 489 |
+
> [!IMPORTANT]
|
| 490 |
+
> 此步骤为必需。
|
| 491 |
+
|
| 492 |
+
#### 从源码安装
|
| 493 |
+
|
| 494 |
+
```bash
|
| 495 |
+
git clone --depth 1 https://github.com/hiyouga/LLaMA-Factory.git
|
| 496 |
+
cd LLaMA-Factory
|
| 497 |
+
pip install -e ".[torch,metrics]" --no-build-isolation
|
| 498 |
+
```
|
| 499 |
+
|
| 500 |
+
可选的额外依赖项:torch、torch-npu、metrics、deepspeed、liger-kernel、bitsandbytes、hqq、eetq、gptq、aqlm、vllm、sglang、galore、apollo、badam、adam-mini、qwen、minicpm_v、openmind、swanlab、dev
|
| 501 |
+
|
| 502 |
+
#### 从镜像安装
|
| 503 |
+
|
| 504 |
+
```bash
|
| 505 |
+
docker run -it --rm --gpus=all --ipc=host hiyouga/llamafactory:latest
|
| 506 |
+
```
|
| 507 |
+
|
| 508 |
+
该镜像基于 Ubuntu 22.04(x86\_64)、CUDA 12.4、Python 3.11、PyTorch 2.6.0 和 Flash-attn 2.7.4 构建。
|
| 509 |
+
|
| 510 |
+
查看全部镜像:https://hub.docker.com/r/hiyouga/llamafactory/tags
|
| 511 |
+
|
| 512 |
+
请参阅[构建 Docker](#构建-docker) 来重新构建镜像。
|
| 513 |
+
|
| 514 |
+
<details><summary>使用 <b>uv</b> 构建虚拟环境</summary>
|
| 515 |
+
|
| 516 |
+
使用 [uv](https://github.com/astral-sh/uv) 创建隔离的 Python 环境:
|
| 517 |
+
|
| 518 |
+
```bash
|
| 519 |
+
uv sync --extra torch --extra metrics --prerelease=allow
|
| 520 |
+
```
|
| 521 |
+
|
| 522 |
+
在环境中运行 LLaMA-Factory:
|
| 523 |
+
|
| 524 |
+
```bash
|
| 525 |
+
uv run --prerelease=allow llamafactory-cli train examples/train_lora/llama3_lora_pretrain.yaml
|
| 526 |
+
```
|
| 527 |
+
|
| 528 |
+
</details>
|
| 529 |
+
|
| 530 |
+
<details><summary>Windows 用户指南</summary>
|
| 531 |
+
|
| 532 |
+
#### 安装 PyTorch
|
| 533 |
+
|
| 534 |
+
Windows 平台需要额外手动安装 GPU 版本的 PyTorch 依赖包,您可以参考[官方网站](https://pytorch.org/get-started/locally/)和以下命令安装并测试 PyTorch 是否正确安装。
|
| 535 |
+
|
| 536 |
+
```bash
|
| 537 |
+
pip uninstall torch torchvision torchaudio
|
| 538 |
+
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126
|
| 539 |
+
python -c "import torch; print(torch.cuda.is_available())"
|
| 540 |
+
```
|
| 541 |
+
|
| 542 |
+
如果看到 `True` 则说明安装成功。
|
| 543 |
+
|
| 544 |
+
若遇到类似 `Can't pickle local object` 的报错,请设置 `dataloader_num_workers: 0`。
|
| 545 |
+
|
| 546 |
+
#### 安装 BitsAndBytes
|
| 547 |
+
|
| 548 |
+
如果要在 Windows 平台上开启量化 LoRA(QLoRA),需要安装预编译的 `bitsandbytes` 库, 支持 CUDA 11.1 到 12.2, 请根据��的 CUDA 版本情况选择适合的[发布版本](https://github.com/jllllll/bitsandbytes-windows-webui/releases/tag/wheels)。
|
| 549 |
+
|
| 550 |
+
```bash
|
| 551 |
+
pip install https://github.com/jllllll/bitsandbytes-windows-webui/releases/download/wheels/bitsandbytes-0.41.2.post2-py3-none-win_amd64.whl
|
| 552 |
+
```
|
| 553 |
+
|
| 554 |
+
#### 安装 Flash Attention-2
|
| 555 |
+
|
| 556 |
+
如果要在 Windows 平台上开启 FlashAttention-2,请使用 [flash-attention-windows-wheel](https://huggingface.co/lldacing/flash-attention-windows-wheel) 中的脚本自行编译与安装。
|
| 557 |
+
|
| 558 |
+
</details>
|
| 559 |
+
|
| 560 |
+
<details><summary>昇腾 NPU 用户指南</summary>
|
| 561 |
+
|
| 562 |
+
在昇腾 NPU 设备上安装 LLaMA Factory 时,请升级 Python 到 3.10 及以上,并需要指定额外依赖项,使用 `pip install -e ".[torch-npu,metrics]"` 命令安装。此外,还需要安装 **[Ascend CANN Toolkit 与 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)或使用以下命令:
|
| 563 |
+
|
| 564 |
+
```bash
|
| 565 |
+
# 请替换 URL 为 CANN 版本和设备型号对应的 URL
|
| 566 |
+
# 安装 CANN Toolkit
|
| 567 |
+
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
|
| 568 |
+
bash Ascend-cann-toolkit_8.0.RC1.alpha001_linux-"$(uname -i)".run --install
|
| 569 |
+
|
| 570 |
+
# 安装 CANN Kernels
|
| 571 |
+
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
|
| 572 |
+
bash Ascend-cann-kernels-910b_8.0.RC1.alpha001_linux.run --install
|
| 573 |
+
|
| 574 |
+
# 设置环境变量
|
| 575 |
+
source /usr/local/Ascend/ascend-toolkit/set_env.sh
|
| 576 |
+
```
|
| 577 |
+
|
| 578 |
+
| 依赖项 | 至少 | 推荐 |
|
| 579 |
+
| ------------ | ------- | -------------- |
|
| 580 |
+
| CANN | 8.0.RC1 | 8.0.0.alpha002 |
|
| 581 |
+
| torch | 2.1.0 | 2.4.0 |
|
| 582 |
+
| torch-npu | 2.1.0 | 2.4.0.post2 |
|
| 583 |
+
| deepspeed | 0.13.2 | 0.13.2 |
|
| 584 |
+
| vllm-ascend | - | 0.7.3 |
|
| 585 |
+
|
| 586 |
+
请使用 `ASCEND_RT_VISIBLE_DEVICES` 而非 `CUDA_VISIBLE_DEVICES` 来指定运算设备。
|
| 587 |
+
|
| 588 |
+
如果遇到无法正常推理的情况,请尝试设置 `do_sample: false`。
|
| 589 |
+
|
| 590 |
+
下载预构建 Docker 镜像:[32GB](http://mirrors.cn-central-221.ovaijisuan.com/detail/130.html) | [64GB](http://mirrors.cn-central-221.ovaijisuan.com/detail/131.html)
|
| 591 |
+
|
| 592 |
+
#### 安装 BitsAndBytes
|
| 593 |
+
|
| 594 |
+
如果要在 Ascend NPU 上进行基于 bitsandbytes 的 QLoRA 量化微调,请执行如下步骤:
|
| 595 |
+
|
| 596 |
+
1. 手动编译 bitsandbytes:请参考[安装文档](https://huggingface.co/docs/bitsandbytes/installation?backend=Ascend+NPU&platform=Ascend+NPU)完成 NPU 版的 bitsandbytes 安装,编译要求环境 cmake 版本不低于 3.22.1,g++ 版本不低于 12.x。
|
| 597 |
+
|
| 598 |
+
```bash
|
| 599 |
+
# 从源码安装 bitsandbytes
|
| 600 |
+
# 克隆 bitsandbytes 仓库, Ascend NPU 目前在 multi-backend-refactor 中支持
|
| 601 |
+
git clone -b multi-backend-refactor https://github.com/bitsandbytes-foundation/bitsandbytes.git
|
| 602 |
+
cd bitsandbytes/
|
| 603 |
+
|
| 604 |
+
# 安装依赖
|
| 605 |
+
pip install -r requirements-dev.txt
|
| 606 |
+
|
| 607 |
+
# 安装编译工具依赖,该步骤在不同系统上命令有所不同,供参考
|
| 608 |
+
apt-get install -y build-essential cmake
|
| 609 |
+
|
| 610 |
+
# 编译 & 安装
|
| 611 |
+
cmake -DCOMPUTE_BACKEND=npu -S .
|
| 612 |
+
make
|
| 613 |
+
pip install .
|
| 614 |
+
```
|
| 615 |
+
|
| 616 |
+
2. 安装 transformers 的 main 分支版本。
|
| 617 |
+
|
| 618 |
+
```bash
|
| 619 |
+
git clone -b main https://github.com/huggingface/transformers.git
|
| 620 |
+
cd transformers
|
| 621 |
+
pip install .
|
| 622 |
+
```
|
| 623 |
+
|
| 624 |
+
3. 在训练参数中设置 `double_quantization: false`,可参考[示例](examples/train_qlora/llama3_lora_sft_bnb_npu.yaml)。
|
| 625 |
+
|
| 626 |
+
</details>
|
| 627 |
+
|
| 628 |
+
### 数据准备
|
| 629 |
+
|
| 630 |
+
关于数据集文件的格式,请参考 [data/README_zh.md](data/README_zh.md) 的内容。你可以使用 HuggingFace / ModelScope / Modelers 上的数据集或加载本地数据集。
|
| 631 |
+
|
| 632 |
+
> [!NOTE]
|
| 633 |
+
> 使用自定义数据集时,请更新 `data/dataset_info.json` 文件。
|
| 634 |
+
|
| 635 |
+
您也可以使用 **[Easy Dataset](https://github.com/ConardLi/easy-dataset)**、**[DataFlow](https://github.com/OpenDCAI/DataFlow)** 和 **[GraphGen](https://github.com/open-sciencelab/GraphGen)** 构建用于微调的合成数据。
|
| 636 |
+
|
| 637 |
+
### 快速开始
|
| 638 |
+
|
| 639 |
+
下面三行命令分别对 Llama3-8B-Instruct 模型进行 LoRA **微调**、**推理**和**合并**。
|
| 640 |
+
|
| 641 |
+
```bash
|
| 642 |
+
llamafactory-cli train examples/train_lora/llama3_lora_sft.yaml
|
| 643 |
+
llamafactory-cli chat examples/inference/llama3_lora_sft.yaml
|
| 644 |
+
llamafactory-cli export examples/merge_lora/llama3_lora_sft.yaml
|
| 645 |
+
```
|
| 646 |
+
|
| 647 |
+
高级用法请参考 [examples/README_zh.md](examples/README_zh.md)(包括多 GPU 微调)。
|
| 648 |
+
|
| 649 |
+
> [!TIP]
|
| 650 |
+
> 使用 `llamafactory-cli help` 显示帮助信息。
|
| 651 |
+
>
|
| 652 |
+
> 遇到报错请先看[常见问题](https://github.com/hiyouga/LLaMA-Factory/issues/4614)。
|
| 653 |
+
|
| 654 |
+
### LLaMA Board 可视化微调(由 [Gradio](https://github.com/gradio-app/gradio) 驱动)
|
| 655 |
+
|
| 656 |
+
```bash
|
| 657 |
+
llamafactory-cli webui
|
| 658 |
+
```
|
| 659 |
+
|
| 660 |
+
### 构建 Docker
|
| 661 |
+
|
| 662 |
+
CUDA 用户:
|
| 663 |
+
|
| 664 |
+
```bash
|
| 665 |
+
cd docker/docker-cuda/
|
| 666 |
+
docker compose up -d
|
| 667 |
+
docker compose exec llamafactory bash
|
| 668 |
+
```
|
| 669 |
+
|
| 670 |
+
昇腾 NPU 用户:
|
| 671 |
+
|
| 672 |
+
```bash
|
| 673 |
+
cd docker/docker-npu/
|
| 674 |
+
docker compose up -d
|
| 675 |
+
docker compose exec llamafactory bash
|
| 676 |
+
```
|
| 677 |
+
|
| 678 |
+
AMD ROCm 用户:
|
| 679 |
+
|
| 680 |
+
```bash
|
| 681 |
+
cd docker/docker-rocm/
|
| 682 |
+
docker compose up -d
|
| 683 |
+
docker compose exec llamafactory bash
|
| 684 |
+
```
|
| 685 |
+
|
| 686 |
+
<details><summary>不使用 Docker Compose 构建</summary>
|
| 687 |
+
|
| 688 |
+
CUDA 用户:
|
| 689 |
+
|
| 690 |
+
```bash
|
| 691 |
+
docker build -f ./docker/docker-cuda/Dockerfile \
|
| 692 |
+
--build-arg PIP_INDEX=https://pypi.org/simple \
|
| 693 |
+
--build-arg EXTRAS=metrics \
|
| 694 |
+
-t llamafactory:latest .
|
| 695 |
+
|
| 696 |
+
docker run -dit --ipc=host --gpus=all \
|
| 697 |
+
-p 7860:7860 \
|
| 698 |
+
-p 8000:8000 \
|
| 699 |
+
--name llamafactory \
|
| 700 |
+
llamafactory:latest
|
| 701 |
+
|
| 702 |
+
docker exec -it llamafactory bash
|
| 703 |
+
```
|
| 704 |
+
|
| 705 |
+
昇腾 NPU 用户:
|
| 706 |
+
|
| 707 |
+
```bash
|
| 708 |
+
docker build -f ./docker/docker-npu/Dockerfile \
|
| 709 |
+
--build-arg PIP_INDEX=https://pypi.org/simple \
|
| 710 |
+
--build-arg EXTRAS=torch-npu,metrics \
|
| 711 |
+
-t llamafactory:latest .
|
| 712 |
+
|
| 713 |
+
docker run -dit --ipc=host \
|
| 714 |
+
-v /usr/local/dcmi:/usr/local/dcmi \
|
| 715 |
+
-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \
|
| 716 |
+
-v /usr/local/Ascend/driver:/usr/local/Ascend/driver \
|
| 717 |
+
-v /etc/ascend_install.info:/etc/ascend_install.info \
|
| 718 |
+
-p 7860:7860 \
|
| 719 |
+
-p 8000:8000 \
|
| 720 |
+
--device /dev/davinci0 \
|
| 721 |
+
--device /dev/davinci_manager \
|
| 722 |
+
--device /dev/devmm_svm \
|
| 723 |
+
--device /dev/hisi_hdc \
|
| 724 |
+
--name llamafactory \
|
| 725 |
+
llamafactory:latest
|
| 726 |
+
|
| 727 |
+
docker exec -it llamafactory bash
|
| 728 |
+
```
|
| 729 |
+
|
| 730 |
+
AMD ROCm 用户:
|
| 731 |
+
|
| 732 |
+
```bash
|
| 733 |
+
docker build -f ./docker/docker-rocm/Dockerfile \
|
| 734 |
+
--build-arg PIP_INDEX=https://pypi.org/simple \
|
| 735 |
+
--build-arg EXTRAS=metrics \
|
| 736 |
+
-t llamafactory:latest .
|
| 737 |
+
|
| 738 |
+
docker run -dit --ipc=host \
|
| 739 |
+
-p 7860:7860 \
|
| 740 |
+
-p 8000:8000 \
|
| 741 |
+
--device /dev/kfd \
|
| 742 |
+
--device /dev/dri \
|
| 743 |
+
--name llamafactory \
|
| 744 |
+
llamafactory:latest
|
| 745 |
+
|
| 746 |
+
docker exec -it llamafactory bash
|
| 747 |
+
```
|
| 748 |
+
|
| 749 |
+
</details>
|
| 750 |
+
|
| 751 |
+
<details><summary>使用数据卷</summary>
|
| 752 |
+
|
| 753 |
+
您可以通过移除 Dockerfile 中 `VOLUME [ "/root/.cache/huggingface", "/app/shared_data", "/app/output" ]` 的注释来使用数据卷。
|
| 754 |
+
|
| 755 |
+
在构建 Docker 时使用参数 `-v ./hf_cache:/root/.cache/huggingface` 来挂载数据卷。各个数据卷的含义表示如下。
|
| 756 |
+
|
| 757 |
+
- `hf_cache`:使用宿主机的 Hugging Face 缓存文件夹。
|
| 758 |
+
- `shared_data`:宿主机中存放数据集的文件夹路径。
|
| 759 |
+
- `output`:将导出目录设置为该路径后,即可在宿主机中访问导出后的模型。
|
| 760 |
+
|
| 761 |
+
</details>
|
| 762 |
+
|
| 763 |
+
### 利用 vLLM 部署 OpenAI API
|
| 764 |
+
|
| 765 |
+
```bash
|
| 766 |
+
API_PORT=8000 llamafactory-cli api examples/inference/llama3.yaml infer_backend=vllm vllm_enforce_eager=true
|
| 767 |
+
```
|
| 768 |
+
|
| 769 |
+
> [!TIP]
|
| 770 |
+
> API 文档请查阅[这里](https://platform.openai.com/docs/api-reference/chat/create)。
|
| 771 |
+
>
|
| 772 |
+
> 示例:[图像理解](scripts/api_example/test_image.py) | [工具调用](scripts/api_example/test_toolcall.py)
|
| 773 |
+
|
| 774 |
+
### 从魔搭社区下载
|
| 775 |
+
|
| 776 |
+
如果您在 Hugging Face 模型和数据集的下载中遇到了问题,可以通过下述方法使用魔搭社区。
|
| 777 |
+
|
| 778 |
+
```bash
|
| 779 |
+
export USE_MODELSCOPE_HUB=1 # Windows 使用 `set USE_MODELSCOPE_HUB=1`
|
| 780 |
+
```
|
| 781 |
+
|
| 782 |
+
将 `model_name_or_path` 设置为模型 ID 来加载对应的模型。在[魔搭社区](https://modelscope.cn/models)查看所有可用的模型,例如 `LLM-Research/Meta-Llama-3-8B-Instruct`。
|
| 783 |
+
|
| 784 |
+
### 从魔乐社区下载
|
| 785 |
+
|
| 786 |
+
您也可以通过下述方法,使用魔乐社区下载数据集和模型。
|
| 787 |
+
|
| 788 |
+
```bash
|
| 789 |
+
export USE_OPENMIND_HUB=1 # Windows 使用 `set USE_OPENMIND_HUB=1`
|
| 790 |
+
```
|
| 791 |
+
|
| 792 |
+
将 `model_name_or_path` 设置为模型 ID 来加载对应的模型。在[魔乐社区](https://modelers.cn/models)查看所有可用的模型,例如 `TeleAI/TeleChat-7B-pt`。
|
| 793 |
+
|
| 794 |
+
### 使用 W&B 面板
|
| 795 |
+
|
| 796 |
+
若要使用 [Weights & Biases](https://wandb.ai) 记录实验数据,请在 yaml 文件中添加下面的参数。
|
| 797 |
+
|
| 798 |
+
```yaml
|
| 799 |
+
report_to: wandb
|
| 800 |
+
run_name: test_run # 可选
|
| 801 |
+
```
|
| 802 |
+
|
| 803 |
+
在启动训练任务时,将 `WANDB_API_KEY` 设置为[密钥](https://wandb.ai/authorize)来登录 W&B 账户。
|
| 804 |
+
|
| 805 |
+
### 使用 SwanLab 面板
|
| 806 |
+
|
| 807 |
+
若要使用 [SwanLab](https://github.com/SwanHubX/SwanLab) 记录实验数据,请在 yaml 文件中添加下面的参数。
|
| 808 |
+
|
| 809 |
+
```yaml
|
| 810 |
+
use_swanlab: true
|
| 811 |
+
swanlab_run_name: test_run # 可选
|
| 812 |
+
```
|
| 813 |
+
|
| 814 |
+
在启动训练任务时,登录SwanLab账户有以下三种方式:
|
| 815 |
+
|
| 816 |
+
方式一:在 yaml 文件中添加 `swanlab_api_key=<your_api_key>` ,并设置为你的 [API 密钥](https://swanlab.cn/settings)。
|
| 817 |
+
方式二:将环境变量 `SWANLAB_API_KEY` 设置为你的 [API 密钥](https://swanlab.cn/settings)。
|
| 818 |
+
方式三:启动前使用 `swanlab login` 命令完成登录。
|
| 819 |
+
|
| 820 |
+
## 使用了 LLaMA Factory 的项目
|
| 821 |
+
|
| 822 |
+
如果您有项目希望添加至下述列表,请通过邮件联系或者创建一个 PR。
|
| 823 |
+
|
| 824 |
+
<details><summary>点击显示</summary>
|
| 825 |
+
|
| 826 |
+
1. Wang et al. ESRL: Efficient Sampling-based Reinforcement Learning for Sequence Generation. 2023. [[arxiv]](https://arxiv.org/abs/2308.02223)
|
| 827 |
+
1. Yu et al. Open, Closed, or Small Language Models for Text Classification? 2023. [[arxiv]](https://arxiv.org/abs/2308.10092)
|
| 828 |
+
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)
|
| 829 |
+
1. Luceri et al. Leveraging Large Language Models to Detect Influence Campaigns in Social Media. 2023. [[arxiv]](https://arxiv.org/abs/2311.07816)
|
| 830 |
+
1. Zhang et al. Alleviating Hallucinations of Large Language Models through Induced Hallucinations. 2023. [[arxiv]](https://arxiv.org/abs/2312.15710)
|
| 831 |
+
1. Wang et al. Know Your Needs Better: Towards Structured Understanding of Marketer Demands with Analogical Reasoning Augmented LLMs. KDD 2024. [[arxiv]](https://arxiv.org/abs/2401.04319)
|
| 832 |
+
1. Wang et al. CANDLE: Iterative Conceptualization and Instantiation Distillation from Large Language Models for Commonsense Reasoning. ACL 2024. [[arxiv]](https://arxiv.org/abs/2401.07286)
|
| 833 |
+
1. Choi et al. FACT-GPT: Fact-Checking Augmentation via Claim Matching with LLMs. 2024. [[arxiv]](https://arxiv.org/abs/2402.05904)
|
| 834 |
+
1. Zhang et al. AutoMathText: Autonomous Data Selection with Language Models for Mathematical Texts. 2024. [[arxiv]](https://arxiv.org/abs/2402.07625)
|
| 835 |
+
1. Lyu et al. KnowTuning: Knowledge-aware Fine-tuning for Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2402.11176)
|
| 836 |
+
1. Yang et al. LaCo: Large Language Model Pruning via Layer Collaps. 2024. [[arxiv]](https://arxiv.org/abs/2402.11187)
|
| 837 |
+
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)
|
| 838 |
+
1. Yang et al. Enhancing Empathetic Response Generation by Augmenting LLMs with Small-scale Empathetic Models. 2024. [[arxiv]](https://arxiv.org/abs/2402.11801)
|
| 839 |
+
1. Yi et al. Generation Meets Verification: Accelerating Large Language Model Inference with Smart Parallel Auto-Correct Decoding. ACL 2024 Findings. [[arxiv]](https://arxiv.org/abs/2402.11809)
|
| 840 |
+
1. Cao et al. Head-wise Shareable Attention for Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2402.11819)
|
| 841 |
+
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)
|
| 842 |
+
1. Kim et al. Efficient and Effective Vocabulary Expansion Towards Multilingual Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2402.14714)
|
| 843 |
+
1. Yu et al. KIEval: A Knowledge-grounded Interactive Evaluation Framework for Large Language Models. ACL 2024. [[arxiv]](https://arxiv.org/abs/2402.15043)
|
| 844 |
+
1. Huang et al. Key-Point-Driven Data Synthesis with its Enhancement on Mathematical Reasoning. 2024. [[arxiv]](https://arxiv.org/abs/2403.02333)
|
| 845 |
+
1. Duan et al. Negating Negatives: Alignment without Human Positive Samples via Distributional Dispreference Optimization. 2024. [[arxiv]](https://arxiv.org/abs/2403.03419)
|
| 846 |
+
1. Xie and Schwertfeger. Empowering Robotics with Large Language Models: osmAG Map Comprehension with LLMs. 2024. [[arxiv]](https://arxiv.org/abs/2403.08228)
|
| 847 |
+
1. Wu et al. Large Language Models are Parallel Multilingual Learners. 2024. [[arxiv]](https://arxiv.org/abs/2403.09073)
|
| 848 |
+
1. Zhang et al. EDT: Improving Large Language Models' Generation by Entropy-based Dynamic Temperature Sampling. 2024. [[arxiv]](https://arxiv.org/abs/2403.14541)
|
| 849 |
+
1. Weller et al. FollowIR: Evaluating and Teaching Information Retrieval Models to Follow Instructions. 2024. [[arxiv]](https://arxiv.org/abs/2403.15246)
|
| 850 |
+
1. Hongbin Na. CBT-LLM: A Chinese Large Language Model for Cognitive Behavioral Therapy-based Mental Health Question Answering. COLING 2024. [[arxiv]](https://arxiv.org/abs/2403.16008)
|
| 851 |
+
1. Zan et al. CodeS: Natural Language to Code Repository via Multi-Layer Sketch. 2024. [[arxiv]](https://arxiv.org/abs/2403.16443)
|
| 852 |
+
1. Liu et al. Extensive Self-Contrast Enables Feedback-Free Language Model Alignment. 2024. [[arxiv]](https://arxiv.org/abs/2404.00604)
|
| 853 |
+
1. Luo et al. BAdam: A Memory Efficient Full Parameter Training Method for Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2404.02827)
|
| 854 |
+
1. Du et al. Chinese Tiny LLM: Pretraining a Chinese-Centric Large Language Model. 2024. [[arxiv]](https://arxiv.org/abs/2404.04167)
|
| 855 |
+
1. Ma et al. Parameter Efficient Quasi-Orthogonal Fine-Tuning via Givens Rotation. ICML 2024. [[arxiv]](https://arxiv.org/abs/2404.04316)
|
| 856 |
+
1. Liu et al. Dynamic Generation of Personalities with Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2404.07084)
|
| 857 |
+
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)
|
| 858 |
+
1. Huang et al. LLMTune: Accelerate Database Knob Tuning with Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2404.11581)
|
| 859 |
+
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)
|
| 860 |
+
1. Acikgoz et al. Hippocrates: An Open-Source Framework for Advancing Large Language Models in Healthcare. 2024. [[arxiv]](https://arxiv.org/abs/2404.16621)
|
| 861 |
+
1. Zhang et al. Small Language Models Need Strong Verifiers to Self-Correct Reasoning. ACL 2024 Findings. [[arxiv]](https://arxiv.org/abs/2404.17140)
|
| 862 |
+
1. Zhou et al. FREB-TQA: A Fine-Grained Robustness Evaluation Benchmark for Table Question Answering. NAACL 2024. [[arxiv]](https://arxiv.org/abs/2404.18585)
|
| 863 |
+
1. Xu et al. Large Language Models for Cyber Security: A Systematic Literature Review. 2024. [[arxiv]](https://arxiv.org/abs/2405.04760)
|
| 864 |
+
1. Dammu et al. "They are uncultured": Unveiling Covert Harms and Social Threats in LLM Generated Conversations. 2024. [[arxiv]](https://arxiv.org/abs/2405.05378)
|
| 865 |
+
1. Yi et al. A safety realignment framework via subspace-oriented model fusion for large language models. 2024. [[arxiv]](https://arxiv.org/abs/2405.09055)
|
| 866 |
+
1. Lou et al. SPO: Multi-Dimensional Preference Sequential Alignment With Implicit Reward Modeling. 2024. [[arxiv]](https://arxiv.org/abs/2405.12739)
|
| 867 |
+
1. Zhang et al. Getting More from Less: Large Language Models are Good Spontaneous Multilingual Learners. 2024. [[arxiv]](https://arxiv.org/abs/2405.13816)
|
| 868 |
+
1. Zhang et al. TS-Align: A Teacher-Student Collaborative Framework for Scalable Iterative Finetuning of Large Language Models. 2024. [[arxiv]](https://arxiv.org/abs/2405.20215)
|
| 869 |
+
1. Zihong Chen. Sentence Segmentation and Sentence Punctuation Based on XunziALLM. 2024. [[paper]](https://aclanthology.org/2024.lt4hala-1.30)
|
| 870 |
+
1. Gao et al. The Best of Both Worlds: Toward an Honest and Helpful Large Language Model. 2024. [[arxiv]](https://arxiv.org/abs/2406.00380)
|
| 871 |
+
1. Wang and Song. MARS: Benchmarking the Metaphysical Reasoning Abilities of Language Models with a Multi-task Evaluation Dataset. 2024. [[arxiv]](https://arxiv.org/abs/2406.02106)
|
| 872 |
+
1. Hu et al. Computational Limits of Low-Rank Adaptation (LoRA) for Transformer-Based Models. 2024. [[arxiv]](https://arxiv.org/abs/2406.03136)
|
| 873 |
+
1. Ge et al. Time Sensitive Knowledge Editing through Efficient Finetuning. ACL 2024. [[arxiv]](https://arxiv.org/abs/2406.04496)
|
| 874 |
+
1. Tan et al. Peer Review as A Multi-Turn and Long-Context Dialogue with Role-Based Interactions. 2024. [[arxiv]](https://arxiv.org/abs/2406.05688)
|
| 875 |
+
1. Song et al. Turbo Sparse: Achieving LLM SOTA Performance with Minimal Activated Parameters. 2024. [[arxiv]](https://arxiv.org/abs/2406.05955)
|
| 876 |
+
1. Gu et al. RWKV-CLIP: A Robust Vision-Language Representation Learner. 2024. [[arxiv]](https://arxiv.org/abs/2406.06973)
|
| 877 |
+
1. Chen et al. Advancing Tool-Augmented Large Language Models: Integrating Insights from Errors in Inference Trees. 2024. [[arxiv]](https://arxiv.org/abs/2406.07115)
|
| 878 |
+
1. Zhu et al. Are Large Language Models Good Statisticians?. 2024. [[arxiv]](https://arxiv.org/abs/2406.07815)
|
| 879 |
+
1. Li et al. Know the Unknown: An Uncertainty-Sensitive Method for LLM Instruction Tuning. 2024. [[arxiv]](https://arxiv.org/abs/2406.10099)
|
| 880 |
+
1. Ding et al. IntentionQA: A Benchmark for Evaluating Purchase Intention Comprehension Abilities of Language Models in E-commerce. 2024. [[arxiv]](https://arxiv.org/abs/2406.10173)
|
| 881 |
+
1. He et al. COMMUNITY-CROSS-INSTRUCT: Unsupervised Instruction Generation for Aligning Large Language Models to Online Communities. 2024. [[arxiv]](https://arxiv.org/abs/2406.12074)
|
| 882 |
+
1. Lin et al. FVEL: Interactive Formal Verification Environment with Large Language Models via Theorem Proving. 2024. [[arxiv]](https://arxiv.org/abs/2406.14408)
|
| 883 |
+
1. Treutlein et al. Connecting the Dots: LLMs can Infer and Verbalize Latent Structure from Disparate Training Data. 2024. [[arxiv]](https://arxiv.org/abs/2406.14546)
|
| 884 |
+
1. Feng et al. SS-Bench: A Benchmark for Social Story Generation and Evaluation. 2024. [[arxiv]](https://arxiv.org/abs/2406.15695)
|
| 885 |
+
1. Feng et al. Self-Constructed Context Decompilation with Fined-grained Alignment Enhancement. 2024. [[arxiv]](https://arxiv.org/abs/2406.17233)
|
| 886 |
+
1. Liu et al. Large Language Models for Cuffless Blood Pressure Measurement From Wearable Biosignals. 2024. [[arxiv]](https://arxiv.org/abs/2406.18069)
|
| 887 |
+
1. Iyer et al. Exploring Very Low-Resource Translation with LLMs: The University of Edinburgh's Submission to AmericasNLP 2024 Translation Task. AmericasNLP 2024. [[paper]](https://aclanthology.org/2024.americasnlp-1.25)
|
| 888 |
+
1. Li et al. Calibrating LLMs with Preference Optimization on Thought Trees for Generating Rationale in Science Question Scoring. 2024. [[arxiv]](https://arxiv.org/abs/2406.19949)
|
| 889 |
+
1. Yang et al. Financial Knowledge Large Language Model. 2024. [[arxiv]](https://arxiv.org/abs/2407.00365)
|
| 890 |
+
1. Lin et al. DogeRM: Equipping Reward Models with Domain Knowledge through Model Merging. 2024. [[arxiv]](https://arxiv.org/abs/2407.01470)
|
| 891 |
+
1. Bako et al. Evaluating the Semantic Profiling Abilities of LLMs for Natural Language Utterances in Data Visualization. 2024. [[arxiv]](https://arxiv.org/abs/2407.06129)
|
| 892 |
+
1. Huang et al. RoLoRA: Fine-tuning Rotated Outlier-free LLMs for Effective Weight-Activation Quantization. 2024. [[arxiv]](https://arxiv.org/abs/2407.08044)
|
| 893 |
+
1. Jiang et al. LLM-Collaboration on Automatic Science Journalism for the General Audience. 2024. [[arxiv]](https://arxiv.org/abs/2407.09756)
|
| 894 |
+
1. Inouye et al. Applied Auto-tuning on LoRA Hyperparameters. 2024. [[paper]](https://scholarcommons.scu.edu/cseng_senior/272/)
|
| 895 |
+
1. Qi et al. Research on Tibetan Tourism Viewpoints information generation system based on LLM. 2024. [[arxiv]](https://arxiv.org/abs/2407.13561)
|
| 896 |
+
1. Xu et al. Course-Correction: Safety Alignment Using Synthetic Preferences. 2024. [[arxiv]](https://arxiv.org/abs/2407.16637)
|
| 897 |
+
1. Sun et al. LAMBDA: A Large Model Based Data Agent. 2024. [[arxiv]](https://arxiv.org/abs/2407.17535)
|
| 898 |
+
1. Zhu et al. CollectiveSFT: Scaling Large Language Models for Chinese Medical Benchmark with Collective Instructions in Healthcare. 2024. [[arxiv]](https://arxiv.org/abs/2407.19705)
|
| 899 |
+
1. Yu et al. Correcting Negative Bias in Large Language Models through Negative Attention Score Alignment. 2024. [[arxiv]](https://arxiv.org/abs/2408.00137)
|
| 900 |
+
1. Xie et al. The Power of Personalized Datasets: Advancing Chinese Composition Writing for Elementary School through Targeted Model Fine-Tuning. IALP 2024. [[paper]](https://www.asianlp.sg/conferences/ialp2024/proceedings/papers/IALP2024_P055.pdf)
|
| 901 |
+
1. Liu et al. Instruct-Code-Llama: Improving Capabilities of Language Model in Competition Level Code Generation by Online Judge Feedback. ICIC 2024. [[paper]](https://link.springer.com/chapter/10.1007/978-981-97-5669-8_11)
|
| 902 |
+
1. Wang et al. Cybernetic Sentinels: Unveiling the Impact of Safety Data Selection on Model Security in Supervised Fine-Tuning. ICIC 2024. [[paper]](https://link.springer.com/chapter/10.1007/978-981-97-5669-8_23)
|
| 903 |
+
1. Xia et al. Understanding the Performance and Estimating the Cost of LLM Fine-Tuning. 2024. [[arxiv]](https://arxiv.org/abs/2408.04693)
|
| 904 |
+
1. Zeng et al. Perceive, Reflect, and Plan: Designing LLM Agent for Goal-Directed City Navigation without Instructions. 2024. [[arxiv]](https://arxiv.org/abs/2408.04168)
|
| 905 |
+
1. Xia et al. Using Pre-trained Language Model for Accurate ESG Prediction. FinNLP 2024. [[paper]](https://aclanthology.org/2024.finnlp-2.1/)
|
| 906 |
+
1. Liang et al. I-SHEEP: Self-Alignment of LLM from Scratch through an Iterative Self-Enhancement Paradigm. 2024. [[arxiv]](https://arxiv.org/abs/2408.08072)
|
| 907 |
+
1. Bai et al. Aligning Large Language Model with Direct Multi-Preference Optimization for Recommendation. CIKM 2024. [[paper]](https://dl.acm.org/doi/10.1145/3627673.3679611)
|
| 908 |
+
1. **[StarWhisper](https://github.com/Yu-Yang-Li/StarWhisper)**: 天文大模型 StarWhisper,基于 ChatGLM2-6B 和 Qwen-14B 在天文数据上微调而得。
|
| 909 |
+
1. **[DISC-LawLLM](https://github.com/FudanDISC/DISC-LawLLM)**: 中文法律领域大模型 DISC-LawLLM,基于 Baichuan-13B 微调而得,具有法律推理和知识检索能力。
|
| 910 |
+
1. **[Sunsimiao](https://github.com/X-D-Lab/Sunsimiao)**: 孙思邈中文医疗大模型 Sumsimiao,基于 Baichuan-7B 和 ChatGLM-6B 在中文医疗数据上微调而得。
|
| 911 |
+
1. **[CareGPT](https://github.com/WangRongsheng/CareGPT)**: 医疗大模型项目 CareGPT,基于 LLaMA2-7B 和 Baichuan-13B 在中文医疗数据上微调而得。
|
| 912 |
+
1. **[MachineMindset](https://github.com/PKU-YuanGroup/Machine-Mindset/)**:MBTI性格大模型项目,根据数据集与训练方式让任意 LLM 拥有 16 个不同的性格类型。
|
| 913 |
+
1. **[Luminia-13B-v3](https://huggingface.co/Nekochu/Luminia-13B-v3)**:一个用于生成 Stable Diffusion 提示词的大型语言模型。[[demo]](https://huggingface.co/spaces/Nekochu/Luminia-13B_SD_Prompt)
|
| 914 |
+
1. **[Chinese-LLaVA-Med](https://github.com/BUAADreamer/Chinese-LLaVA-Med)**:中文多模态医学大模型,基于 LLaVA-1.5-7B 在中文多模态医疗数据上微调而得。
|
| 915 |
+
1. **[AutoRE](https://github.com/THUDM/AutoRE)**:基于大语言模型的文档级关系抽取系统。
|
| 916 |
+
1. **[NVIDIA RTX AI Toolkit](https://github.com/NVIDIA/RTX-AI-Toolkit)**:在 Windows 主机上利用英伟达 RTX 设备进行大型语言模型微调的开发包。
|
| 917 |
+
1. **[LazyLLM](https://github.com/LazyAGI/LazyLLM)**:一个低代码构建多 Agent 大模型应用的开发工具,支持基于 LLaMA Factory 的模型微调.
|
| 918 |
+
1. **[RAG-Retrieval](https://github.com/NLPJCL/RAG-Retrieval)**:一个全链路 RAG 检索模型微调、推理和蒸馏代码库。[[blog]](https://zhuanlan.zhihu.com/p/987727357)
|
| 919 |
+
1. **[360-LLaMA-Factory](https://github.com/Qihoo360/360-LLaMA-Factory)**:一个魔改后的代码库,通过 Ring Attention 支持长序列的 SFT 和 DPO 训练。
|
| 920 |
+
1. **[Sky-T1](https://novasky-ai.github.io/posts/sky-t1/)**:由 NovaSky AI 微调的低成本类 o1 长推理模型。
|
| 921 |
+
1. **[WeClone](https://github.com/xming521/WeClone)**:从聊天记录创造数字分身的一站式解决方案。
|
| 922 |
+
|
| 923 |
+
</details>
|
| 924 |
+
|
| 925 |
+
## 协议
|
| 926 |
+
|
| 927 |
+
本仓库的代码依照 [Apache-2.0](LICENSE) 协议开源。
|
| 928 |
+
|
| 929 |
+
使用模型权重时,请遵循对应的模型协议:[Baichuan 2](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) / [GLM-4](https://huggingface.co/THUDM/glm-4-9b/blob/main/LICENSE) / [GPT-2](https://github.com/openai/gpt-2/blob/master/LICENSE) / [Granite](LICENSE) / [Index](https://huggingface.co/IndexTeam/Index-1.9B/blob/main/LICENSE) / [InternLM](https://github.com/InternLM/InternLM#license) / [Llama](https://github.com/facebookresearch/llama/blob/main/MODEL_CARD.md) / [Llama 2](https://ai.meta.com/llama/license/) / [Llama 3](https://llama.meta.com/llama3/license/) / [Llama 4](https://github.com/meta-llama/llama-models/blob/main/models/llama4/LICENSE) / [MiniCPM](https://github.com/OpenBMB/MiniCPM/blob/main/MiniCPM%20Model%20License.md) / [Mistral/Mixtral/Pixtral](LICENSE) / [OLMo](LICENSE) / [Phi-1.5/Phi-2](https://huggingface.co/microsoft/phi-1_5/resolve/main/Research%20License.docx) / [Phi-3/Phi-4](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct/blob/main/LICENSE) / [Qwen](https://github.com/QwenLM/Qwen/blob/main/Tongyi%20Qianwen%20LICENSE%20AGREEMENT) / [Skywork](https://huggingface.co/Skywork/Skywork-13B-base/blob/main/Skywork%20Community%20License.pdf) / [StarCoder 2](https://huggingface.co/spaces/bigcode/bigcode-model-license-agreement) / [TeleChat2](https://huggingface.co/Tele-AI/telechat-7B/blob/main/TeleChat%E6%A8%A1%E5%9E%8B%E7%A4%BE%E5%8C%BA%E8%AE%B8%E5%8F%AF%E5%8D%8F%E8%AE%AE.pdf) / [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 2](https://github.com/IEIT-Yuan/Yuan-2.0/blob/main/LICENSE-Yuan)
|
| 930 |
+
|
| 931 |
+
## 引用
|
| 932 |
+
|
| 933 |
+
如果您觉得此项目有帮助,请考虑以下列格式引用
|
| 934 |
+
|
| 935 |
+
```bibtex
|
| 936 |
+
@inproceedings{zheng2024llamafactory,
|
| 937 |
+
title={LlamaFactory: Unified Efficient Fine-Tuning of 100+ Language Models},
|
| 938 |
+
author={Yaowei Zheng and Richong Zhang and Junhao Zhang and Yanhan Ye and Zheyan Luo and Zhangchi Feng and Yongqiang Ma},
|
| 939 |
+
booktitle={Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 3: System Demonstrations)},
|
| 940 |
+
address={Bangkok, Thailand},
|
| 941 |
+
publisher={Association for Computational Linguistics},
|
| 942 |
+
year={2024},
|
| 943 |
+
url={http://arxiv.org/abs/2403.13372}
|
| 944 |
+
}
|
| 945 |
+
```
|
| 946 |
+
|
| 947 |
+
## 致谢
|
| 948 |
+
|
| 949 |
+
本项目受益于 [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),感谢以上诸位作者的付出。
|
| 950 |
+
|
| 951 |
+
## Star History
|
| 952 |
+
|
| 953 |
+

|
assets/alaya_new.svg
ADDED
|
|
assets/logo.png
ADDED
|
assets/serpapi.svg
ADDED
|
|
assets/warp.jpg
ADDED
|
Git LFS Details
|
assets/wechat.jpg
ADDED
|
Git LFS Details
|
assets/wechat_alaya.png
ADDED
|
Git LFS Details
|
assets/wechat_npu.jpg
ADDED
|
Git LFS Details
|
data/.gitattributes
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
*.lz4 filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.mds filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
# Audio files - uncompressed
|
| 39 |
+
*.pcm filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
*.sam filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
*.raw filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
# Audio files - compressed
|
| 43 |
+
*.aac filter=lfs diff=lfs merge=lfs -text
|
| 44 |
+
*.flac filter=lfs diff=lfs merge=lfs -text
|
| 45 |
+
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
| 46 |
+
*.ogg filter=lfs diff=lfs merge=lfs -text
|
| 47 |
+
*.wav filter=lfs diff=lfs merge=lfs -text
|
| 48 |
+
# Image files - uncompressed
|
| 49 |
+
*.bmp filter=lfs diff=lfs merge=lfs -text
|
| 50 |
+
*.gif filter=lfs diff=lfs merge=lfs -text
|
| 51 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
| 52 |
+
*.tiff filter=lfs diff=lfs merge=lfs -text
|
| 53 |
+
# Image files - compressed
|
| 54 |
+
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 55 |
+
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
| 56 |
+
*.webp filter=lfs diff=lfs merge=lfs -text
|
| 57 |
+
# Video files - compressed
|
| 58 |
+
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 59 |
+
*.webm filter=lfs diff=lfs merge=lfs -text
|
| 60 |
+
train0_train1_merged.json filter=lfs diff=lfs merge=lfs -text
|
data/9909_delta_11.141_18.457sharegpt.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e55e8ea372b5504890764068f04295f3e86ddbe21bbeeb065c211e4592221cf5
|
| 3 |
+
size 47726527
|
data/9909_delta_29.609_73.375sharegpt.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ea575dc374e0d896e76d29b1373b7949604d8d872196cd52c1ca523b1f698692
|
| 3 |
+
size 46948154
|
data/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
dataset_info:
|
| 3 |
+
features:
|
| 4 |
+
- name: app_days
|
| 5 |
+
dtype: int64
|
| 6 |
+
- name: bot_id
|
| 7 |
+
dtype: string
|
| 8 |
+
- name: chosen
|
| 9 |
+
dtype: string
|
| 10 |
+
- name: chosen_model
|
| 11 |
+
dtype: int64
|
| 12 |
+
- name: chosen_position
|
| 13 |
+
dtype: int64
|
| 14 |
+
- name: chosen_prompt
|
| 15 |
+
dtype: string
|
| 16 |
+
- name: id
|
| 17 |
+
dtype: int64
|
| 18 |
+
- name: reject
|
| 19 |
+
dtype: string
|
| 20 |
+
- name: reject_model
|
| 21 |
+
dtype: int64
|
| 22 |
+
- name: reject_prompt
|
| 23 |
+
dtype: string
|
| 24 |
+
- name: timestamp
|
| 25 |
+
dtype: string
|
| 26 |
+
- name: user_id
|
| 27 |
+
dtype: string
|
| 28 |
+
splits:
|
| 29 |
+
- name: train
|
| 30 |
+
num_bytes: 112650448
|
| 31 |
+
num_examples: 7098
|
| 32 |
+
download_size: 59720019
|
| 33 |
+
dataset_size: 112650448
|
| 34 |
+
configs:
|
| 35 |
+
- config_name: default
|
| 36 |
+
data_files:
|
| 37 |
+
- split: train
|
| 38 |
+
path: data/train-*
|
| 39 |
+
---
|
data/README_zh.md
ADDED
|
@@ -0,0 +1,478 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[dataset_info.json](dataset_info.json) 包含了所有可用的数据集。如果您希望使用自定义数据集,请**务必**在 `dataset_info.json` 文件中添加*数据集描述*,并通过修改 `dataset: 数据集名称` 配置来使用数据集。
|
| 2 |
+
|
| 3 |
+
其中 `dataset_info.json` 文件应放置在 `dataset_dir` 目录下。您可以通过修改 `dataset_dir` 参数来使用其他目录。默认值为 `./data`。
|
| 4 |
+
|
| 5 |
+
目前我们支持 **alpaca** 格式和 **sharegpt** 格式的数据集。允许的文件类型包括 json、jsonl、csv、parquet 和 arrow。
|
| 6 |
+
|
| 7 |
+
```json
|
| 8 |
+
"数据集名称": {
|
| 9 |
+
"hf_hub_url": "Hugging Face 的数据集仓库地址(若指定,则忽略 script_url 和 file_name)",
|
| 10 |
+
"ms_hub_url": "ModelScope 的数据集仓库地址(若指定,则忽略 script_url 和 file_name)",
|
| 11 |
+
"script_url": "包含数据加载脚本的本地文件夹名称(若指定,则忽略 file_name)",
|
| 12 |
+
"file_name": "该目录下数据集文件夹或文件的名称(若上述参数未指定,则此项必需)",
|
| 13 |
+
"formatting": "数据集格式(可选,默认:alpaca,可以为 alpaca 或 sharegpt)",
|
| 14 |
+
"ranking": "是否为偏好数据集(可选,默认:False)",
|
| 15 |
+
"subset": "数据集子集的名称(可选,默认:None)",
|
| 16 |
+
"split": "所使用的数据集切分(可选,默认:train)",
|
| 17 |
+
"folder": "Hugging Face 仓库的文件夹名称(可选,默认:None)",
|
| 18 |
+
"num_samples": "该数据集所使用的样本数量。(可选,默认:None)",
|
| 19 |
+
"columns(可选)": {
|
| 20 |
+
"prompt": "数据集代表提示词的表头名称(默认:instruction)",
|
| 21 |
+
"query": "数据集代表请求的表头名称(默认:input)",
|
| 22 |
+
"response": "数据集代表回答的表头名称(默认:output)",
|
| 23 |
+
"history": "数据集代表历史对话的表头名称(默认:None)",
|
| 24 |
+
"messages": "数据集代表消息列表的表头名称(默认:conversations)",
|
| 25 |
+
"system": "数据集代表系统提示的表头名称(默认:None)",
|
| 26 |
+
"tools": "数据集代表工具描述的表头名称(默认:None)",
|
| 27 |
+
"images": "数据集代表图像输入的表头名称(默认:None)",
|
| 28 |
+
"videos": "数据集代表视频输入的表头名称(默认:None)",
|
| 29 |
+
"audios": "数据集代表音频输入的表头名称(默认:None)",
|
| 30 |
+
"chosen": "数据集代表更优回答的表头名称(默认:None)",
|
| 31 |
+
"rejected": "数据集代表更差回答的表头名称(默认:None)",
|
| 32 |
+
"kto_tag": "数据集代表 KTO 标签的表头名称(默认:None)"
|
| 33 |
+
},
|
| 34 |
+
"tags(可选,用于 sharegpt 格式)": {
|
| 35 |
+
"role_tag": "消息中代表发送者身份的键名(默认:from)",
|
| 36 |
+
"content_tag": "消息中代表文本内容的键名(默认:value)",
|
| 37 |
+
"user_tag": "消息中代表用户的 role_tag(默认:human)",
|
| 38 |
+
"assistant_tag": "消息中代表助手的 role_tag(默认:gpt)",
|
| 39 |
+
"observation_tag": "消息中代表工具返回结果的 role_tag(默认:observation)",
|
| 40 |
+
"function_tag": "消息中代表工具调用的 role_tag(默认:function_call)",
|
| 41 |
+
"system_tag": "消息中代表系统提示的 role_tag(默认:system,会覆盖 system column)"
|
| 42 |
+
}
|
| 43 |
+
}
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
## Alpaca 格式
|
| 47 |
+
|
| 48 |
+
### 指令监督微调数据集
|
| 49 |
+
|
| 50 |
+
- [样例数据集](alpaca_zh_demo.json)
|
| 51 |
+
|
| 52 |
+
在指令监督微调时,`instruction` 列对应的内容会与 `input` 列对应的内容拼接后作为提示词,即提示词为 `instruction\ninput`。而 `output` 列对应的内容为模型回答。
|
| 53 |
+
|
| 54 |
+
对于推理类模型的微调,如果数据集包含思维链,则需要把思维链放在模型回答中,例如 `<think>cot</think>output`。
|
| 55 |
+
|
| 56 |
+
如果指定,`system` 列对应的内容将被作为系统提示词。
|
| 57 |
+
|
| 58 |
+
`history` 列是由多个字符串二元组构成的列表,分别代表历史消息中每轮对话的指令和回答。注意在指令监督微调时,历史消息中的回答内容**也会被用于模型学习**。
|
| 59 |
+
|
| 60 |
+
```json
|
| 61 |
+
[
|
| 62 |
+
{
|
| 63 |
+
"instruction": "用户指令(必填)",
|
| 64 |
+
"input": "用户输入(选填)",
|
| 65 |
+
"output": "模型回答(必填)",
|
| 66 |
+
"system": "系统提示词(选填)",
|
| 67 |
+
"history": [
|
| 68 |
+
["第一轮指令(选填)", "第一轮回答(选填)"],
|
| 69 |
+
["第二轮指令(选填)", "第二轮回答(选填)"]
|
| 70 |
+
]
|
| 71 |
+
}
|
| 72 |
+
]
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
对于上述格式的数据,`dataset_info.json` 中的*数据集描述*应为:
|
| 76 |
+
|
| 77 |
+
```json
|
| 78 |
+
"数据集名称": {
|
| 79 |
+
"file_name": "data.json",
|
| 80 |
+
"columns": {
|
| 81 |
+
"prompt": "instruction",
|
| 82 |
+
"query": "input",
|
| 83 |
+
"response": "output",
|
| 84 |
+
"system": "system",
|
| 85 |
+
"history": "history"
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
> [!TIP]
|
| 91 |
+
> 如果模型本身具备推理能力(如 Qwen3)而数据集不包含思维链,LLaMA-Factory 会自动为数据添加空思维链。当 `enable_thinking` 为 `True` 时(慢思考,默认),空思维链会添加到模型回答中并且计算损失,否则会添加到用户指令中并且不计算损失(快思考)。请在训练和推理时保�� `enable_thinking` 参数一致。
|
| 92 |
+
>
|
| 93 |
+
> 如果您希望训练包含思维链的数据时使用慢思考,训练不包含思维链的数据时使用快思考,可以设置 `enable_thinking` 为 `None`。但该功能较为复杂,请谨慎使用。
|
| 94 |
+
|
| 95 |
+
### 预训练数据集
|
| 96 |
+
|
| 97 |
+
- [样例数据集](c4_demo.jsonl)
|
| 98 |
+
|
| 99 |
+
在预训练时,只有 `text` 列中的内容会用于模型学习。
|
| 100 |
+
|
| 101 |
+
```json
|
| 102 |
+
[
|
| 103 |
+
{"text": "document"},
|
| 104 |
+
{"text": "document"}
|
| 105 |
+
]
|
| 106 |
+
```
|
| 107 |
+
|
| 108 |
+
对于上述格式的数据,`dataset_info.json` 中的*数据集描述*应为:
|
| 109 |
+
|
| 110 |
+
```json
|
| 111 |
+
"数据集名称": {
|
| 112 |
+
"file_name": "data.json",
|
| 113 |
+
"columns": {
|
| 114 |
+
"prompt": "text"
|
| 115 |
+
}
|
| 116 |
+
}
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
### 偏好数据集
|
| 120 |
+
|
| 121 |
+
偏好数据集用于奖励模型训练、DPO 训练、ORPO 训练和 SimPO 训练。
|
| 122 |
+
|
| 123 |
+
它需要在 `chosen` 列中提供更优的回答,并在 `rejected` 列中提供更差的回答。
|
| 124 |
+
|
| 125 |
+
```json
|
| 126 |
+
[
|
| 127 |
+
{
|
| 128 |
+
"instruction": "用户指令(必填)",
|
| 129 |
+
"input": "用户输入(选填)",
|
| 130 |
+
"chosen": "优质回答(必填)",
|
| 131 |
+
"rejected": "劣质回答(必填)"
|
| 132 |
+
}
|
| 133 |
+
]
|
| 134 |
+
```
|
| 135 |
+
|
| 136 |
+
对于上述格式的数据,`dataset_info.json` 中的*数据集描述*应为:
|
| 137 |
+
|
| 138 |
+
```json
|
| 139 |
+
"数据集名称": {
|
| 140 |
+
"file_name": "data.json",
|
| 141 |
+
"ranking": true,
|
| 142 |
+
"columns": {
|
| 143 |
+
"prompt": "instruction",
|
| 144 |
+
"query": "input",
|
| 145 |
+
"chosen": "chosen",
|
| 146 |
+
"rejected": "rejected"
|
| 147 |
+
}
|
| 148 |
+
}
|
| 149 |
+
```
|
| 150 |
+
|
| 151 |
+
### KTO 数据集
|
| 152 |
+
|
| 153 |
+
KTO 数据集需要提供额外的 `kto_tag` 列。详情请参阅 [sharegpt](#sharegpt-格式)。
|
| 154 |
+
|
| 155 |
+
### 多模态图像数据集
|
| 156 |
+
|
| 157 |
+
多模态图像数据集需要提供额外的 `images` 列。详情请参阅 [sharegpt](#sharegpt-格式)。
|
| 158 |
+
|
| 159 |
+
### 多模态视频数据集
|
| 160 |
+
|
| 161 |
+
多模态视频数据集需要提供额外的 `videos` 列。详情请参阅 [sharegpt](#sharegpt-格式)。
|
| 162 |
+
|
| 163 |
+
### 多模态音频数据集
|
| 164 |
+
|
| 165 |
+
多模态音频数据集需要提供额外的 `audios` 列。详情请参阅 [sharegpt](#sharegpt-格式)。
|
| 166 |
+
|
| 167 |
+
## Sharegpt 格式
|
| 168 |
+
|
| 169 |
+
### 指令监督微调数据集
|
| 170 |
+
|
| 171 |
+
- [样例数据集](glaive_toolcall_zh_demo.json)
|
| 172 |
+
|
| 173 |
+
相比 alpaca 格式的数据集,sharegpt 格式支持**更多的角色种类**,例如 human、gpt、observation、function 等等。它们构成一个对象列表呈现在 `conversations` 列中。
|
| 174 |
+
|
| 175 |
+
注意其中 human 和 observation 必须出现在奇数位置,gpt 和 function 必须出现在偶数位置。默认所有的 gpt 和 function 会被用于学习。
|
| 176 |
+
|
| 177 |
+
```json
|
| 178 |
+
[
|
| 179 |
+
{
|
| 180 |
+
"conversations": [
|
| 181 |
+
{
|
| 182 |
+
"from": "human",
|
| 183 |
+
"value": "用户指令"
|
| 184 |
+
},
|
| 185 |
+
{
|
| 186 |
+
"from": "function_call",
|
| 187 |
+
"value": "工具参数"
|
| 188 |
+
},
|
| 189 |
+
{
|
| 190 |
+
"from": "observation",
|
| 191 |
+
"value": "工具结果"
|
| 192 |
+
},
|
| 193 |
+
{
|
| 194 |
+
"from": "gpt",
|
| 195 |
+
"value": "模型回答"
|
| 196 |
+
}
|
| 197 |
+
],
|
| 198 |
+
"system": "系统提示词(选填)",
|
| 199 |
+
"tools": "工具描述(选填)"
|
| 200 |
+
}
|
| 201 |
+
]
|
| 202 |
+
```
|
| 203 |
+
|
| 204 |
+
对于上述格式的数据,`dataset_info.json` 中的*数据集描述*应为:
|
| 205 |
+
|
| 206 |
+
```json
|
| 207 |
+
"数据集名称": {
|
| 208 |
+
"file_name": "data.json",
|
| 209 |
+
"formatting": "sharegpt",
|
| 210 |
+
"columns": {
|
| 211 |
+
"messages": "conversations",
|
| 212 |
+
"system": "system",
|
| 213 |
+
"tools": "tools"
|
| 214 |
+
}
|
| 215 |
+
}
|
| 216 |
+
```
|
| 217 |
+
|
| 218 |
+
### 预训练数据集
|
| 219 |
+
|
| 220 |
+
尚不支持,请使用 [alpaca](#alpaca-格式) 格式。
|
| 221 |
+
|
| 222 |
+
### 偏好数据集
|
| 223 |
+
|
| 224 |
+
- [样例数据集](dpo_zh_demo.json)
|
| 225 |
+
|
| 226 |
+
Sharegpt 格式的偏好数据集同样需要在 `chosen` 列中提供更优的消息,并在 `rejected` 列中提供更差的消息。
|
| 227 |
+
|
| 228 |
+
```json
|
| 229 |
+
[
|
| 230 |
+
{
|
| 231 |
+
"conversations": [
|
| 232 |
+
{
|
| 233 |
+
"from": "human",
|
| 234 |
+
"value": "用户指令"
|
| 235 |
+
},
|
| 236 |
+
{
|
| 237 |
+
"from": "gpt",
|
| 238 |
+
"value": "模型回答"
|
| 239 |
+
},
|
| 240 |
+
{
|
| 241 |
+
"from": "human",
|
| 242 |
+
"value": "用户指令"
|
| 243 |
+
}
|
| 244 |
+
],
|
| 245 |
+
"chosen": {
|
| 246 |
+
"from": "gpt",
|
| 247 |
+
"value": "优质回答"
|
| 248 |
+
},
|
| 249 |
+
"rejected": {
|
| 250 |
+
"from": "gpt",
|
| 251 |
+
"value": "劣质回答"
|
| 252 |
+
}
|
| 253 |
+
}
|
| 254 |
+
]
|
| 255 |
+
```
|
| 256 |
+
|
| 257 |
+
对于上述格式的数据,`dataset_info.json` 中的*数据集描述*应为:
|
| 258 |
+
|
| 259 |
+
```json
|
| 260 |
+
"数据集名称": {
|
| 261 |
+
"file_name": "data.json",
|
| 262 |
+
"formatting": "sharegpt",
|
| 263 |
+
"ranking": true,
|
| 264 |
+
"columns": {
|
| 265 |
+
"messages": "conversations",
|
| 266 |
+
"chosen": "chosen",
|
| 267 |
+
"rejected": "rejected"
|
| 268 |
+
}
|
| 269 |
+
}
|
| 270 |
+
```
|
| 271 |
+
|
| 272 |
+
### KTO 数据集
|
| 273 |
+
|
| 274 |
+
- [样例数据集](kto_en_demo.json)
|
| 275 |
+
|
| 276 |
+
KTO 数据集需要额外添加一个 `kto_tag` 列,包含 bool 类型的人类反馈。
|
| 277 |
+
|
| 278 |
+
```json
|
| 279 |
+
[
|
| 280 |
+
{
|
| 281 |
+
"conversations": [
|
| 282 |
+
{
|
| 283 |
+
"from": "human",
|
| 284 |
+
"value": "用户指令"
|
| 285 |
+
},
|
| 286 |
+
{
|
| 287 |
+
"from": "gpt",
|
| 288 |
+
"value": "模型回答"
|
| 289 |
+
}
|
| 290 |
+
],
|
| 291 |
+
"kto_tag": "人类反馈 [true/false](必填)"
|
| 292 |
+
}
|
| 293 |
+
]
|
| 294 |
+
```
|
| 295 |
+
|
| 296 |
+
对于上述格式的数据,`dataset_info.json` 中的*数据集描述*应为:
|
| 297 |
+
|
| 298 |
+
```json
|
| 299 |
+
"数据集名称": {
|
| 300 |
+
"file_name": "data.json",
|
| 301 |
+
"formatting": "sharegpt",
|
| 302 |
+
"columns": {
|
| 303 |
+
"messages": "conversations",
|
| 304 |
+
"kto_tag": "kto_tag"
|
| 305 |
+
}
|
| 306 |
+
}
|
| 307 |
+
```
|
| 308 |
+
|
| 309 |
+
### 多模态图像数据集
|
| 310 |
+
|
| 311 |
+
- [样例数据集](mllm_demo.json)
|
| 312 |
+
|
| 313 |
+
多模态图像数据集需要额外添加一个 `images` 列,包含输入图像的路径。
|
| 314 |
+
|
| 315 |
+
注���图片的数量必须与文本中所有 `<image>` 标记的数量严格一致。
|
| 316 |
+
|
| 317 |
+
```json
|
| 318 |
+
[
|
| 319 |
+
{
|
| 320 |
+
"conversations": [
|
| 321 |
+
{
|
| 322 |
+
"from": "human",
|
| 323 |
+
"value": "<image><image>用户指令"
|
| 324 |
+
},
|
| 325 |
+
{
|
| 326 |
+
"from": "gpt",
|
| 327 |
+
"value": "模型回答"
|
| 328 |
+
}
|
| 329 |
+
],
|
| 330 |
+
"images": [
|
| 331 |
+
"图像路径(必填)",
|
| 332 |
+
"图像路径(必填)"
|
| 333 |
+
]
|
| 334 |
+
}
|
| 335 |
+
]
|
| 336 |
+
```
|
| 337 |
+
|
| 338 |
+
对于上述格式的数据,`dataset_info.json` 中的*数据集描述*应为:
|
| 339 |
+
|
| 340 |
+
```json
|
| 341 |
+
"数据集名称": {
|
| 342 |
+
"file_name": "data.json",
|
| 343 |
+
"formatting": "sharegpt",
|
| 344 |
+
"columns": {
|
| 345 |
+
"messages": "conversations",
|
| 346 |
+
"images": "images"
|
| 347 |
+
}
|
| 348 |
+
}
|
| 349 |
+
```
|
| 350 |
+
|
| 351 |
+
### 多模态视频数据集
|
| 352 |
+
|
| 353 |
+
- [样例数据集](mllm_video_demo.json)
|
| 354 |
+
|
| 355 |
+
多模态视频数据集需要额外添加一个 `videos` 列,包含输入视频的路径。
|
| 356 |
+
|
| 357 |
+
注意视频的数量必须与文本中所有 `<video>` 标记的数量严格一致。
|
| 358 |
+
|
| 359 |
+
```json
|
| 360 |
+
[
|
| 361 |
+
{
|
| 362 |
+
"conversations": [
|
| 363 |
+
{
|
| 364 |
+
"from": "human",
|
| 365 |
+
"value": "<video><video>用户指令"
|
| 366 |
+
},
|
| 367 |
+
{
|
| 368 |
+
"from": "gpt",
|
| 369 |
+
"value": "模型回答"
|
| 370 |
+
}
|
| 371 |
+
],
|
| 372 |
+
"videos": [
|
| 373 |
+
"视频路径(必填)",
|
| 374 |
+
"视频路径(必填)"
|
| 375 |
+
]
|
| 376 |
+
}
|
| 377 |
+
]
|
| 378 |
+
```
|
| 379 |
+
|
| 380 |
+
对于上述格式的数据,`dataset_info.json` 中的*数据集描述*应为:
|
| 381 |
+
|
| 382 |
+
```json
|
| 383 |
+
"数据集名称": {
|
| 384 |
+
"file_name": "data.json",
|
| 385 |
+
"formatting": "sharegpt",
|
| 386 |
+
"columns": {
|
| 387 |
+
"messages": "conversations",
|
| 388 |
+
"videos": "videos"
|
| 389 |
+
}
|
| 390 |
+
}
|
| 391 |
+
```
|
| 392 |
+
|
| 393 |
+
### 多模态音频数据集
|
| 394 |
+
|
| 395 |
+
- [样例数据集](mllm_audio_demo.json)
|
| 396 |
+
|
| 397 |
+
多模态音频数据集需要额外添加一个 `audios` 列,包含输入音频的路径。
|
| 398 |
+
|
| 399 |
+
注意音频的数量必须与文本中所有 `<audio>` 标记的数量严格一致。
|
| 400 |
+
|
| 401 |
+
```json
|
| 402 |
+
[
|
| 403 |
+
{
|
| 404 |
+
"conversations": [
|
| 405 |
+
{
|
| 406 |
+
"from": "human",
|
| 407 |
+
"value": "<audio><audio>用户指令"
|
| 408 |
+
},
|
| 409 |
+
{
|
| 410 |
+
"from": "gpt",
|
| 411 |
+
"value": "模型回答"
|
| 412 |
+
}
|
| 413 |
+
],
|
| 414 |
+
"audios": [
|
| 415 |
+
"音频路径(必填)",
|
| 416 |
+
"音频路径(必填)"
|
| 417 |
+
]
|
| 418 |
+
}
|
| 419 |
+
]
|
| 420 |
+
```
|
| 421 |
+
|
| 422 |
+
对于上述格式的数据,`dataset_info.json` 中的*数据集描述*应为:
|
| 423 |
+
|
| 424 |
+
```json
|
| 425 |
+
"数据集名称": {
|
| 426 |
+
"file_name": "data.json",
|
| 427 |
+
"formatting": "sharegpt",
|
| 428 |
+
"columns": {
|
| 429 |
+
"messages": "conversations",
|
| 430 |
+
"audios": "audios"
|
| 431 |
+
}
|
| 432 |
+
}
|
| 433 |
+
```
|
| 434 |
+
|
| 435 |
+
|
| 436 |
+
### OpenAI 格式
|
| 437 |
+
|
| 438 |
+
OpenAI 格式仅仅是 sharegpt 格式的一种特殊情况,其中第一条消息可能是系统提示词。
|
| 439 |
+
|
| 440 |
+
```json
|
| 441 |
+
[
|
| 442 |
+
{
|
| 443 |
+
"messages": [
|
| 444 |
+
{
|
| 445 |
+
"role": "system",
|
| 446 |
+
"content": "系统提示词(选填)"
|
| 447 |
+
},
|
| 448 |
+
{
|
| 449 |
+
"role": "user",
|
| 450 |
+
"content": "用户指令"
|
| 451 |
+
},
|
| 452 |
+
{
|
| 453 |
+
"role": "assistant",
|
| 454 |
+
"content": "模型回答"
|
| 455 |
+
}
|
| 456 |
+
]
|
| 457 |
+
}
|
| 458 |
+
]
|
| 459 |
+
```
|
| 460 |
+
|
| 461 |
+
对于上述格式的数据,`dataset_info.json` 中的*数据集描述*应为:
|
| 462 |
+
|
| 463 |
+
```json
|
| 464 |
+
"数据集名称": {
|
| 465 |
+
"file_name": "data.json",
|
| 466 |
+
"formatting": "sharegpt",
|
| 467 |
+
"columns": {
|
| 468 |
+
"messages": "messages"
|
| 469 |
+
},
|
| 470 |
+
"tags": {
|
| 471 |
+
"role_tag": "role",
|
| 472 |
+
"content_tag": "content",
|
| 473 |
+
"user_tag": "user",
|
| 474 |
+
"assistant_tag": "assistant",
|
| 475 |
+
"system_tag": "system"
|
| 476 |
+
}
|
| 477 |
+
}
|
| 478 |
+
```
|
data/belle_multiturn/belle_multiturn.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2025 the LlamaFactory team.
|
| 2 |
+
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
|
| 16 |
+
import json
|
| 17 |
+
import os
|
| 18 |
+
|
| 19 |
+
import datasets
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
_HF_ENDPOINT = os.getenv("HF_ENDPOINT", "https://huggingface.co")
|
| 23 |
+
|
| 24 |
+
_DESCRIPTION = "BELLE multiturn chat dataset."
|
| 25 |
+
|
| 26 |
+
_CITATION = """\
|
| 27 |
+
@article{belle2023exploring,
|
| 28 |
+
title={Exploring the Impact of Instruction Data Scaling on Large Language Models},
|
| 29 |
+
author={Yunjie Ji, Yong Deng, Yan Gong, Yiping Peng, Qiang Niu, Lei Zhang, Baochang Ma, Xiangang Li},
|
| 30 |
+
journal={arXiv preprint arXiv:2303.14742},
|
| 31 |
+
year={2023}
|
| 32 |
+
}
|
| 33 |
+
"""
|
| 34 |
+
|
| 35 |
+
_HOMEPAGE = f"{_HF_ENDPOINT}/datasets/BelleGroup/multiturn_chat_0.8M"
|
| 36 |
+
_LICENSE = "gpl-3.0"
|
| 37 |
+
_URL = f"{_HF_ENDPOINT}/datasets/BelleGroup/multiturn_chat_0.8M/resolve/main/multiturn_chat_0.8M.json"
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
class BelleMultiturn(datasets.GeneratorBasedBuilder):
|
| 41 |
+
VERSION = datasets.Version("0.0.0")
|
| 42 |
+
|
| 43 |
+
def _info(self):
|
| 44 |
+
features = datasets.Features(
|
| 45 |
+
{"conversations": [{"from": datasets.Value("string"), "value": datasets.Value("string")}]}
|
| 46 |
+
)
|
| 47 |
+
return datasets.DatasetInfo(
|
| 48 |
+
description=_DESCRIPTION, features=features, homepage=_HOMEPAGE, license=_LICENSE, citation=_CITATION
|
| 49 |
+
)
|
| 50 |
+
|
| 51 |
+
def _split_generators(self, dl_manager: datasets.DownloadManager):
|
| 52 |
+
file_path = dl_manager.download(_URL)
|
| 53 |
+
return [datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": file_path})]
|
| 54 |
+
|
| 55 |
+
def _generate_examples(self, filepath: str):
|
| 56 |
+
with open(filepath, encoding="utf-8") as f:
|
| 57 |
+
for key, row in enumerate(f):
|
| 58 |
+
data = json.loads(row)
|
| 59 |
+
conversations = []
|
| 60 |
+
prompt = data["instruction"].strip()
|
| 61 |
+
response = data["output"].strip()
|
| 62 |
+
|
| 63 |
+
assist_idx = prompt.rfind("Assistant:")
|
| 64 |
+
human_idx = prompt.rfind("Human:")
|
| 65 |
+
query = prompt[human_idx + 6 : assist_idx].strip()
|
| 66 |
+
prompt = prompt[:human_idx].strip()
|
| 67 |
+
conversations.insert(0, {"from": "gpt", "value": response})
|
| 68 |
+
conversations.insert(0, {"from": "human", "value": query})
|
| 69 |
+
|
| 70 |
+
while prompt.rfind("Assistant:") != -1:
|
| 71 |
+
assist_idx = prompt.rfind("Assistant:")
|
| 72 |
+
human_idx = prompt.rfind("Human:")
|
| 73 |
+
if human_idx != -1:
|
| 74 |
+
old_query = prompt[human_idx + 6 : assist_idx].strip()
|
| 75 |
+
old_resp = prompt[assist_idx + 10 :].strip()
|
| 76 |
+
conversations.insert(0, {"from": "gpt", "value": old_resp})
|
| 77 |
+
conversations.insert(0, {"from": "human", "value": old_query})
|
| 78 |
+
else:
|
| 79 |
+
break
|
| 80 |
+
prompt = prompt[:human_idx].strip()
|
| 81 |
+
|
| 82 |
+
yield key, {"conversations": conversations}
|
data/dataset_info.json
ADDED
|
@@ -0,0 +1,950 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
"mllm_audio_demo": {
|
| 42 |
+
"file_name": "mllm_audio_demo.json",
|
| 43 |
+
"formatting": "sharegpt",
|
| 44 |
+
"columns": {
|
| 45 |
+
"messages": "messages",
|
| 46 |
+
"audios": "audios"
|
| 47 |
+
},
|
| 48 |
+
"tags": {
|
| 49 |
+
"role_tag": "role",
|
| 50 |
+
"content_tag": "content",
|
| 51 |
+
"user_tag": "user",
|
| 52 |
+
"assistant_tag": "assistant"
|
| 53 |
+
}
|
| 54 |
+
},
|
| 55 |
+
"mllm_video_demo": {
|
| 56 |
+
"file_name": "mllm_video_demo.json",
|
| 57 |
+
"formatting": "sharegpt",
|
| 58 |
+
"columns": {
|
| 59 |
+
"messages": "messages",
|
| 60 |
+
"videos": "videos"
|
| 61 |
+
},
|
| 62 |
+
"tags": {
|
| 63 |
+
"role_tag": "role",
|
| 64 |
+
"content_tag": "content",
|
| 65 |
+
"user_tag": "user",
|
| 66 |
+
"assistant_tag": "assistant"
|
| 67 |
+
}
|
| 68 |
+
},
|
| 69 |
+
"mllm_video_audio_demo": {
|
| 70 |
+
"file_name": "mllm_video_audio_demo.json",
|
| 71 |
+
"formatting": "sharegpt",
|
| 72 |
+
"columns": {
|
| 73 |
+
"messages": "messages",
|
| 74 |
+
"videos": "videos",
|
| 75 |
+
"audios": "audios"
|
| 76 |
+
},
|
| 77 |
+
"tags": {
|
| 78 |
+
"role_tag": "role",
|
| 79 |
+
"content_tag": "content",
|
| 80 |
+
"user_tag": "user",
|
| 81 |
+
"assistant_tag": "assistant"
|
| 82 |
+
}
|
| 83 |
+
},
|
| 84 |
+
"alpaca_en": {
|
| 85 |
+
"hf_hub_url": "llamafactory/alpaca_en",
|
| 86 |
+
"ms_hub_url": "llamafactory/alpaca_en",
|
| 87 |
+
"om_hub_url": "HaM/alpaca_en"
|
| 88 |
+
},
|
| 89 |
+
"alpaca_zh": {
|
| 90 |
+
"hf_hub_url": "llamafactory/alpaca_zh",
|
| 91 |
+
"ms_hub_url": "llamafactory/alpaca_zh"
|
| 92 |
+
},
|
| 93 |
+
"alpaca_gpt4_en": {
|
| 94 |
+
"hf_hub_url": "llamafactory/alpaca_gpt4_en",
|
| 95 |
+
"ms_hub_url": "llamafactory/alpaca_gpt4_en"
|
| 96 |
+
},
|
| 97 |
+
"alpaca_gpt4_zh": {
|
| 98 |
+
"hf_hub_url": "llamafactory/alpaca_gpt4_zh",
|
| 99 |
+
"ms_hub_url": "llamafactory/alpaca_gpt4_zh",
|
| 100 |
+
"om_hub_url": "State_Cloud/alpaca-gpt4-data-zh"
|
| 101 |
+
},
|
| 102 |
+
"glaive_toolcall_en": {
|
| 103 |
+
"hf_hub_url": "llamafactory/glaive_toolcall_en",
|
| 104 |
+
"formatting": "sharegpt",
|
| 105 |
+
"columns": {
|
| 106 |
+
"messages": "conversations",
|
| 107 |
+
"tools": "tools"
|
| 108 |
+
}
|
| 109 |
+
},
|
| 110 |
+
"glaive_toolcall_zh": {
|
| 111 |
+
"hf_hub_url": "llamafactory/glaive_toolcall_zh",
|
| 112 |
+
"formatting": "sharegpt",
|
| 113 |
+
"columns": {
|
| 114 |
+
"messages": "conversations",
|
| 115 |
+
"tools": "tools"
|
| 116 |
+
}
|
| 117 |
+
},
|
| 118 |
+
"lima": {
|
| 119 |
+
"hf_hub_url": "llamafactory/lima",
|
| 120 |
+
"formatting": "sharegpt"
|
| 121 |
+
},
|
| 122 |
+
"guanaco": {
|
| 123 |
+
"hf_hub_url": "JosephusCheung/GuanacoDataset",
|
| 124 |
+
"ms_hub_url": "AI-ModelScope/GuanacoDataset"
|
| 125 |
+
},
|
| 126 |
+
"belle_2m": {
|
| 127 |
+
"hf_hub_url": "BelleGroup/train_2M_CN",
|
| 128 |
+
"ms_hub_url": "AI-ModelScope/train_2M_CN"
|
| 129 |
+
},
|
| 130 |
+
"belle_1m": {
|
| 131 |
+
"hf_hub_url": "BelleGroup/train_1M_CN",
|
| 132 |
+
"ms_hub_url": "AI-ModelScope/train_1M_CN"
|
| 133 |
+
},
|
| 134 |
+
"belle_0.5m": {
|
| 135 |
+
"hf_hub_url": "BelleGroup/train_0.5M_CN",
|
| 136 |
+
"ms_hub_url": "AI-ModelScope/train_0.5M_CN"
|
| 137 |
+
},
|
| 138 |
+
"belle_dialog": {
|
| 139 |
+
"hf_hub_url": "BelleGroup/generated_chat_0.4M",
|
| 140 |
+
"ms_hub_url": "AI-ModelScope/generated_chat_0.4M"
|
| 141 |
+
},
|
| 142 |
+
"belle_math": {
|
| 143 |
+
"hf_hub_url": "BelleGroup/school_math_0.25M",
|
| 144 |
+
"ms_hub_url": "AI-ModelScope/school_math_0.25M"
|
| 145 |
+
},
|
| 146 |
+
"belle_multiturn": {
|
| 147 |
+
"script_url": "belle_multiturn",
|
| 148 |
+
"formatting": "sharegpt"
|
| 149 |
+
},
|
| 150 |
+
"ultra_chat": {
|
| 151 |
+
"script_url": "ultra_chat",
|
| 152 |
+
"formatting": "sharegpt"
|
| 153 |
+
},
|
| 154 |
+
"open_platypus": {
|
| 155 |
+
"hf_hub_url": "garage-bAInd/Open-Platypus",
|
| 156 |
+
"ms_hub_url": "AI-ModelScope/Open-Platypus"
|
| 157 |
+
},
|
| 158 |
+
"codealpaca": {
|
| 159 |
+
"hf_hub_url": "sahil2801/CodeAlpaca-20k",
|
| 160 |
+
"ms_hub_url": "AI-ModelScope/CodeAlpaca-20k"
|
| 161 |
+
},
|
| 162 |
+
"alpaca_cot": {
|
| 163 |
+
"hf_hub_url": "QingyiSi/Alpaca-CoT",
|
| 164 |
+
"ms_hub_url": "AI-ModelScope/Alpaca-CoT"
|
| 165 |
+
},
|
| 166 |
+
"openorca": {
|
| 167 |
+
"hf_hub_url": "Open-Orca/OpenOrca",
|
| 168 |
+
"ms_hub_url": "AI-ModelScope/OpenOrca",
|
| 169 |
+
"columns": {
|
| 170 |
+
"prompt": "question",
|
| 171 |
+
"response": "response",
|
| 172 |
+
"system": "system_prompt"
|
| 173 |
+
}
|
| 174 |
+
},
|
| 175 |
+
"slimorca": {
|
| 176 |
+
"hf_hub_url": "Open-Orca/SlimOrca",
|
| 177 |
+
"formatting": "sharegpt"
|
| 178 |
+
},
|
| 179 |
+
"mathinstruct": {
|
| 180 |
+
"hf_hub_url": "TIGER-Lab/MathInstruct",
|
| 181 |
+
"ms_hub_url": "AI-ModelScope/MathInstruct",
|
| 182 |
+
"columns": {
|
| 183 |
+
"prompt": "instruction",
|
| 184 |
+
"response": "output"
|
| 185 |
+
}
|
| 186 |
+
},
|
| 187 |
+
"firefly": {
|
| 188 |
+
"hf_hub_url": "YeungNLP/firefly-train-1.1M",
|
| 189 |
+
"columns": {
|
| 190 |
+
"prompt": "input",
|
| 191 |
+
"response": "target"
|
| 192 |
+
}
|
| 193 |
+
},
|
| 194 |
+
"wikiqa": {
|
| 195 |
+
"hf_hub_url": "wiki_qa",
|
| 196 |
+
"columns": {
|
| 197 |
+
"prompt": "question",
|
| 198 |
+
"response": "answer"
|
| 199 |
+
}
|
| 200 |
+
},
|
| 201 |
+
"webqa": {
|
| 202 |
+
"hf_hub_url": "suolyer/webqa",
|
| 203 |
+
"ms_hub_url": "AI-ModelScope/webqa",
|
| 204 |
+
"columns": {
|
| 205 |
+
"prompt": "input",
|
| 206 |
+
"response": "output"
|
| 207 |
+
}
|
| 208 |
+
},
|
| 209 |
+
"webnovel": {
|
| 210 |
+
"hf_hub_url": "zxbsmk/webnovel_cn",
|
| 211 |
+
"ms_hub_url": "AI-ModelScope/webnovel_cn"
|
| 212 |
+
},
|
| 213 |
+
"nectar_sft": {
|
| 214 |
+
"hf_hub_url": "AstraMindAI/SFT-Nectar",
|
| 215 |
+
"ms_hub_url": "AI-ModelScope/SFT-Nectar"
|
| 216 |
+
},
|
| 217 |
+
"deepctrl": {
|
| 218 |
+
"ms_hub_url": "deepctrl/deepctrl-sft-data"
|
| 219 |
+
},
|
| 220 |
+
"adgen_train": {
|
| 221 |
+
"hf_hub_url": "HasturOfficial/adgen",
|
| 222 |
+
"ms_hub_url": "AI-ModelScope/adgen",
|
| 223 |
+
"split": "train",
|
| 224 |
+
"columns": {
|
| 225 |
+
"prompt": "content",
|
| 226 |
+
"response": "summary"
|
| 227 |
+
}
|
| 228 |
+
},
|
| 229 |
+
"adgen_eval": {
|
| 230 |
+
"hf_hub_url": "HasturOfficial/adgen",
|
| 231 |
+
"ms_hub_url": "AI-ModelScope/adgen",
|
| 232 |
+
"split": "validation",
|
| 233 |
+
"columns": {
|
| 234 |
+
"prompt": "content",
|
| 235 |
+
"response": "summary"
|
| 236 |
+
}
|
| 237 |
+
},
|
| 238 |
+
"sharegpt_hyper": {
|
| 239 |
+
"hf_hub_url": "totally-not-an-llm/sharegpt-hyperfiltered-3k",
|
| 240 |
+
"formatting": "sharegpt"
|
| 241 |
+
},
|
| 242 |
+
"sharegpt4": {
|
| 243 |
+
"hf_hub_url": "shibing624/sharegpt_gpt4",
|
| 244 |
+
"ms_hub_url": "AI-ModelScope/sharegpt_gpt4",
|
| 245 |
+
"formatting": "sharegpt"
|
| 246 |
+
},
|
| 247 |
+
"ultrachat_200k": {
|
| 248 |
+
"hf_hub_url": "HuggingFaceH4/ultrachat_200k",
|
| 249 |
+
"ms_hub_url": "AI-ModelScope/ultrachat_200k",
|
| 250 |
+
"split": "train_sft",
|
| 251 |
+
"formatting": "sharegpt",
|
| 252 |
+
"columns": {
|
| 253 |
+
"messages": "messages"
|
| 254 |
+
},
|
| 255 |
+
"tags": {
|
| 256 |
+
"role_tag": "role",
|
| 257 |
+
"content_tag": "content",
|
| 258 |
+
"user_tag": "user",
|
| 259 |
+
"assistant_tag": "assistant"
|
| 260 |
+
}
|
| 261 |
+
},
|
| 262 |
+
"agent_instruct": {
|
| 263 |
+
"hf_hub_url": "THUDM/AgentInstruct",
|
| 264 |
+
"ms_hub_url": "ZhipuAI/AgentInstruct",
|
| 265 |
+
"formatting": "sharegpt"
|
| 266 |
+
},
|
| 267 |
+
"lmsys_chat": {
|
| 268 |
+
"hf_hub_url": "lmsys/lmsys-chat-1m",
|
| 269 |
+
"ms_hub_url": "AI-ModelScope/lmsys-chat-1m",
|
| 270 |
+
"formatting": "sharegpt",
|
| 271 |
+
"columns": {
|
| 272 |
+
"messages": "conversation"
|
| 273 |
+
},
|
| 274 |
+
"tags": {
|
| 275 |
+
"role_tag": "role",
|
| 276 |
+
"content_tag": "content",
|
| 277 |
+
"user_tag": "user",
|
| 278 |
+
"assistant_tag": "assistant"
|
| 279 |
+
}
|
| 280 |
+
},
|
| 281 |
+
"evol_instruct": {
|
| 282 |
+
"hf_hub_url": "WizardLM/WizardLM_evol_instruct_V2_196k",
|
| 283 |
+
"ms_hub_url": "AI-ModelScope/WizardLM_evol_instruct_V2_196k",
|
| 284 |
+
"formatting": "sharegpt"
|
| 285 |
+
},
|
| 286 |
+
"glaive_toolcall_100k": {
|
| 287 |
+
"hf_hub_url": "hiyouga/glaive-function-calling-v2-sharegpt",
|
| 288 |
+
"formatting": "sharegpt",
|
| 289 |
+
"columns": {
|
| 290 |
+
"messages": "conversations",
|
| 291 |
+
"tools": "tools"
|
| 292 |
+
}
|
| 293 |
+
},
|
| 294 |
+
"cosmopedia": {
|
| 295 |
+
"hf_hub_url": "HuggingFaceTB/cosmopedia",
|
| 296 |
+
"columns": {
|
| 297 |
+
"prompt": "prompt",
|
| 298 |
+
"response": "text"
|
| 299 |
+
}
|
| 300 |
+
},
|
| 301 |
+
"stem_zh": {
|
| 302 |
+
"hf_hub_url": "hfl/stem_zh_instruction"
|
| 303 |
+
},
|
| 304 |
+
"ruozhiba_gpt4": {
|
| 305 |
+
"hf_hub_url": "hfl/ruozhiba_gpt4_turbo"
|
| 306 |
+
},
|
| 307 |
+
"neo_sft": {
|
| 308 |
+
"hf_hub_url": "m-a-p/neo_sft_phase2",
|
| 309 |
+
"formatting": "sharegpt"
|
| 310 |
+
},
|
| 311 |
+
"magpie_pro_300k": {
|
| 312 |
+
"hf_hub_url": "Magpie-Align/Magpie-Pro-300K-Filtered",
|
| 313 |
+
"formatting": "sharegpt"
|
| 314 |
+
},
|
| 315 |
+
"magpie_ultra": {
|
| 316 |
+
"hf_hub_url": "argilla/magpie-ultra-v0.1",
|
| 317 |
+
"columns": {
|
| 318 |
+
"prompt": "instruction",
|
| 319 |
+
"response": "response"
|
| 320 |
+
}
|
| 321 |
+
},
|
| 322 |
+
"web_instruct": {
|
| 323 |
+
"hf_hub_url": "TIGER-Lab/WebInstructSub",
|
| 324 |
+
"columns": {
|
| 325 |
+
"prompt": "question",
|
| 326 |
+
"response": "answer"
|
| 327 |
+
}
|
| 328 |
+
},
|
| 329 |
+
"openo1_sft": {
|
| 330 |
+
"hf_hub_url": "llamafactory/OpenO1-SFT",
|
| 331 |
+
"ms_hub_url": "llamafactory/OpenO1-SFT",
|
| 332 |
+
"columns": {
|
| 333 |
+
"prompt": "prompt",
|
| 334 |
+
"response": "response"
|
| 335 |
+
}
|
| 336 |
+
},
|
| 337 |
+
"open_thoughts": {
|
| 338 |
+
"hf_hub_url": "llamafactory/OpenThoughts-114k",
|
| 339 |
+
"formatting": "sharegpt",
|
| 340 |
+
"columns": {
|
| 341 |
+
"messages": "messages"
|
| 342 |
+
},
|
| 343 |
+
"tags": {
|
| 344 |
+
"role_tag": "role",
|
| 345 |
+
"content_tag": "content",
|
| 346 |
+
"user_tag": "user",
|
| 347 |
+
"assistant_tag": "assistant",
|
| 348 |
+
"system_tag": "system"
|
| 349 |
+
}
|
| 350 |
+
},
|
| 351 |
+
"open_r1_math": {
|
| 352 |
+
"hf_hub_url": "llamafactory/OpenR1-Math-94k",
|
| 353 |
+
"formatting": "sharegpt",
|
| 354 |
+
"columns": {
|
| 355 |
+
"messages": "messages"
|
| 356 |
+
},
|
| 357 |
+
"tags": {
|
| 358 |
+
"role_tag": "role",
|
| 359 |
+
"content_tag": "content",
|
| 360 |
+
"user_tag": "user",
|
| 361 |
+
"assistant_tag": "assistant",
|
| 362 |
+
"system_tag": "system"
|
| 363 |
+
}
|
| 364 |
+
},
|
| 365 |
+
"chinese_r1_distill": {
|
| 366 |
+
"hf_hub_url": "Congliu/Chinese-DeepSeek-R1-Distill-data-110k-SFT",
|
| 367 |
+
"ms_hub_url": "liucong/Chinese-DeepSeek-R1-Distill-data-110k-SFT"
|
| 368 |
+
},
|
| 369 |
+
"llava_1k_en": {
|
| 370 |
+
"hf_hub_url": "BUAADreamer/llava-en-zh-2k",
|
| 371 |
+
"subset": "en",
|
| 372 |
+
"formatting": "sharegpt",
|
| 373 |
+
"columns": {
|
| 374 |
+
"messages": "messages",
|
| 375 |
+
"images": "images"
|
| 376 |
+
},
|
| 377 |
+
"tags": {
|
| 378 |
+
"role_tag": "role",
|
| 379 |
+
"content_tag": "content",
|
| 380 |
+
"user_tag": "user",
|
| 381 |
+
"assistant_tag": "assistant"
|
| 382 |
+
}
|
| 383 |
+
},
|
| 384 |
+
"llava_1k_zh": {
|
| 385 |
+
"hf_hub_url": "BUAADreamer/llava-en-zh-2k",
|
| 386 |
+
"subset": "zh",
|
| 387 |
+
"formatting": "sharegpt",
|
| 388 |
+
"columns": {
|
| 389 |
+
"messages": "messages",
|
| 390 |
+
"images": "images"
|
| 391 |
+
},
|
| 392 |
+
"tags": {
|
| 393 |
+
"role_tag": "role",
|
| 394 |
+
"content_tag": "content",
|
| 395 |
+
"user_tag": "user",
|
| 396 |
+
"assistant_tag": "assistant"
|
| 397 |
+
}
|
| 398 |
+
},
|
| 399 |
+
"llava_150k_en": {
|
| 400 |
+
"hf_hub_url": "BUAADreamer/llava-en-zh-300k",
|
| 401 |
+
"subset": "en",
|
| 402 |
+
"formatting": "sharegpt",
|
| 403 |
+
"columns": {
|
| 404 |
+
"messages": "messages",
|
| 405 |
+
"images": "images"
|
| 406 |
+
},
|
| 407 |
+
"tags": {
|
| 408 |
+
"role_tag": "role",
|
| 409 |
+
"content_tag": "content",
|
| 410 |
+
"user_tag": "user",
|
| 411 |
+
"assistant_tag": "assistant"
|
| 412 |
+
}
|
| 413 |
+
},
|
| 414 |
+
"llava_150k_zh": {
|
| 415 |
+
"hf_hub_url": "BUAADreamer/llava-en-zh-300k",
|
| 416 |
+
"subset": "zh",
|
| 417 |
+
"formatting": "sharegpt",
|
| 418 |
+
"columns": {
|
| 419 |
+
"messages": "messages",
|
| 420 |
+
"images": "images"
|
| 421 |
+
},
|
| 422 |
+
"tags": {
|
| 423 |
+
"role_tag": "role",
|
| 424 |
+
"content_tag": "content",
|
| 425 |
+
"user_tag": "user",
|
| 426 |
+
"assistant_tag": "assistant"
|
| 427 |
+
}
|
| 428 |
+
},
|
| 429 |
+
"pokemon_cap": {
|
| 430 |
+
"hf_hub_url": "llamafactory/pokemon-gpt4o-captions",
|
| 431 |
+
"formatting": "sharegpt",
|
| 432 |
+
"columns": {
|
| 433 |
+
"messages": "conversations",
|
| 434 |
+
"images": "images"
|
| 435 |
+
}
|
| 436 |
+
},
|
| 437 |
+
"mllm_pt_demo": {
|
| 438 |
+
"hf_hub_url": "BUAADreamer/mllm_pt_demo",
|
| 439 |
+
"formatting": "sharegpt",
|
| 440 |
+
"columns": {
|
| 441 |
+
"messages": "messages",
|
| 442 |
+
"images": "images"
|
| 443 |
+
},
|
| 444 |
+
"tags": {
|
| 445 |
+
"role_tag": "role",
|
| 446 |
+
"content_tag": "content",
|
| 447 |
+
"user_tag": "user",
|
| 448 |
+
"assistant_tag": "assistant"
|
| 449 |
+
}
|
| 450 |
+
},
|
| 451 |
+
"oasst_de": {
|
| 452 |
+
"hf_hub_url": "mayflowergmbh/oasst_de"
|
| 453 |
+
},
|
| 454 |
+
"dolly_15k_de": {
|
| 455 |
+
"hf_hub_url": "mayflowergmbh/dolly-15k_de"
|
| 456 |
+
},
|
| 457 |
+
"alpaca-gpt4_de": {
|
| 458 |
+
"hf_hub_url": "mayflowergmbh/alpaca-gpt4_de"
|
| 459 |
+
},
|
| 460 |
+
"openschnabeltier_de": {
|
| 461 |
+
"hf_hub_url": "mayflowergmbh/openschnabeltier_de"
|
| 462 |
+
},
|
| 463 |
+
"evol_instruct_de": {
|
| 464 |
+
"hf_hub_url": "mayflowergmbh/evol-instruct_de"
|
| 465 |
+
},
|
| 466 |
+
"dolphin_de": {
|
| 467 |
+
"hf_hub_url": "mayflowergmbh/dolphin_de"
|
| 468 |
+
},
|
| 469 |
+
"booksum_de": {
|
| 470 |
+
"hf_hub_url": "mayflowergmbh/booksum_de"
|
| 471 |
+
},
|
| 472 |
+
"airoboros_de": {
|
| 473 |
+
"hf_hub_url": "mayflowergmbh/airoboros-3.0_de"
|
| 474 |
+
},
|
| 475 |
+
"ultrachat_de": {
|
| 476 |
+
"hf_hub_url": "mayflowergmbh/ultra-chat_de"
|
| 477 |
+
},
|
| 478 |
+
"dpo_en_demo": {
|
| 479 |
+
"file_name": "dpo_en_demo.json",
|
| 480 |
+
"ranking": true,
|
| 481 |
+
"formatting": "sharegpt",
|
| 482 |
+
"columns": {
|
| 483 |
+
"messages": "conversations",
|
| 484 |
+
"chosen": "chosen",
|
| 485 |
+
"rejected": "rejected"
|
| 486 |
+
}
|
| 487 |
+
},
|
| 488 |
+
"dpo_zh_demo": {
|
| 489 |
+
"file_name": "dpo_zh_demo.json",
|
| 490 |
+
"ranking": true,
|
| 491 |
+
"formatting": "sharegpt",
|
| 492 |
+
"columns": {
|
| 493 |
+
"messages": "conversations",
|
| 494 |
+
"chosen": "chosen",
|
| 495 |
+
"rejected": "rejected"
|
| 496 |
+
}
|
| 497 |
+
},
|
| 498 |
+
"dpo_mix_en": {
|
| 499 |
+
"hf_hub_url": "llamafactory/DPO-En-Zh-20k",
|
| 500 |
+
"subset": "en",
|
| 501 |
+
"ranking": true,
|
| 502 |
+
"formatting": "sharegpt",
|
| 503 |
+
"columns": {
|
| 504 |
+
"messages": "conversations",
|
| 505 |
+
"chosen": "chosen",
|
| 506 |
+
"rejected": "rejected"
|
| 507 |
+
}
|
| 508 |
+
},
|
| 509 |
+
"dpo_mix_zh": {
|
| 510 |
+
"hf_hub_url": "llamafactory/DPO-En-Zh-20k",
|
| 511 |
+
"subset": "zh",
|
| 512 |
+
"ranking": true,
|
| 513 |
+
"formatting": "sharegpt",
|
| 514 |
+
"columns": {
|
| 515 |
+
"messages": "conversations",
|
| 516 |
+
"chosen": "chosen",
|
| 517 |
+
"rejected": "rejected"
|
| 518 |
+
}
|
| 519 |
+
},
|
| 520 |
+
"ultrafeedback": {
|
| 521 |
+
"hf_hub_url": "llamafactory/ultrafeedback_binarized",
|
| 522 |
+
"ms_hub_url": "llamafactory/ultrafeedback_binarized",
|
| 523 |
+
"ranking": true,
|
| 524 |
+
"columns": {
|
| 525 |
+
"prompt": "instruction",
|
| 526 |
+
"chosen": "chosen",
|
| 527 |
+
"rejected": "rejected"
|
| 528 |
+
}
|
| 529 |
+
},
|
| 530 |
+
"coig_p": {
|
| 531 |
+
"hf_hub_url": "m-a-p/COIG-P",
|
| 532 |
+
"ranking": true,
|
| 533 |
+
"formatting": "sharegpt",
|
| 534 |
+
"columns": {
|
| 535 |
+
"messages": "conversations",
|
| 536 |
+
"chosen": "chosen",
|
| 537 |
+
"rejected": "rejected"
|
| 538 |
+
}
|
| 539 |
+
},
|
| 540 |
+
"rlhf_v": {
|
| 541 |
+
"hf_hub_url": "llamafactory/RLHF-V",
|
| 542 |
+
"ranking": true,
|
| 543 |
+
"formatting": "sharegpt",
|
| 544 |
+
"columns": {
|
| 545 |
+
"messages": "conversations",
|
| 546 |
+
"chosen": "chosen",
|
| 547 |
+
"rejected": "rejected",
|
| 548 |
+
"images": "images"
|
| 549 |
+
}
|
| 550 |
+
},
|
| 551 |
+
"vlfeedback": {
|
| 552 |
+
"hf_hub_url": "Zhihui/VLFeedback",
|
| 553 |
+
"ranking": true,
|
| 554 |
+
"formatting": "sharegpt",
|
| 555 |
+
"columns": {
|
| 556 |
+
"messages": "conversations",
|
| 557 |
+
"chosen": "chosen",
|
| 558 |
+
"rejected": "rejected",
|
| 559 |
+
"images": "images"
|
| 560 |
+
}
|
| 561 |
+
},
|
| 562 |
+
"rlaif_v": {
|
| 563 |
+
"hf_hub_url": "openbmb/RLAIF-V-Dataset",
|
| 564 |
+
"ranking": true,
|
| 565 |
+
"columns": {
|
| 566 |
+
"prompt": "question",
|
| 567 |
+
"chosen": "chosen",
|
| 568 |
+
"rejected": "rejected",
|
| 569 |
+
"images": "image"
|
| 570 |
+
}
|
| 571 |
+
},
|
| 572 |
+
"orca_pairs": {
|
| 573 |
+
"hf_hub_url": "Intel/orca_dpo_pairs",
|
| 574 |
+
"ranking": true,
|
| 575 |
+
"columns": {
|
| 576 |
+
"prompt": "question",
|
| 577 |
+
"chosen": "chosen",
|
| 578 |
+
"rejected": "rejected",
|
| 579 |
+
"system": "system"
|
| 580 |
+
}
|
| 581 |
+
},
|
| 582 |
+
"hh_rlhf_en": {
|
| 583 |
+
"script_url": "hh_rlhf_en",
|
| 584 |
+
"ranking": true,
|
| 585 |
+
"columns": {
|
| 586 |
+
"prompt": "instruction",
|
| 587 |
+
"chosen": "chosen",
|
| 588 |
+
"rejected": "rejected",
|
| 589 |
+
"history": "history"
|
| 590 |
+
}
|
| 591 |
+
},
|
| 592 |
+
"nectar_rm": {
|
| 593 |
+
"hf_hub_url": "AstraMindAI/RLAIF-Nectar",
|
| 594 |
+
"ms_hub_url": "AI-ModelScope/RLAIF-Nectar",
|
| 595 |
+
"ranking": true
|
| 596 |
+
},
|
| 597 |
+
"orca_dpo_de": {
|
| 598 |
+
"hf_hub_url": "mayflowergmbh/intel_orca_dpo_pairs_de",
|
| 599 |
+
"ranking": true
|
| 600 |
+
},
|
| 601 |
+
"kto_en_demo": {
|
| 602 |
+
"file_name": "kto_en_demo.json",
|
| 603 |
+
"formatting": "sharegpt",
|
| 604 |
+
"columns": {
|
| 605 |
+
"messages": "messages",
|
| 606 |
+
"kto_tag": "label"
|
| 607 |
+
},
|
| 608 |
+
"tags": {
|
| 609 |
+
"role_tag": "role",
|
| 610 |
+
"content_tag": "content",
|
| 611 |
+
"user_tag": "user",
|
| 612 |
+
"assistant_tag": "assistant"
|
| 613 |
+
}
|
| 614 |
+
},
|
| 615 |
+
"kto_mix_en": {
|
| 616 |
+
"hf_hub_url": "argilla/kto-mix-15k",
|
| 617 |
+
"formatting": "sharegpt",
|
| 618 |
+
"columns": {
|
| 619 |
+
"messages": "completion",
|
| 620 |
+
"kto_tag": "label"
|
| 621 |
+
},
|
| 622 |
+
"tags": {
|
| 623 |
+
"role_tag": "role",
|
| 624 |
+
"content_tag": "content",
|
| 625 |
+
"user_tag": "user",
|
| 626 |
+
"assistant_tag": "assistant"
|
| 627 |
+
}
|
| 628 |
+
},
|
| 629 |
+
"ultrafeedback_kto": {
|
| 630 |
+
"hf_hub_url": "argilla/ultrafeedback-binarized-preferences-cleaned-kto",
|
| 631 |
+
"ms_hub_url": "AI-ModelScope/ultrafeedback-binarized-preferences-cleaned-kto",
|
| 632 |
+
"columns": {
|
| 633 |
+
"prompt": "prompt",
|
| 634 |
+
"response": "completion",
|
| 635 |
+
"kto_tag": "label"
|
| 636 |
+
}
|
| 637 |
+
},
|
| 638 |
+
"wiki_demo": {
|
| 639 |
+
"file_name": "wiki_demo.txt",
|
| 640 |
+
"columns": {
|
| 641 |
+
"prompt": "text"
|
| 642 |
+
}
|
| 643 |
+
},
|
| 644 |
+
"c4_demo": {
|
| 645 |
+
"file_name": "c4_demo.jsonl",
|
| 646 |
+
"columns": {
|
| 647 |
+
"prompt": "text"
|
| 648 |
+
}
|
| 649 |
+
},
|
| 650 |
+
"refinedweb": {
|
| 651 |
+
"hf_hub_url": "tiiuae/falcon-refinedweb",
|
| 652 |
+
"columns": {
|
| 653 |
+
"prompt": "content"
|
| 654 |
+
}
|
| 655 |
+
},
|
| 656 |
+
"redpajama_v2": {
|
| 657 |
+
"hf_hub_url": "togethercomputer/RedPajama-Data-V2",
|
| 658 |
+
"columns": {
|
| 659 |
+
"prompt": "raw_content"
|
| 660 |
+
},
|
| 661 |
+
"subset": "default"
|
| 662 |
+
},
|
| 663 |
+
"wikipedia_en": {
|
| 664 |
+
"hf_hub_url": "olm/olm-wikipedia-20221220",
|
| 665 |
+
"ms_hub_url": "AI-ModelScope/olm-wikipedia-20221220",
|
| 666 |
+
"columns": {
|
| 667 |
+
"prompt": "text"
|
| 668 |
+
}
|
| 669 |
+
},
|
| 670 |
+
"wikipedia_zh": {
|
| 671 |
+
"hf_hub_url": "pleisto/wikipedia-cn-20230720-filtered",
|
| 672 |
+
"ms_hub_url": "AI-ModelScope/wikipedia-cn-20230720-filtered",
|
| 673 |
+
"columns": {
|
| 674 |
+
"prompt": "completion"
|
| 675 |
+
}
|
| 676 |
+
},
|
| 677 |
+
"pile": {
|
| 678 |
+
"hf_hub_url": "monology/pile-uncopyrighted",
|
| 679 |
+
"ms_hub_url": "AI-ModelScope/pile",
|
| 680 |
+
"columns": {
|
| 681 |
+
"prompt": "text"
|
| 682 |
+
}
|
| 683 |
+
},
|
| 684 |
+
"skypile": {
|
| 685 |
+
"hf_hub_url": "Skywork/SkyPile-150B",
|
| 686 |
+
"ms_hub_url": "AI-ModelScope/SkyPile-150B",
|
| 687 |
+
"columns": {
|
| 688 |
+
"prompt": "text"
|
| 689 |
+
}
|
| 690 |
+
},
|
| 691 |
+
"fineweb": {
|
| 692 |
+
"hf_hub_url": "HuggingFaceFW/fineweb",
|
| 693 |
+
"columns": {
|
| 694 |
+
"prompt": "text"
|
| 695 |
+
}
|
| 696 |
+
},
|
| 697 |
+
"fineweb_edu": {
|
| 698 |
+
"hf_hub_url": "HuggingFaceFW/fineweb-edu",
|
| 699 |
+
"columns": {
|
| 700 |
+
"prompt": "text"
|
| 701 |
+
}
|
| 702 |
+
},
|
| 703 |
+
"the_stack": {
|
| 704 |
+
"hf_hub_url": "bigcode/the-stack",
|
| 705 |
+
"ms_hub_url": "AI-ModelScope/the-stack",
|
| 706 |
+
"columns": {
|
| 707 |
+
"prompt": "content"
|
| 708 |
+
}
|
| 709 |
+
},
|
| 710 |
+
"starcoder_python": {
|
| 711 |
+
"hf_hub_url": "bigcode/starcoderdata",
|
| 712 |
+
"ms_hub_url": "AI-ModelScope/starcoderdata",
|
| 713 |
+
"columns": {
|
| 714 |
+
"prompt": "content"
|
| 715 |
+
},
|
| 716 |
+
"folder": "python"
|
| 717 |
+
},
|
| 718 |
+
"9.8feedback_sharegpt": {
|
| 719 |
+
"file_name": "9.8feedback_converted.json",
|
| 720 |
+
"formatting": "sharegpt",
|
| 721 |
+
"columns": {
|
| 722 |
+
"messages": "conversations",
|
| 723 |
+
"system": "system"
|
| 724 |
+
},
|
| 725 |
+
"tags": {
|
| 726 |
+
"role_tag": "from",
|
| 727 |
+
"content_tag": "value",
|
| 728 |
+
"user_tag": "human",
|
| 729 |
+
"assistant_tag": "gpt",
|
| 730 |
+
"system_tag": "system"
|
| 731 |
+
}
|
| 732 |
+
},
|
| 733 |
+
"9_25_dpo_fd_mistral": {
|
| 734 |
+
"file_name": "9_25_dpo_fd_mistral_converted_lab4.json",
|
| 735 |
+
"formatting": "sharegpt",
|
| 736 |
+
"ranking": true,
|
| 737 |
+
"columns": {
|
| 738 |
+
"messages": "conversations",
|
| 739 |
+
"chosen": "chosen",
|
| 740 |
+
"rejected": "rejected"
|
| 741 |
+
},
|
| 742 |
+
"tags": {
|
| 743 |
+
"role_tag": "from",
|
| 744 |
+
"content_tag": "value",
|
| 745 |
+
"user_tag": "human",
|
| 746 |
+
"assistant_tag": "gpt",
|
| 747 |
+
"system_tag": "system"
|
| 748 |
+
}
|
| 749 |
+
},
|
| 750 |
+
"reward_align": {
|
| 751 |
+
"file_name": "/home/LLaMA-Factory/data/filtered_data_9w_by_quota.json",
|
| 752 |
+
"formatting": "sharegpt",
|
| 753 |
+
"ranking": true,
|
| 754 |
+
"columns": {
|
| 755 |
+
"messages": "conversations",
|
| 756 |
+
"chosen": "chosen",
|
| 757 |
+
"rejected": "rejected"
|
| 758 |
+
},
|
| 759 |
+
"tags": {
|
| 760 |
+
"role_tag": "from",
|
| 761 |
+
"content_tag": "value",
|
| 762 |
+
"user_tag": "human",
|
| 763 |
+
"assistant_tag": "gpt",
|
| 764 |
+
"system_tag": "system"
|
| 765 |
+
}
|
| 766 |
+
},
|
| 767 |
+
"mistral_converted_lab5_sft": {
|
| 768 |
+
"file_name": "mistral_converted_lab5_sft_processed.json",
|
| 769 |
+
"formatting": "sharegpt",
|
| 770 |
+
"columns": {
|
| 771 |
+
"messages": "conversations",
|
| 772 |
+
"system": "system"
|
| 773 |
+
},
|
| 774 |
+
"tags": {
|
| 775 |
+
"role_tag": "from",
|
| 776 |
+
"content_tag": "value",
|
| 777 |
+
"user_tag": "human",
|
| 778 |
+
"assistant_tag": "gpt",
|
| 779 |
+
"system_tag": "system"
|
| 780 |
+
}
|
| 781 |
+
},
|
| 782 |
+
"mistral_converted_lab5_dpo": {
|
| 783 |
+
"file_name": "mistral_converted_lab5.json",
|
| 784 |
+
"formatting": "sharegpt",
|
| 785 |
+
"ranking": true,
|
| 786 |
+
"columns": {
|
| 787 |
+
"messages": "conversations",
|
| 788 |
+
"chosen": "chosen",
|
| 789 |
+
"rejected": "rejected"
|
| 790 |
+
},
|
| 791 |
+
"tags": {
|
| 792 |
+
"role_tag": "from",
|
| 793 |
+
"content_tag": "value",
|
| 794 |
+
"user_tag": "human",
|
| 795 |
+
"assistant_tag": "gpt",
|
| 796 |
+
"system_tag": "system"
|
| 797 |
+
}
|
| 798 |
+
},
|
| 799 |
+
"mistral_reward_processed": {
|
| 800 |
+
"file_name": "mistral_reward_processed.json",
|
| 801 |
+
"formatting": "sharegpt",
|
| 802 |
+
"ranking": true,
|
| 803 |
+
"columns": {
|
| 804 |
+
"messages": "conversations",
|
| 805 |
+
"chosen": "chosen",
|
| 806 |
+
"rejected": "rejected"
|
| 807 |
+
},
|
| 808 |
+
"tags": {
|
| 809 |
+
"role_tag": "from",
|
| 810 |
+
"content_tag": "value",
|
| 811 |
+
"user_tag": "human",
|
| 812 |
+
"assistant_tag": "gpt",
|
| 813 |
+
"system_tag": "system"
|
| 814 |
+
}
|
| 815 |
+
},
|
| 816 |
+
"merged_rm_dpo": {
|
| 817 |
+
"file_name": "/home/LLaMA-Factory/data/merged_rm_dpo.json",
|
| 818 |
+
"formatting": "sharegpt",
|
| 819 |
+
"ranking": true,
|
| 820 |
+
"columns": {
|
| 821 |
+
"messages": "conversations",
|
| 822 |
+
"chosen": "chosen",
|
| 823 |
+
"rejected": "rejected"
|
| 824 |
+
},
|
| 825 |
+
"tags": {
|
| 826 |
+
"role_tag": "from",
|
| 827 |
+
"content_tag": "value",
|
| 828 |
+
"user_tag": "human",
|
| 829 |
+
"assistant_tag": "gpt",
|
| 830 |
+
"system_tag": "system"
|
| 831 |
+
}
|
| 832 |
+
},
|
| 833 |
+
"merged_nongram": {
|
| 834 |
+
"file_name": "/home/LLaMA-Factory/data/merged_nongram.json",
|
| 835 |
+
"formatting": "sharegpt",
|
| 836 |
+
"ranking": true,
|
| 837 |
+
"columns": {
|
| 838 |
+
"messages": "conversations",
|
| 839 |
+
"chosen": "chosen",
|
| 840 |
+
"rejected": "rejected"
|
| 841 |
+
},
|
| 842 |
+
"tags": {
|
| 843 |
+
"role_tag": "from",
|
| 844 |
+
"content_tag": "value",
|
| 845 |
+
"user_tag": "human",
|
| 846 |
+
"assistant_tag": "gpt",
|
| 847 |
+
"system_tag": "system"
|
| 848 |
+
}
|
| 849 |
+
},
|
| 850 |
+
"rm_merged": {
|
| 851 |
+
"file_name": "/home/LLaMA-Factory/data/merged_rm_dpo_score_filtered_shuffled.json",
|
| 852 |
+
"formatting": "sharegpt",
|
| 853 |
+
"ranking": true,
|
| 854 |
+
"columns": {
|
| 855 |
+
"messages": "conversations",
|
| 856 |
+
"chosen": "chosen",
|
| 857 |
+
"rejected": "rejected"
|
| 858 |
+
},
|
| 859 |
+
"tags": {
|
| 860 |
+
"role_tag": "from",
|
| 861 |
+
"content_tag": "value",
|
| 862 |
+
"user_tag": "human",
|
| 863 |
+
"assistant_tag": "gpt",
|
| 864 |
+
"system_tag": "system"
|
| 865 |
+
}
|
| 866 |
+
},
|
| 867 |
+
"group5": {
|
| 868 |
+
"file_name": "/home/LLaMA-Factory/data/9909_delta_29.609_73.375sharegpt.json",
|
| 869 |
+
"formatting": "sharegpt",
|
| 870 |
+
"ranking": true,
|
| 871 |
+
"columns": {
|
| 872 |
+
"messages": "conversations",
|
| 873 |
+
"chosen": "chosen",
|
| 874 |
+
"rejected": "rejected"
|
| 875 |
+
},
|
| 876 |
+
"tags": {
|
| 877 |
+
"role_tag": "from",
|
| 878 |
+
"content_tag": "value",
|
| 879 |
+
"user_tag": "human",
|
| 880 |
+
"assistant_tag": "gpt",
|
| 881 |
+
"system_tag": "system"
|
| 882 |
+
}
|
| 883 |
+
},
|
| 884 |
+
"rm_v2_dpo": {
|
| 885 |
+
"file_name": "/home/LLaMA-Factory/data/rm_v2_truncated_guarded_30safe.json",
|
| 886 |
+
"formatting": "sharegpt",
|
| 887 |
+
"ranking": true,
|
| 888 |
+
"columns": {
|
| 889 |
+
"messages": "conversations",
|
| 890 |
+
"chosen": "chosen",
|
| 891 |
+
"rejected": "rejected"
|
| 892 |
+
},
|
| 893 |
+
"tags": {
|
| 894 |
+
"role_tag": "from",
|
| 895 |
+
"content_tag": "value",
|
| 896 |
+
"user_tag": "human",
|
| 897 |
+
"assistant_tag": "gpt",
|
| 898 |
+
"system_tag": "system"
|
| 899 |
+
}
|
| 900 |
+
},
|
| 901 |
+
"replaced_sft": {
|
| 902 |
+
"file_name": "/home/LLaMA-Factory/data/rm_dpo_8_truncated_replaced_30safe_sft.json",
|
| 903 |
+
"formatting": "sharegpt",
|
| 904 |
+
"columns": {
|
| 905 |
+
"messages": "conversations",
|
| 906 |
+
"system": "system"
|
| 907 |
+
},
|
| 908 |
+
"tags": {
|
| 909 |
+
"role_tag": "from",
|
| 910 |
+
"content_tag": "value",
|
| 911 |
+
"user_tag": "human",
|
| 912 |
+
"assistant_tag": "gpt",
|
| 913 |
+
"system_tag": "system"
|
| 914 |
+
}
|
| 915 |
+
},
|
| 916 |
+
"replaced_dpo": {
|
| 917 |
+
"file_name": "/home/LLaMA-Factory/data/rm_dpo_8_truncated_replaced_30safe.json",
|
| 918 |
+
"formatting": "sharegpt",
|
| 919 |
+
"ranking": true,
|
| 920 |
+
"columns": {
|
| 921 |
+
"messages": "conversations",
|
| 922 |
+
"chosen": "chosen",
|
| 923 |
+
"rejected": "rejected"
|
| 924 |
+
},
|
| 925 |
+
"tags": {
|
| 926 |
+
"role_tag": "from",
|
| 927 |
+
"content_tag": "value",
|
| 928 |
+
"user_tag": "human",
|
| 929 |
+
"assistant_tag": "gpt",
|
| 930 |
+
"system_tag": "system"
|
| 931 |
+
}
|
| 932 |
+
},
|
| 933 |
+
"datasetv2_train0": {
|
| 934 |
+
"file_name": "/home/LLaMA-Factory/data/train0_train1_merged.json",
|
| 935 |
+
"formatting": "sharegpt",
|
| 936 |
+
"ranking": true,
|
| 937 |
+
"columns": {
|
| 938 |
+
"messages": "conversations",
|
| 939 |
+
"chosen": "chosen",
|
| 940 |
+
"rejected": "rejected"
|
| 941 |
+
},
|
| 942 |
+
"tags": {
|
| 943 |
+
"role_tag": "from",
|
| 944 |
+
"content_tag": "value",
|
| 945 |
+
"user_tag": "human",
|
| 946 |
+
"assistant_tag": "gpt",
|
| 947 |
+
"system_tag": "system"
|
| 948 |
+
}
|
| 949 |
+
}
|
| 950 |
+
}
|
data/delta_score_all_sharegpt_byclosure.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:19983e7720354bdc0337ceb42e7b4ce616557285c2a42340dbc1e120cb8bffd4
|
| 3 |
+
size 215555726
|
data/hh_rlhf_en/hh_rlhf_en.py
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2025 the LlamaFactory team.
|
| 2 |
+
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
|
| 16 |
+
import json
|
| 17 |
+
import os
|
| 18 |
+
|
| 19 |
+
import datasets
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
_HF_ENDPOINT = os.getenv("HF_ENDPOINT", "https://huggingface.co")
|
| 23 |
+
_DESCRIPTION = "Human preference data about helpfulness and harmlessness."
|
| 24 |
+
_CITATION = ""
|
| 25 |
+
_HOMEPAGE = f"{_HF_ENDPOINT}/datasets/Anthropic/hh-rlhf"
|
| 26 |
+
_LICENSE = "mit"
|
| 27 |
+
_URL = f"{_HF_ENDPOINT}/datasets/Anthropic/hh-rlhf/resolve/main/"
|
| 28 |
+
_URLS = {
|
| 29 |
+
"train": [
|
| 30 |
+
_URL + "harmless-base/train.jsonl.gz",
|
| 31 |
+
_URL + "helpful-base/train.jsonl.gz",
|
| 32 |
+
_URL + "helpful-online/train.jsonl.gz",
|
| 33 |
+
_URL + "helpful-rejection-sampled/train.jsonl.gz",
|
| 34 |
+
],
|
| 35 |
+
"test": [
|
| 36 |
+
_URL + "harmless-base/test.jsonl.gz",
|
| 37 |
+
_URL + "helpful-base/test.jsonl.gz",
|
| 38 |
+
_URL + "helpful-online/test.jsonl.gz",
|
| 39 |
+
_URL + "helpful-rejection-sampled/test.jsonl.gz",
|
| 40 |
+
],
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
class HhRlhfEn(datasets.GeneratorBasedBuilder):
|
| 45 |
+
VERSION = datasets.Version("0.0.0")
|
| 46 |
+
|
| 47 |
+
def _info(self) -> datasets.DatasetInfo:
|
| 48 |
+
features = datasets.Features(
|
| 49 |
+
{
|
| 50 |
+
"instruction": datasets.Value("string"),
|
| 51 |
+
"chosen": datasets.Value("string"),
|
| 52 |
+
"rejected": datasets.Value("string"),
|
| 53 |
+
"history": datasets.Sequence(datasets.Sequence(datasets.Value("string"))),
|
| 54 |
+
}
|
| 55 |
+
)
|
| 56 |
+
return datasets.DatasetInfo(
|
| 57 |
+
description=_DESCRIPTION, features=features, homepage=_HOMEPAGE, license=_LICENSE, citation=_CITATION
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
def _split_generators(self, dl_manager: datasets.DownloadManager):
|
| 61 |
+
file_path = dl_manager.download_and_extract(_URLS)
|
| 62 |
+
return [
|
| 63 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepaths": file_path["train"]}),
|
| 64 |
+
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepaths": file_path["test"]}),
|
| 65 |
+
]
|
| 66 |
+
|
| 67 |
+
def _generate_examples(self, filepaths: list[str]):
|
| 68 |
+
key = 0
|
| 69 |
+
for filepath in filepaths:
|
| 70 |
+
with open(filepath, encoding="utf-8") as f:
|
| 71 |
+
for row in f:
|
| 72 |
+
data = json.loads(row)
|
| 73 |
+
chosen = data["chosen"]
|
| 74 |
+
rejected = data["rejected"]
|
| 75 |
+
|
| 76 |
+
assist_idx = rejected.rfind("\n\nAssistant: ")
|
| 77 |
+
r_reject = rejected[assist_idx + 13 :].strip()
|
| 78 |
+
assist_idx = chosen.rfind("\n\nAssistant: ")
|
| 79 |
+
r_accept = chosen[assist_idx + 13 :].strip()
|
| 80 |
+
|
| 81 |
+
human_idx = chosen.rfind("\n\nHuman: ")
|
| 82 |
+
query = chosen[human_idx + 9 : assist_idx].strip()
|
| 83 |
+
prompt = chosen[:human_idx]
|
| 84 |
+
history = []
|
| 85 |
+
|
| 86 |
+
while prompt.rfind("\n\nAssistant: ") != -1:
|
| 87 |
+
assist_idx = prompt.rfind("\n\nAssistant: ")
|
| 88 |
+
human_idx = prompt.rfind("\n\nHuman: ")
|
| 89 |
+
if human_idx != -1:
|
| 90 |
+
old_query = prompt[human_idx + 9 : assist_idx].strip()
|
| 91 |
+
old_resp = prompt[assist_idx + 13 :].strip()
|
| 92 |
+
history.insert(0, (old_query, old_resp))
|
| 93 |
+
else:
|
| 94 |
+
break
|
| 95 |
+
prompt = prompt[:human_idx]
|
| 96 |
+
|
| 97 |
+
yield key, {"instruction": query, "chosen": r_accept, "rejected": r_reject, "history": history}
|
| 98 |
+
key += 1
|
data/merged_rm_dpo.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b8656f41ab9bc682d69e280889b8fe5dd56faaeaf1377c33d064f19dd9ab68e6
|
| 3 |
+
size 166736494
|
data/merged_rm_dpo_score_filtered.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f239b291153a061f35cefc061bc9ab841a5f36e69d4a0945dacfe95f4565df56
|
| 3 |
+
size 146112368
|
data/new_byranw_v1.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:903e3539ade836c171ab5f0c7facc20659009d219113ea0203c25493446e38c0
|
| 3 |
+
size 2324545019
|
data/new_byranw_v1_checked.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e8392252de32c0ae4a22e295f506989e62b64e658c5b601645cdb1ea1529c8c4
|
| 3 |
+
size 2353642071
|
data/new_new_byranw_v1.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4ee1b83fa867c7a38a26fd2e06415f7adc26ae53aea5f8b075d3632d2abd34e3
|
| 3 |
+
size 2350732826
|
data/rm_dpo_8_truncated_replaced_30safe.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:858d5dc8d63d01b3b3c378bbbabe95d10d7831878d6b791ea6c68f51734aa1b6
|
| 3 |
+
size 34598946
|
data/scripts_hsichen/batch_download.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from download import download_hf_dataset
|
| 2 |
+
|
| 3 |
+
repos = [
|
| 4 |
+
'chaiting/pk-2087-L4',
|
| 5 |
+
'chaiting/pk-2354-L5',
|
| 6 |
+
'chaiting/pk-2360-L4',
|
| 7 |
+
'chaiting/pk-2353-L4',
|
| 8 |
+
'chaiting/pk-3976-L5',
|
| 9 |
+
'chaiting/pk-1818-L4',
|
| 10 |
+
'chaiting/pk-2086-L3',
|
| 11 |
+
'chaiting/pk-2089-L6',
|
| 12 |
+
'chaiting/pk-1158-L5',
|
| 13 |
+
'chaiting/pk-1740-L4',
|
| 14 |
+
'chaiting/pk-1819-L5',
|
| 15 |
+
'chaiting/pk-1820-L6',
|
| 16 |
+
'chaiting/pk-867-L4',
|
| 17 |
+
'chaiting/pk-2352-L3',
|
| 18 |
+
'chaiting/pk-2352-L3',
|
| 19 |
+
'chaiting/pk-1817-L3',
|
| 20 |
+
'chaiting/pk-4089-L5',
|
| 21 |
+
'chaiting/pk-1741-L3'
|
| 22 |
+
]
|
| 23 |
+
|
| 24 |
+
for repo in repos:
|
| 25 |
+
basename = repo.split('/')[-1]
|
| 26 |
+
print(f'Downloading {repo}...')
|
| 27 |
+
download_hf_dataset(repo, f'/home/hsichen/LLaMA-Factory/data/chaiting/batch_data/{basename}')
|
| 28 |
+
print(f'Downloaded {repo} successfully.')
|
data/scripts_hsichen/data_filter/filter_by_quota.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import json
|
| 3 |
+
import re
|
| 4 |
+
from tqdm import tqdm
|
| 5 |
+
|
| 6 |
+
data = json.load(open("/home/LLaMA-Factory/data/merged_rm_dpo_scored.json"))
|
| 7 |
+
target_file_path = '/home/LLaMA-Factory/data/merged_rm_dpo_score_filtered.json'
|
| 8 |
+
output_data = []
|
| 9 |
+
for sample in tqdm(data,total=len(data)):
|
| 10 |
+
chosen_value = sample['chosen_quota_score']
|
| 11 |
+
rejected_value = sample['rejected_quota_score']
|
| 12 |
+
|
| 13 |
+
if chosen_value - rejected_value < 0 or chosen_value < 3 or rejected_value < 3:
|
| 14 |
+
continue
|
| 15 |
+
output_data.append(sample)
|
| 16 |
+
|
| 17 |
+
with open(target_file_path, 'w', encoding='utf-8') as f:
|
| 18 |
+
json.dump(output_data, f, indent=2)
|
| 19 |
+
print(f"Filtered data saved to {target_file_path}, total {len(output_data)} samples.")
|
| 20 |
+
|
data/scripts_hsichen/data_filter/filter_by_sim_score.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
from tqdm import tqdm
|
| 3 |
+
|
| 4 |
+
# 输入和输出文件路径
|
| 5 |
+
input_path = "/home/hsichen/LLaMA-Factory/data/chaiting/batch_data_merged_9w_scored.json"
|
| 6 |
+
output_path = "/home/hsichen/LLaMA-Factory/data/chaiting/batch_data_merged_filtered.json"
|
| 7 |
+
|
| 8 |
+
bert_threshold = 0.37
|
| 9 |
+
rouge_threshold = 0.25
|
| 10 |
+
|
| 11 |
+
# 加载原始数据
|
| 12 |
+
with open(input_path, "r", encoding="utf-8") as f:
|
| 13 |
+
data = json.load(f)
|
| 14 |
+
|
| 15 |
+
# 过滤逻辑
|
| 16 |
+
filtered_data = [
|
| 17 |
+
sample for sample in tqdm(data,total=len(data))
|
| 18 |
+
if sample.get("bert_score", 1.0) < bert_threshold and sample.get("rouge_l", 1.0) < rouge_threshold
|
| 19 |
+
]
|
| 20 |
+
|
| 21 |
+
# 保存过滤后的数据
|
| 22 |
+
with open(output_path, "w", encoding="utf-8") as f:
|
| 23 |
+
json.dump(filtered_data, f, indent=2, ensure_ascii=False)
|
| 24 |
+
|
| 25 |
+
print(f"已筛选样本数:{len(filtered_data)},保存至:{output_path}")
|
data/scripts_hsichen/data_filter/filter_nsfw_by_rule.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
|
| 3 |
+
path = '/home/hsichen/LLaMA-Factory/data/chaiting/pk_2087dpo_cop.json'
|
| 4 |
+
|
| 5 |
+
with open(path, 'r') as f:
|
| 6 |
+
data = json.load(f)
|
| 7 |
+
|
| 8 |
+
discard_id = []
|
| 9 |
+
|
| 10 |
+
for i, item in enumerate(data):
|
| 11 |
+
try:
|
| 12 |
+
if "I'm sorry" in item['chosen']:
|
| 13 |
+
discard_id.append(i)
|
| 14 |
+
continue
|
| 15 |
+
if "I'm sorry" in item['rejected']:
|
| 16 |
+
discard_id.append(i)
|
| 17 |
+
except Exception as e:
|
| 18 |
+
print(item)
|
| 19 |
+
discard_id.append(i)
|
| 20 |
+
|
| 21 |
+
remain_data = [item for i, item in enumerate(data) if i not in discard_id]
|
| 22 |
+
with open(path.replace('.json', '_filtered.json'), 'w') as f:
|
| 23 |
+
json.dump(remain_data, f, indent=4)
|
| 24 |
+
print(f"Filtered {len(discard_id)} items, remaining {len(remain_data)} items.")
|
data/scripts_hsichen/data_filter/parrellel_annotate.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
from tqdm import tqdm
|
| 4 |
+
from bert_score import BERTScorer
|
| 5 |
+
from rouge_score import rouge_scorer
|
| 6 |
+
|
| 7 |
+
# 路径
|
| 8 |
+
INPUT_PATH = "/home/hsichen/LLaMA-Factory/data/chaiting/batch_data_merged_9w.json"
|
| 9 |
+
OUTPUT_PATH = "/home/hsichen/LLaMA-Factory/data/chaiting/batch_data_merged_9w_scored.json"
|
| 10 |
+
|
| 11 |
+
# 加载数据
|
| 12 |
+
with open(INPUT_PATH, "r", encoding="utf-8") as f:
|
| 13 |
+
data = json.load(f)
|
| 14 |
+
|
| 15 |
+
# 初始化模型
|
| 16 |
+
print("Loading BERTScorer model (bert-base-uncased)...")
|
| 17 |
+
scorer = BERTScorer(
|
| 18 |
+
lang="en",
|
| 19 |
+
model_type="bert-base-uncased",
|
| 20 |
+
rescale_with_baseline=True,
|
| 21 |
+
batch_size=16
|
| 22 |
+
# verbose=False
|
| 23 |
+
)
|
| 24 |
+
rouge = rouge_scorer.RougeScorer(["rougeL"], use_stemmer=True)
|
| 25 |
+
|
| 26 |
+
# 构造 batch
|
| 27 |
+
chosen_list = []
|
| 28 |
+
rejected_list = []
|
| 29 |
+
indices = []
|
| 30 |
+
|
| 31 |
+
for idx, sample in enumerate(data):
|
| 32 |
+
try:
|
| 33 |
+
chosen = sample["chosen"]["value"]
|
| 34 |
+
rejected = sample["rejected"]["value"]
|
| 35 |
+
chosen_list.append(chosen)
|
| 36 |
+
rejected_list.append(rejected)
|
| 37 |
+
indices.append(idx)
|
| 38 |
+
except Exception as e:
|
| 39 |
+
print(f"Sample {idx} skipped due to error: {e}")
|
| 40 |
+
|
| 41 |
+
# 分批处理 BERTScore
|
| 42 |
+
print("Computing BERTScore and ROUGE-L...")
|
| 43 |
+
bert_scores = []
|
| 44 |
+
for start in tqdm(range(0, len(chosen_list), 64)):
|
| 45 |
+
end = start + 64
|
| 46 |
+
P, R, F1 = scorer.score(chosen_list[start:end], rejected_list[start:end])
|
| 47 |
+
for f1 in F1:
|
| 48 |
+
bert_scores.append(float(f1))
|
| 49 |
+
|
| 50 |
+
# 处理 ROUGE-L(逐条处理)
|
| 51 |
+
rouge_ls = []
|
| 52 |
+
for c, r in tqdm(zip(chosen_list, rejected_list), total=len(chosen_list)):
|
| 53 |
+
score = rouge.score(c, r)["rougeL"].fmeasure
|
| 54 |
+
rouge_ls.append(score)
|
| 55 |
+
|
| 56 |
+
# 合并回原数据
|
| 57 |
+
print("Merging results...")
|
| 58 |
+
for i, idx in enumerate(indices):
|
| 59 |
+
data[idx]["id"] = idx
|
| 60 |
+
data[idx]["bert_score"] = bert_scores[i]
|
| 61 |
+
data[idx]["rouge_l"] = rouge_ls[i]
|
| 62 |
+
|
| 63 |
+
# 保存
|
| 64 |
+
with open(OUTPUT_PATH, "w", encoding="utf-8") as f:
|
| 65 |
+
json.dump(data, f, indent=2, ensure_ascii=False)
|
| 66 |
+
|
| 67 |
+
print("All done.")
|
| 68 |
+
|