Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌐 [i18n-KO] Translated fast_tokenizers.mdx to Korean #22956

Merged
merged 14 commits into from
May 30, 2023
4 changes: 2 additions & 2 deletions docs/source/ko/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
title: (번역중) Troubleshoot
title: (번역중) 일반적인 사용방법
- sections:
- local: in_translation
title: (번역중) Use tokenizers from 🤗 Tokenizers
- local: fast_tokenizers
title: 🤗 Tokenizers 라이브러리에서 토크나이저 사용하기
- local: in_translation
title: (번역중) Inference for multilingual models
- local: in_translation
Expand Down
67 changes: 67 additions & 0 deletions docs/source/ko/fast_tokenizers.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<!--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.
-->

# 🤗 Tokenizers 라이브러리의 토크나이저 사용하기
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제목에 영어문서와 동일한 anchor를 [[ ]] 부호 사이에 넣어야 우측의 TOC가 동작합니다.
대부분 영어 제목과 동일한 소문자인데 공백을 - 로 표현하는 형태입니다. :-)
다른 분들 문서를 보시면 이해되실꺼예요.


[PreTrainedTokenizerFast]는 🤗 Tokenizers 라이브러리에 기반합니다. 🤗 Tokenizers 라이브러리의 토크나이저는
kihoon71 marked this conversation as resolved.
Show resolved Hide resolved
🤗 Transformers로 매우 간단하게 불러올 수 있습니다.

구체적인 내용에 들어가기 전에, 몇 줄의 코드로 더미 토크나이저를 만들어 보겠습니다:

```python
>>> from tokenizers import Tokenizer
>>> from tokenizers.models import BPE
>>> from tokenizers.trainers import BpeTrainer
>>> from tokenizers.pre_tokenizers import Whitespace

>>> tokenizer = Tokenizer(BPE(unk_token="[UNK]"))
>>> trainer = BpeTrainer(special_tokens=["[UNK]", "[CLS]", "[SEP]", "[PAD]", "[MASK]"])

>>> tokenizer.pre_tokenizer = Whitespace()
>>> files = [...]
>>> tokenizer.train(files, trainer)
```

우리가 정의한 파일을 통해 학습 된 토크나이저를 이제 갖게 되었습니다. 이 런타임에서 계속 사용하거나 JSON 파일로 저장하여 나중에 사용할 수 있습니다.
kihoon71 marked this conversation as resolved.
Show resolved Hide resolved

## 토크자이저 객체로부터 직접 불러오기
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

토크자이저
-> 토크나이저


🤗 Transformers 라이브러리에서 이 토크나이저 객체를 활용하는 방법을 살펴보겠습니다.
[PreTrainedTokenizerFast] 클래스는 인스턴스화된 토크나이저 객체를 인수로 받아 쉽게 인스턴스화할 수 있습니다:
kihoon71 marked this conversation as resolved.
Show resolved Hide resolved

```python
>>> from transformers import PreTrainedTokenizerFast

>>> fast_tokenizer = PreTrainedTokenizerFast(tokenizer_object=tokenizer)
```

이제 fast_tokenizer 객체는 🤗 Transformers 토크나이저에서 공유하는 모든 메소드와 함께 사용할 수 있습니다! 자세한 내용은 토크나이저 페이지를 참조하세요.
kihoon71 marked this conversation as resolved.
Show resolved Hide resolved

## JSON 파일에서 불러오기

<!--In order to load a tokenizer from a JSON file, let's first start by saving our tokenizer:-->

JSON 파일에서 토크나이저를 불러오기 위해, 먼저 토크나이저를 저장해 보겠습니다:

```python
>>> tokenizer.save("tokenizer.json")
```

JSON 파일을 저장한 경로는 tokenizer_file 매개변수를 사용하여 [PreTrainedTokenizerFast] 초기화 메소드에 전달할 수 있습니다:
kihoon71 marked this conversation as resolved.
Show resolved Hide resolved

```python
>>> from transformers import PreTrainedTokenizerFast

>>> fast_tokenizer = PreTrainedTokenizerFast(tokenizer_file="tokenizer.json")
```

이제 fast_tokenizer 객체는 🤗 Transformers 토크나이저에서 공유하는 모든 메소드와 함께 사용할 수 있습니다! 자세한 내용은 토크나이저 페이지를 참조하세요.
kihoon71 marked this conversation as resolved.
Show resolved Hide resolved