File size: 2,853 Bytes
17c6d62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!--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.

-->

# Trainer [[trainer]]

[`Trainer`] ν΄λž˜μŠ€λŠ” PyTorchμ—μ„œ μ™„μ „ν•œ κΈ°λŠ₯(feature-complete)의 ν›ˆλ ¨μ„ μœ„ν•œ APIλ₯Ό μ œκ³΅ν•˜λ©°, 닀쀑 GPU/TPUμ—μ„œμ˜ λΆ„μ‚° ν›ˆλ ¨, [NVIDIA GPU](https://nvidia.github.io/apex/), [AMD GPU](https://rocm.docs.amd.com/en/latest/rocm.html)λ₯Ό μœ„ν•œ ν˜Όν•© 정밀도, 그리고 PyTorch의 [`torch.amp`](https://pytorch.org/docs/stable/amp.html)λ₯Ό μ§€μ›ν•©λ‹ˆλ‹€. [`Trainer`]λŠ” λͺ¨λΈμ˜ ν›ˆλ ¨ 방식을 μ»€μŠ€ν„°λ§ˆμ΄μ¦ˆν•  수 μžˆλŠ” λ‹€μ–‘ν•œ μ˜΅μ…˜μ„ μ œκ³΅ν•˜λŠ” [`TrainingArguments`] ν΄λž˜μŠ€μ™€ ν•¨κ»˜ μ‚¬μš©λ©λ‹ˆλ‹€. 이 두 ν΄λž˜μŠ€λŠ” ν•¨κ»˜ μ™„μ „ν•œ ν›ˆλ ¨ APIλ₯Ό μ œκ³΅ν•©λ‹ˆλ‹€.

[`Seq2SeqTrainer`]와 [`Seq2SeqTrainingArguments`]λŠ” [`Trainer`]와 [`TrainingArguments`] 클래슀λ₯Ό μƒμ†ν•˜λ©°, μš”μ•½μ΄λ‚˜ λ²ˆμ—­κ³Ό 같은 μ‹œν€€μŠ€-투-μ‹œν€€μŠ€ μž‘μ—…μ„ μœ„ν•œ λͺ¨λΈ ν›ˆλ ¨μ— μ ν•©ν•˜κ²Œ μ‘°μ •λ˜μ–΄ μžˆμŠ΅λ‹ˆλ‹€.

<Tip warning={true}>

[`Trainer`] ν΄λž˜μŠ€λŠ” πŸ€— Transformers λͺ¨λΈμ— μ΅œμ ν™”λ˜μ–΄ 있으며, λ‹€λ₯Έ λͺ¨λΈκ³Ό ν•¨κ»˜ μ‚¬μš©λ  λ•Œ μ˜ˆμƒμΉ˜ λͺ»ν•œ λ™μž‘μ„ ν•˜κ²Œ 될 수 μžˆμŠ΅λ‹ˆλ‹€. μžμ‹ λ§Œμ˜ λͺ¨λΈμ„ μ‚¬μš©ν•  λ•ŒλŠ” λ‹€μŒμ„ ν™•μΈν•˜μ„Έμš”:

- λͺ¨λΈμ€ 항상 νŠœν”Œμ΄λ‚˜ [`~utils.ModelOutput`]의 μ„œλΈŒν΄λž˜μŠ€λ₯Ό λ°˜ν™˜ν•΄μ•Ό ν•©λ‹ˆλ‹€.
- λͺ¨λΈμ€ `labels` μΈμžκ°€ 제곡되면 손싀을 계산할 수 있고, λͺ¨λΈμ΄ νŠœν”Œμ„ λ°˜ν™˜ν•˜λŠ” 경우 κ·Έ 손싀이 νŠœν”Œμ˜ 첫 번째 μš”μ†Œλ‘œ λ°˜ν™˜λ˜μ–΄μ•Ό ν•©λ‹ˆλ‹€.
- λͺ¨λΈμ€ μ—¬λŸ¬ 개의 λ ˆμ΄λΈ” 인자λ₯Ό μˆ˜μš©ν•  수 μžˆμ–΄μ•Ό ν•˜λ©°, [`Trainer`]μ—κ²Œ 이름을 μ•Œλ¦¬κΈ° μœ„ν•΄ [`TrainingArguments`]μ—μ„œ `label_names`λ₯Ό μ‚¬μš©ν•˜μ§€λ§Œ, κ·Έ 쀑 μ–΄λŠ 것도 `"label"`둜 λͺ…λͺ…λ˜μ–΄μ„œλŠ” μ•ˆ λ©λ‹ˆλ‹€.

</Tip>

## Trainer [[transformers.Trainer]]

[[autodoc]] Trainer
    - all

## Seq2SeqTrainer [[transformers.Seq2SeqTrainer]]

[[autodoc]] Seq2SeqTrainer
    - evaluate
    - predict

## TrainingArguments [[transformers.TrainingArguments]]

[[autodoc]] TrainingArguments
    - all

## Seq2SeqTrainingArguments [[transformers.Seq2SeqTrainingArguments]]

[[autodoc]] Seq2SeqTrainingArguments
    - all