Skip to content

Commit

Permalink
update review
Browse files Browse the repository at this point in the history
  • Loading branch information
HanNayeoniee committed Apr 15, 2023
1 parent 39ae84f commit 1a563a4
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions docs/source/ko/custom_models.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ specific language governing permissions and limitations under the License.
모델의 `configuration`은 모델을 만들기 위해 필요한 모든 중요한 것들을 포함하고 있는 객체입니다.
다음 섹션에서 있듯이, 모델은 `config`를 사용해서만 초기화할 있기 때문에 완벽한 구성이 필요합니다.

아래 예시에서는 ResNet 클래스의 인자(argument)를 조정해보겠습니다.
아래 예시에서는 ResNet 클래스의 인수(argument)를 조정해보겠습니다.
다른 구성은 가능한 ResNet 다른 유형을 제공합니다.
그런 다음 가지 유효성을 확인한 해당 인자를 저장합니다.
그런 다음 가지 유효성을 확인한 해당 인수를 저장합니다.

```python
from transformers import PretrainedConfig
Expand Down Expand Up @@ -70,12 +70,12 @@ class ResnetConfig(PretrainedConfig):
```

사용자 정의 `configuration`을 작성할 기억해야 가지 중요한 사항은 다음과 같습니다:
- `PretrainedConfig`을 상속해야 합니다,
- `PretrainedConfig`을 상속해야 합니다.
- `PretrainedConfig`의 `__init__`은 모든 kwargs를 허용해야 하고,
- 이러한 `kwargs`는 상위 클래스 `__init__`에 전달되어야 합니다.

상속은 🤗 Transformers 라이브러리에서 모든 기능을 가져오는 것입니다.
이러한 점으로 부터 비롯되는 가지 제약 조건은 `PretrainedConfig`에 설정하는 것보다 많은 필드가 있습니다.
이러한 점으로부터 비롯되는 가지 제약 조건은 `PretrainedConfig`에 설정하는 것보다 많은 필드가 있습니다.
`from_pretrained` 메서드로 구성을 다시 로드할 해당 필드는 구성에서 수락한 상위 클래스로 보내야 합니다.

모델을 auto 클래스에 등록하지 않는 한, `configuration`에서 `model_type`을 정의(여기서 `model_type="resnet"`)하는 것은 필수 사항이 아닙니다 (마지막 섹션 참조).
Expand Down Expand Up @@ -103,7 +103,7 @@ resnet50d_config = ResnetConfig.from_pretrained("custom-resnet")
이제 ResNet 구성이 있으므로 모델을 작성할 있습니다.
실제로는 개를 작성할 것입니다. 하나는 이미지 배치에서 hidden features를 추출하는 것([`BertModel`]과 같이), 다른 하나는 이미지 분류에 적합한 것입니다([`BertForSequenceClassification`]과 같이).

이전에 언급했듯이 예제에서는 단순하게 하기 위해 모델의 느슨한 래퍼만 작성할 것입니다.
이전에 언급했듯이 예제에서는 단순하게 하기 위해 모델의 느슨한 래퍼(loose wrapper)만 작성할 것입니다.
클래스를 작성하기 전에 블록 유형과 실제 블록 클래스 간의 매핑 작업만 하면 됩니다.
그런 다음 `ResNet` 클래스로 전달되어 `configuration`을 통해 모델이 선언됩니다:

Expand Down Expand Up @@ -189,7 +189,7 @@ class ResnetModelForImageClassification(PreTrainedModel):
resnet50d = ResnetModelForImageClassification(resnet50d_config)
```

다시 말하지만, [`~PreTrainedModel.save_pretrained`] 또는 [`~PreTrainedModel.push_to_hub`] 처럼 [`PreTrainedModel`] 속하는 메소드 모두 사용할 있습니다.
다시 말하지만, [`~PreTrainedModel.save_pretrained`]또는 [`~PreTrainedModel.push_to_hub`]처럼 [`PreTrainedModel`] 속하는 모든 메소드를 사용할 있습니다.
다음 섹션에서 번째 메소드를 사용해 모델 코드와 모델 가중치를 업로드하는 방법을 살펴보겠습니다.
먼저, 모델 내부에 사전 훈련된 가중치를 로드해 보겠습니다.

Expand Down Expand Up @@ -237,7 +237,7 @@ Python이 `resnet_model`을 모듈로 사용할 수 있도록 감지하는 목

</Tip>

기존 구성이나 모델을 재사용할(또는 subclass) 수 있습니다.
기존 구성이나 모델을 재사용(또는 서브 클래스화)할 수 있습니다.

커뮤니티에 모델을 공유하기 위해서는 다음 단계를 따라야 합니다:
먼저, 새로 만든 파일에 ResNet 모델과 구성을 임포트합니다:
Expand Down Expand Up @@ -269,7 +269,6 @@ pretrained_model = timm.create_model("resnet50d", pretrained=True)
resnet50d.model.load_state_dict(pretrained_model.state_dict())
```

Now to send the model to the Hub, make sure you are logged in. Either run in your terminal:
이제 모델을 Hub로 업로드하기 위해 로그인 상태인지 확인하세요.
터미널에서 다음 코드를 실행해 확인할 수 있습니다:

Expand All @@ -285,7 +284,7 @@ from huggingface_hub import notebook_login
notebook_login()
```

그런 다음 다음과 같이 자신의 네임스페이스(또는 자신이 속한 조직)에 업로드할 수 있습니다:
그런 다음 이렇게 자신의 네임스페이스(또는 자신이 속한 조직)에 업로드할 수 있습니다:
```py
resnet50d.push_to_hub("custom-resnet50d")
```
Expand Down Expand Up @@ -339,8 +338,5 @@ AutoModel.register(ResnetConfig, ResnetModel)
AutoModelForImageClassification.register(ResnetConfig, ResnetModelForImageClassification)
```

Note that the first argument used when registering your custom config to [`AutoConfig`] needs to match the `model_type`
of your custom config, and the first argument used when registering your custom models to any auto model class needs
to match the `config_class` of those models.
사용자 정의 구성을 [`AutoConfig`]에 등록할 때 사용되는 첫 번째 인수는 사용자 정의 구성의 `model_type`과 일치해야 합니다.
또한, 사용자 정의 모델을 auto 클래스에 등록할 때 사용되는 첫 번째 인수는 해당 모델의 `config_class`와 일치해야 합니다.

0 comments on commit 1a563a4

Please sign in to comment.