Instructions to use AbdulElahGwaith/transformers with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AbdulElahGwaith/transformers with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("AbdulElahGwaith/transformers", device_map="auto") - Notebooks
- Google Colab
- Kaggle
|
Download docs/source/ko/main_classes/callback.md from AbdulElahGwaith/transformers: direct link, hf CLI and curl.
- Browser
- Download file 5.87 kB
-
https://huggingface.co/AbdulElahGwaith/transformers/resolve/main/docs/source/ko/main_classes/callback.md
- Command line
-
hf download hf://AbdulElahGwaith/transformers/docs/source/ko/main_classes/callback.md
-
curl -L -o callback.md https://huggingface.co/AbdulElahGwaith/transformers/resolve/main/docs/source/ko/main_classes/callback.md
5.87 kB
| <!--Copyright 2020 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. | |
| --> | |
| # ์ฝ๋ฐฑ [[callbacks]] | |
| ์ฝ๋ฐฑ์ PyTorch [`Trainer`]์ ๋ฐ๋ณต ํ์ต ๋์์ ์ฌ์ฉ์ ์ ์ํ ์ ์๋ ๊ฐ์ฒด์ ๋๋ค | |
| (์ด ๊ธฐ๋ฅ์ TensorFlow์์๋ ์์ง ๊ตฌํ๋์ง ์์์ต๋๋ค). ์ฝ๋ฐฑ์ ๋ฐ๋ณต ํ์ต์ ์ํ๋ฅผ | |
| ๊ฒ์ฌํ์ฌ (์งํ ์ํฉ ๋ณด๊ณ , TensorBoard ๋๋ ๊ธฐํ ๋จธ์ ๋ฌ๋ ํ๋ซํผ์ ๋ก๊ทธ ๋จ๊ธฐ๊ธฐ ๋ฑ) | |
| ๊ฒฐ์ (์: ์กฐ๊ธฐ ์ข ๋ฃ)์ ๋ด๋ฆด ์ ์์ต๋๋ค. | |
| ์ฝ๋ฐฑ์ [`TrainerControl`] ๊ฐ์ฒด๋ฅผ ๋ฐํํ๋ ๊ฒ ์ธ์๋ ๋ฐ๋ณต ํ์ต์์ ์ด๋ค ๊ฒ๋ ๋ณ๊ฒฝํ ์ ์๋ | |
| "์ฝ๊ธฐ ์ ์ฉ" ์ฝ๋ ์กฐ๊ฐ์ ๋๋ค. ๋ฐ๋ณต ํ์ต์ ๋ณ๊ฒฝ์ด ํ์ํ ์ฌ์ฉ์ ์ ์ ์์ ์ด ํ์ํ ๊ฒฝ์ฐ, | |
| [`Trainer`]๋ฅผ ์๋ธํด๋์ค๋ก ๋ง๋ค์ด ํ์ํ ๋ฉ์๋๋ค์ ์ค๋ฒ๋ผ์ด๋ํด์ผ ํฉ๋๋ค (์์๋ [trainer](trainer)๋ฅผ ์ฐธ์กฐํ์ธ์). | |
| ๊ธฐ๋ณธ์ ์ผ๋ก `TrainingArguments.report_to`๋ `"all"`๋ก ์ค์ ๋์ด ์์ผ๋ฏ๋ก, [`Trainer`]๋ ๋ค์ ์ฝ๋ฐฑ์ ์ฌ์ฉํฉ๋๋ค. | |
| - [`DefaultFlowCallback`]๋ ๋ก๊ทธ, ์ ์ฅ, ํ๊ฐ์ ๋ํ ๊ธฐ๋ณธ ๋์์ ์ฒ๋ฆฌํฉ๋๋ค. | |
| - [`PrinterCallback`] ๋๋ [`ProgressCallback`]๋ ์งํ ์ํฉ์ ํ์ํ๊ณ ๋ก๊ทธ๋ฅผ ์ถ๋ ฅํฉ๋๋ค | |
| ([`TrainingArguments`]๋ฅผ ํตํด tqdm์ ๋นํ์ฑํํ๋ฉด ์ฒซ ๋ฒ์งธ ์ฝ๋ฐฑ์ด ์ฌ์ฉ๋๊ณ , ๊ทธ๋ ์ง ์์ผ๋ฉด ๋ ๋ฒ์งธ๊ฐ ์ฌ์ฉ๋ฉ๋๋ค). | |
| - [`~integrations.TensorBoardCallback`]๋ TensorBoard๊ฐ (PyTorch >= 1.4 | |
| ๋๋ tensorboardX๋ฅผ ํตํด) ์ ๊ทผ ๊ฐ๋ฅํ๋ฉด ์ฌ์ฉ๋ฉ๋๋ค. | |
| - [`~integrations.WandbCallback`]๋ [wandb](https://www.wandb.com/)๊ฐ ์ค์น๋์ด ์์ผ๋ฉด | |
| ์ฌ์ฉ๋ฉ๋๋ค. | |
| - [`~integrations.CometCallback`]๋ [comet_ml](https://www.comet.com/site/)์ด ์ค์น๋์ด ์์ผ๋ฉด ์ฌ์ฉ๋ฉ๋๋ค. | |
| - [`~integrations.MLflowCallback`]๋ [mlflow](https://www.mlflow.org/)๊ฐ ์ค์น๋์ด ์์ผ๋ฉด ์ฌ์ฉ๋ฉ๋๋ค. | |
| - [`~integrations.AzureMLCallback`]๋ [azureml-sdk](https://pypi.org/project/azureml-sdk/)๊ฐ ์ค์น๋์ด | |
| ์์ผ๋ฉด ์ฌ์ฉ๋ฉ๋๋ค. | |
| - [`~integrations.CodeCarbonCallback`]๋ [codecarbon](https://pypi.org/project/codecarbon/)์ด ์ค์น๋์ด | |
| ์์ผ๋ฉด ์ฌ์ฉ๋ฉ๋๋ค. | |
| - [`~integrations.ClearMLCallback`]๋ [clearml](https://github.com/allegroai/clearml)์ด ์ค์น๋์ด ์์ผ๋ฉด ์ฌ์ฉ๋ฉ๋๋ค. | |
| - [`~integrations.DagsHubCallback`]๋ [dagshub](https://dagshub.com/)์ด ์ค์น๋์ด ์์ผ๋ฉด ์ฌ์ฉ๋ฉ๋๋ค. | |
| - [`~integrations.FlyteCallback`]๋ [flyte](https://flyte.org/)๊ฐ ์ค์น๋์ด ์์ผ๋ฉด ์ฌ์ฉ๋ฉ๋๋ค. | |
| - [`~integrations.DVCLiveCallback`]๋ [dvclive](https://dvc.org/doc/dvclive)๊ฐ ์ค์น๋์ด ์์ผ๋ฉด ์ฌ์ฉ๋ฉ๋๋ค. | |
| - [`~integrations.SwanLabCallback`]๋ [swanlab](https://swanlab.cn)๊ฐ ์ค์น๋์ด ์์ผ๋ฉด ์ฌ์ฉ๋ฉ๋๋ค. | |
| ํจํค์ง๊ฐ ์ค์น๋์ด ์์ง๋ง ํด๋น ํตํฉ ๊ธฐ๋ฅ์ ์ฌ์ฉํ๊ณ ์ถ์ง ์๋ค๋ฉด, `TrainingArguments.report_to`๋ฅผ ์ฌ์ฉํ๊ณ ์ ํ๋ ํตํฉ ๊ธฐ๋ฅ ๋ชฉ๋ก์ผ๋ก ๋ณ๊ฒฝํ ์ ์์ต๋๋ค (์: `["azure_ml", "wandb"]`). | |
| ์ฝ๋ฐฑ์ ๊ตฌํํ๋ ์ฃผ์ ํด๋์ค๋ [`TrainerCallback`]์ ๋๋ค. ์ด ํด๋์ค๋ [`Trainer`]๋ฅผ | |
| ์ธ์คํด์คํํ๋ ๋ฐ ์ฌ์ฉ๋ [`TrainingArguments`]๋ฅผ ๊ฐ์ ธ์ค๊ณ , ํด๋น Trainer์ ๋ด๋ถ ์ํ๋ฅผ | |
| [`TrainerState`]๋ฅผ ํตํด ์ ๊ทผํ ์ ์์ผ๋ฉฐ, [`TrainerControl`]์ ํตํด ๋ฐ๋ณต ํ์ต์์ ์ผ๋ถ | |
| ์์ ์ ์ํํ ์ ์์ต๋๋ค. | |
| ## ์ฌ์ฉ ๊ฐ๋ฅํ ์ฝ๋ฐฑ [[available-callbacks]] | |
| ๋ผ์ด๋ธ๋ฌ๋ฆฌ์์ ์ฌ์ฉ ๊ฐ๋ฅํ [`TrainerCallback`] ๋ชฉ๋ก์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค: | |
| [[autodoc]] integrations.CometCallback | |
| - setup | |
| [[autodoc]] DefaultFlowCallback | |
| [[autodoc]] PrinterCallback | |
| [[autodoc]] ProgressCallback | |
| [[autodoc]] EarlyStoppingCallback | |
| [[autodoc]] integrations.TensorBoardCallback | |
| [[autodoc]] integrations.WandbCallback | |
| - setup | |
| [[autodoc]] integrations.MLflowCallback | |
| - setup | |
| [[autodoc]] integrations.AzureMLCallback | |
| [[autodoc]] integrations.CodeCarbonCallback | |
| [[autodoc]] integrations.ClearMLCallback | |
| [[autodoc]] integrations.DagsHubCallback | |
| [[autodoc]] integrations.FlyteCallback | |
| [[autodoc]] integrations.DVCLiveCallback | |
| - setup | |
| [[autodoc]] integrations.SwanLabCallback | |
| - setup | |
| ## TrainerCallback [[trainercallback]] | |
| [[autodoc]] TrainerCallback | |
| ์ฌ๊ธฐ PyTorch [`Trainer`]์ ํจ๊ป ์ฌ์ฉ์ ์ ์ ์ฝ๋ฐฑ์ ๋ฑ๋กํ๋ ์์๊ฐ ์์ต๋๋ค: | |
| ```python | |
| class MyCallback(TrainerCallback): | |
| "A callback that prints a message at the beginning of training" | |
| def on_train_begin(self, args, state, control, **kwargs): | |
| print("Starting training") | |
| trainer = Trainer( | |
| model, | |
| args, | |
| train_dataset=train_dataset, | |
| eval_dataset=eval_dataset, | |
| callbacks=[MyCallback], # ์ฐ๋ฆฌ๋ ์ฝ๋ฐฑ ํด๋์ค๋ฅผ ์ด ๋ฐฉ์์ผ๋ก ์ ๋ฌํ๊ฑฐ๋ ๊ทธ๊ฒ์ ์ธ์คํด์ค(MyCallback())๋ฅผ ์ ๋ฌํ ์ ์์ต๋๋ค | |
| ) | |
| ``` | |
| ๋ ๋ค๋ฅธ ์ฝ๋ฐฑ์ ๋ฑ๋กํ๋ ๋ฐฉ๋ฒ์ `trainer.add_callback()`์ ํธ์ถํ๋ ๊ฒ์ ๋๋ค: | |
| ```python | |
| trainer = Trainer(...) | |
| trainer.add_callback(MyCallback) | |
| # ๋ค๋ฅธ ๋ฐฉ๋ฒ์ผ๋ก๋ ์ฝ๋ฐฑ ํด๋์ค์ ์ธ์คํด์ค๋ฅผ ์ ๋ฌํ ์ ์์ต๋๋ค | |
| trainer.add_callback(MyCallback()) | |
| ``` | |
| ## TrainerState [[trainerstate]] | |
| [[autodoc]] TrainerState | |
| ## TrainerControl [[trainercontrol]] | |
| [[autodoc]] TrainerControl | |