-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'training-encodec' of github.com:jonflynng/transformers …
…into training-encodec
- Loading branch information
Showing
194 changed files
with
13,616 additions
and
6,008 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
name: Process failed tests | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
docker: | ||
required: true | ||
type: string | ||
start_sha: | ||
required: true | ||
type: string | ||
|
||
|
||
env: | ||
HF_HOME: /mnt/cache | ||
TRANSFORMERS_IS_CI: yes | ||
OMP_NUM_THREADS: 8 | ||
MKL_NUM_THREADS: 8 | ||
RUN_SLOW: yes | ||
# For gated repositories, we still need to agree to share information on the Hub repo. page in order to get access. | ||
# This token is created under the bot `hf-transformers-bot`. | ||
HF_HUB_READ_TOKEN: ${{ secrets.HF_HUB_READ_TOKEN }} | ||
SIGOPT_API_TOKEN: ${{ secrets.SIGOPT_API_TOKEN }} | ||
TF_FORCE_GPU_ALLOW_GROWTH: true | ||
RUN_PT_TF_CROSS_TESTS: 1 | ||
CUDA_VISIBLE_DEVICES: 0,1 | ||
|
||
|
||
jobs: | ||
run_models_gpu: | ||
name: " " | ||
runs-on: | ||
group: aws-g4dn-2xlarge-cache | ||
container: | ||
image: ${{ inputs.docker }} | ||
options: --gpus all --shm-size "16gb" --ipc host -v /mnt/cache/.cache/huggingface:/mnt/cache/ | ||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: ci_results_run_models_gpu | ||
path: /transformers/ci_results_run_models_gpu | ||
|
||
- name: Update clone | ||
working-directory: /transformers | ||
run: git fetch && git checkout ${{ github.sha }} | ||
|
||
- name: Get target commit | ||
working-directory: /transformers/utils | ||
run: | | ||
echo "END_SHA=$(TOKEN=${{ secrets.ACCESS_REPO_INFO_TOKEN }} python3 -c 'import os; from get_previous_daily_ci import get_last_daily_ci_run_commit; commit=get_last_daily_ci_run_commit(token=os.environ["TOKEN"]); print(commit)')" >> $GITHUB_ENV | ||
- name: Checkout to `start_sha` | ||
working-directory: /transformers | ||
run: git fetch && git checkout ${{ inputs.start_sha }} | ||
|
||
- name: Reinstall transformers in edit mode (remove the one installed during docker image build) | ||
working-directory: /transformers | ||
run: python3 -m pip uninstall -y transformers && python3 -m pip install -e . | ||
|
||
- name: NVIDIA-SMI | ||
run: | | ||
nvidia-smi | ||
- name: Environment | ||
working-directory: /transformers | ||
run: | | ||
python3 utils/print_env.py | ||
- name: Show installed libraries and their versions | ||
working-directory: /transformers | ||
run: pip freeze | ||
|
||
- name: Check failed tests | ||
working-directory: /transformers | ||
run: python3 utils/check_bad_commit.py --start_commit ${{ inputs.start_sha }} --end_commit ${{ env.END_SHA }} --file ci_results_run_models_gpu/new_model_failures.json --output_file new_model_failures_with_bad_commit.json | ||
|
||
- name: Show results | ||
working-directory: /transformers | ||
run: | | ||
ls -l new_model_failures_with_bad_commit.json | ||
cat new_model_failures_with_bad_commit.json | ||
- name: Checkout back | ||
working-directory: /transformers | ||
run: | | ||
git checkout ${{ inputs.start_sha }} | ||
- name: Process report | ||
shell: bash | ||
working-directory: /transformers | ||
env: | ||
TRANSFORMERS_CI_RESULTS_UPLOAD_TOKEN: ${{ secrets.TRANSFORMERS_CI_RESULTS_UPLOAD_TOKEN }} | ||
run: | | ||
python3 utils/process_bad_commit_report.py | ||
- name: Process report | ||
shell: bash | ||
working-directory: /transformers | ||
env: | ||
TRANSFORMERS_CI_RESULTS_UPLOAD_TOKEN: ${{ secrets.TRANSFORMERS_CI_RESULTS_UPLOAD_TOKEN }} | ||
run: | | ||
{ | ||
echo 'REPORT_TEXT<<EOF' | ||
python3 utils/process_bad_commit_report.py | ||
echo EOF | ||
} >> "$GITHUB_ENV" | ||
- name: Send processed report | ||
if: ${{ env.REPORT_TEXT != '' }} | ||
uses: slackapi/slack-github-action@6c661ce58804a1a20f6dc5fbee7f0381b469e001 | ||
with: | ||
# Slack channel id, channel name, or user id to post message. | ||
# See also: https://api.slack.com/methods/chat.postMessage#channels | ||
channel-id: '#transformers-ci-feedback-tests' | ||
# For posting a rich message using Block Kit | ||
payload: | | ||
{ | ||
"blocks": [ | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "${{ env.REPORT_TEXT }}" | ||
} | ||
} | ||
] | ||
} | ||
env: | ||
SLACK_BOT_TOKEN: ${{ secrets.SLACK_CIFEEDBACK_BOT_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Dockers for `transformers` | ||
|
||
In this folder you will find various docker files, and some subfolders. | ||
- dockerfiles (ex: `consistency.dockerfile`) present under `~/docker` are used for our "fast" CIs. You should be able to use them for tasks that only need CPU. For example `torch-light` is a very light weights container (703MiB). | ||
- subfloder contain dockerfiles used for our `slow` CIs, which *can* be used for GPU tasks, but they are **BIG** as they were not specifically designed for a single model / single task. Thus the `~/docker/transformers-pytorch-gpu` includes additional dependencies to allow us to run ALL model tests (say `librosa` or `tesseract`, which you do not need to run LLMs) | ||
|
||
Note that in both case, you need to run `uv pip install -e .`, which should take around 5 seconds. We do it outside the dockerfile for the need of our CI: we checkout a new branch each time, and the `transformers` code is thus updated. | ||
|
||
We are open to contribution, and invite the community to create dockerfiles with potential arguments that properly choose extras depending on the model's dependencies! :hugs: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<!--Copyright 2024 The GLM & ZhipuAI team and The HuggingFace Team. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations under the License. | ||
⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be | ||
rendered properly in your Markdown viewer. | ||
--> | ||
|
||
# GLM | ||
|
||
## Overview | ||
|
||
The GLM Model was proposed | ||
in [ChatGLM: A Family of Large Language Models from GLM-130B to GLM-4 All Tools](https://arxiv.org/html/2406.12793v1) | ||
by GLM Team, THUDM & ZhipuAI. | ||
|
||
The abstract from the paper is the following: | ||
|
||
*We introduce ChatGLM, an evolving family of large language models that we have been developing over time. This report | ||
primarily focuses on the GLM-4 language series, which includes GLM-4, GLM-4-Air, and GLM-4-9B. They represent our most | ||
capable models that are trained with all the insights and lessons gained from the preceding three generations of | ||
ChatGLM. To date, the GLM-4 models are pre-trained on ten trillions of tokens mostly in Chinese and English, along with | ||
a small set of corpus from 24 languages, and aligned primarily for Chinese and English usage. The high-quality alignment | ||
is achieved via a multi-stage post-training process, which involves supervised fine-tuning and learning from human | ||
feedback. Evaluations show that GLM-4 1) closely rivals or outperforms GPT-4 in terms of general metrics such as MMLU, | ||
GSM8K, MATH, BBH, GPQA, and HumanEval, 2) gets close to GPT-4-Turbo in instruction following as measured by IFEval, 3) | ||
matches GPT-4 Turbo (128K) and Claude 3 for long context tasks, and 4) outperforms GPT-4 in Chinese alignments as | ||
measured by AlignBench. The GLM-4 All Tools model is further aligned to understand user intent and autonomously decide | ||
when and which tool(s) to use—including web browser, Python interpreter, text-to-image model, and user-defined | ||
functions—to effectively complete complex tasks. In practical applications, it matches and even surpasses GPT-4 All | ||
Tools in tasks like accessing online information via web browsing and solving math problems using Python interpreter. | ||
Over the course, we have open-sourced a series of models, including ChatGLM-6B (three generations), GLM-4-9B (128K, 1M), | ||
GLM-4V-9B, WebGLM, and CodeGeeX, attracting over 10 million downloads on Hugging face in the year 2023 alone.* | ||
|
||
Tips: | ||
|
||
- This model was contributed by [THUDM](https://huggingface.co/THUDM). The most recent code can be | ||
found [here](https://github.com/thudm/GLM-4). | ||
|
||
|
||
## Usage tips | ||
|
||
`GLM-4` can be found on the [Huggingface Hub](https://huggingface.co/collections/THUDM/glm-4-665fcf188c414b03c2f7e3b7) | ||
|
||
In the following, we demonstrate how to use `glm-4-9b-chat` for the inference. Note that we have used the ChatML format for dialog, in this demo we show how to leverage `apply_chat_template` for this purpose. | ||
|
||
```python | ||
>>> from transformers import AutoModelForCausalLM, AutoTokenizer | ||
>>> device = "cuda" # the device to load the model onto | ||
|
||
>>> model = AutoModelForCausalLM.from_pretrained("THUDM/glm-4-9b-chat", device_map="auto") | ||
>>> tokenizer = AutoTokenizer.from_pretrained("THUDM/glm-4-9b-chat") | ||
|
||
>>> prompt = "Give me a short introduction to large language model." | ||
|
||
>>> messages = [{"role": "user", "content": prompt}] | ||
|
||
>>> text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True) | ||
|
||
>>> model_inputs = tokenizer([text], return_tensors="pt").to(device) | ||
|
||
>>> generated_ids = model.generate(model_inputs.input_ids, max_new_tokens=512, do_sample=True) | ||
|
||
>>> generated_ids = [output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)] | ||
|
||
>>> response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0] | ||
``` | ||
|
||
## GlmConfig | ||
|
||
[[autodoc]] GlmConfig | ||
|
||
## GlmModel | ||
|
||
[[autodoc]] GlmModel | ||
- forward | ||
|
||
## GlmForCausalLM | ||
|
||
[[autodoc]] GlmForCausalLM | ||
- forward | ||
|
||
## GlmForSequenceClassification | ||
|
||
[[autodoc]] GlmForSequenceClassification | ||
- forward | ||
|
||
## GlmForTokenClassification | ||
|
||
[[autodoc]] GlmForTokenClassification | ||
- forward |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.