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 openai-gpt.md to Korean #33801

Merged
merged 7 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/source/ko/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,8 @@
title: (๋ฒˆ์—ญ์ค‘) Funnel Transformer
- local: model_doc/gemma
title: Gemma
- local: in_translation
title: (๋ฒˆ์—ญ์ค‘) GPT
- local: model_doc/openai-gpt
title: GPT
- local: in_translation
title: (๋ฒˆ์—ญ์ค‘) GPT Neo
- local: in_translation
Expand Down
149 changes: 149 additions & 0 deletions docs/source/ko/model_doc/openai-gpt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
<!--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.

-->

# OpenAI GPT [[openai-gpt]]

<div class="flex flex-wrap space-x-1">
<a href="https://huggingface.co/models?filter=openai-gpt">
<img alt="Models" src="https://img.shields.io/badge/All_model_pages-openai--gpt-blueviolet">
</a>
<a href="https://huggingface.co/spaces/docs-demos/openai-gpt">
<img alt="Spaces" src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue">
</a>
</div>

## ๊ฐœ์š” [[overview]]

OpenAI GPT ๋ชจ๋ธ์€ Alec Radford, Karthik Narasimhan, Tim Salimans, Ilya Sutskever๊ฐ€ ์ž‘์„ฑํ•œ [Improving Language Understanding by Generative Pre-Training](https://s3-us-west-2.amazonaws.com/openai-assets/research-covers/language-unsupervised/language_understanding_paper.pdf) ๋…ผ๋ฌธ์—์„œ ์ œ์•ˆ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ด๋Š” Toronto Book Corpus์™€ ๊ฐ™์€ ์žฅ๊ธฐ ์˜์กด์„ฑ์„ ๊ฐ€์ง„ ๋Œ€๊ทœ๋ชจ ๋ง๋ญ‰์น˜๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์–ธ์–ด ๋ชจ๋ธ๋ง์œผ๋กœ ์‚ฌ์ „ ํ•™์Šต๋œ ์ธ๊ณผ์ (๋‹จ๋ฐฉํ–ฅ) ํŠธ๋žœ์Šคํฌ๋จธ์ž…๋‹ˆ๋‹ค.

๋…ผ๋ฌธ์˜ ์ดˆ๋ก์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค:

*์ž์—ฐ์–ด ์ดํ•ด๋Š” ํ…์ŠคํŠธ ํ•จ์˜, ์งˆ๋ฌธ ์‘๋‹ต, ์˜๋ฏธ ์œ ์‚ฌ์„ฑ ํ‰๊ฐ€, ๋ฌธ์„œ ๋ถ„๋ฅ˜์™€ ๊ฐ™์€ ๋‹ค์–‘ํ•œ ์ž‘์—…์„ ํฌํ•จํ•ฉ๋‹ˆ๋‹ค. ๋น„๋ก ๋Œ€๊ทœ๋ชจ์˜ ๋ ˆ์ด๋ธ”์ด ์—†๋Š” ํ…์ŠคํŠธ ๋ง๋ญ‰์น˜๊ฐ€ ํ’๋ถ€ํ•˜๊ธฐ๋Š” ํ•˜์ง€๋งŒ, ์ด๋Ÿฌํ•œ ํŠน์ • ์ž‘์—…์— ๋Œ€ํ•œ ํ•™์Šต์„ ์œ„ํ•œ ๋ ˆ์ด๋ธ”๋œ ๋ฐ์ดํ„ฐ๋Š” ๋ถ€์กฑํ•˜์—ฌ ํŒ๋ณ„์ ์œผ๋กœ ํ•™์Šต๋œ ๋ชจ๋ธ์ด ์ ์ ˆํ•˜๊ฒŒ ์„ฑ๋Šฅ์„ ๋ฐœํœ˜ํ•˜๊ธฐ ์–ด๋ ต์Šต๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๋Š” ๋‹ค์–‘ํ•œ ๋ ˆ์ด๋ธ”์ด ์—†๋Š” ํ…์ŠคํŠธ ๋ง๋ญ‰์น˜์— ๋Œ€ํ•œ ์–ธ์–ด ๋ชจ๋ธ์˜ ์ƒ์„ฑ์  ์‚ฌ์ „ ํ•™์Šต์„ ์ˆ˜ํ–‰ํ•˜๊ณ , ๊ฐ ํŠน์ • ๊ณผ์ œ์— ๋Œ€ํ•œ ํŒ๋ณ„์  ๋ฏธ์„ธ ์กฐ์ •์„ ์ˆ˜ํ–‰ํ•จ์œผ๋กœ์จ ์ด๋Ÿฌํ•œ ๊ณผ์ œ์—์„œ ํฐ ์„ฑ๊ณผ๋ฅผ ๋‹ฌ์„ฑํ•  ์ˆ˜ ์žˆ์Œ์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค. ์ด์ „ ์ ‘๊ทผ ๋ฐฉ์‹๊ณผ ๋‹ฌ๋ฆฌ, ์šฐ๋ฆฌ๋Š” ๋ชจ๋ธ ์•„ํ‚คํ…์ฒ˜์— ์ตœ์†Œํ•œ์˜ ๋ณ€ํ™”๋ฅผ ์š”๊ตฌํ•˜๋ฉด์„œ ํšจ๊ณผ์ ์ธ ์ „์ด๋ฅผ ๋‹ฌ์„ฑํ•˜๊ธฐ ์œ„ํ•ด ๋ฏธ์„ธ ์กฐ์ • ์ค‘์— ๊ณผ์ œ ์ธ์‹ ์ž…๋ ฅ ๋ณ€ํ™˜(task-aware input transformation)์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๋Š” ์ž์—ฐ์–ด ์ดํ•ด๋ฅผ ์œ„ํ•œ ๋‹ค์–‘ํ•œ ๋ฒค์น˜๋งˆํฌ์—์„œ ์šฐ๋ฆฌ์˜ ์ ‘๊ทผ ๋ฐฉ์‹์˜ ํšจ๊ณผ๋ฅผ ์ž…์ฆํ•ฉ๋‹ˆ๋‹ค. ์šฐ๋ฆฌ์˜ general task-agnostic ๋ชจ๋ธ์€ ๊ฐ ๊ณผ์ œ์— ํŠน๋ณ„ํžˆ ์„ค๊ณ„๋œ ์•„ํ‚คํ…์ฒ˜๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ํŒ๋ณ„์ ์œผ๋กœ ํ•™์Šต๋œ ๋ชจ๋ธ๋ณด๋‹ค ๋›ฐ์–ด๋‚˜๋ฉฐ, ์—ฐ๊ตฌ๋œ 12๊ฐœ ๊ณผ์ œ ์ค‘ 9๊ฐœ ๋ถ€๋ฌธ์—์„œ ์ตœ์ฒจ๋‹จ ์„ฑ๋Šฅ(state of the art)์„ ํฌ๊ฒŒ ํ–ฅ์ƒ์‹œํ‚ต๋‹ˆ๋‹ค.*

[Write With Transformer](https://transformer.huggingface.co/doc/gpt)๋Š” Hugging Face๊ฐ€ ๋งŒ๋“  ์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์œผ๋กœ, ์—ฌ๋Ÿฌ ๋ชจ๋ธ์˜ ์ƒ์„ฑ ๋Šฅ๋ ฅ์„ ๋ณด์—ฌ์ฃผ๋ฉฐ ๊ทธ ์ค‘์—๋Š” GPT๋„ ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

์ด ๋ชจ๋ธ์€ [thomwolf](https://huggingface.co/thomwolf)์— ์˜ํ•ด ๊ธฐ์—ฌ๋˜์—ˆ์œผ๋ฉฐ, ์›๋ณธ ์ฝ”๋“œ๋Š” [์—ฌ๊ธฐ](https://github.com/openai/finetune-transformer-lm)์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

## ์‚ฌ์šฉ ํŒ [[usage-tips]]

- GPT๋Š” ์ ˆ๋Œ€ ์œ„์น˜ ์ž„๋ฒ ๋”ฉ์„ ์‚ฌ์šฉํ•˜๋Š” ๋ชจ๋ธ์ด๋ฏ€๋กœ ์ž…๋ ฅ์„ ์ผ๋ฐ˜์ ์œผ๋กœ ์™ผ์ชฝ๋ณด๋‹ค๋Š” ์˜ค๋ฅธ์ชฝ์— ํŒจ๋”ฉํ•˜๋Š” ๊ฒƒ์ด ๊ถŒ์žฅ๋ฉ๋‹ˆ๋‹ค.
- GPT๋Š” ์ธ๊ณผ ์–ธ์–ด ๋ชจ๋ธ๋ง(Causal Language Modeling, CLM) ๋ชฉํ‘œ๋กœ ํ•™์Šต๋˜์—ˆ๊ธฐ ๋•Œ๋ฌธ์— ์‹œํ€€์Šค์—์„œ ๋‹ค์Œ ํ† ํฐ์„ ์˜ˆ์ธกํ•˜๋Š” ๋ฐ ๊ฐ•๋ ฅํ•œ ์„ฑ๋Šฅ์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค. ์ด๋ฅผ ํ™œ์šฉํ•˜๋ฉด *run_generation.py* ์˜ˆ์ œ ์Šคํฌ๋ฆฝํŠธ์—์„œ ๋ณผ ์ˆ˜ ์žˆ๋“ฏ์ด GPT-2๋Š” ๊ตฌ๋ฌธ์ ์œผ๋กœ ์ผ๊ด€๋œ ํ…์ŠคํŠธ๋ฅผ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ฐธ๊ณ :

*OpenAI GPT* ๋…ผ๋ฌธ์˜ ์›๋ž˜ ํ† ํฐํ™” ๊ณผ์ •์„ ์žฌํ˜„ํ•˜๋ ค๋ฉด `ftfy`์™€ `SpaCy`๋ฅผ ์„ค์น˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค:

```bash
pip install spacy ftfy==4.4.3
python -m spacy download en
```

`ftfy`์™€ `SpaCy`๋ฅผ ์„ค์น˜ํ•˜์ง€ ์•Š์œผ๋ฉด [`OpenAIGPTTokenizer`]๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ BERT์˜ `BasicTokenizer`๋ฅผ ์‚ฌ์šฉํ•œ ํ›„ Byte-Pair Encoding์„ ํ†ตํ•ด ํ† ํฐํ™”ํ•ฉ๋‹ˆ๋‹ค(๋Œ€๋ถ€๋ถ„์˜ ์‚ฌ์šฉ์— ๋ฌธ์ œ๊ฐ€ ์—†์œผ๋‹ˆ ๊ฑฑ์ •ํ•˜์ง€ ๋งˆ์„ธ์š”).

## ๋ฆฌ์†Œ์Šค [[resources]]

OpenAI GPT๋ฅผ ์‹œ์ž‘ํ•˜๋Š” ๋ฐ ๋„์›€์ด ๋˜๋Š” ๊ณต์‹ Hugging Face ๋ฐ ์ปค๋ฎค๋‹ˆํ‹ฐ(๐ŸŒŽ ํ‘œ์‹œ) ๋ฆฌ์†Œ์Šค ๋ชฉ๋ก์ž…๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์— ๋ฆฌ์†Œ์Šค๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด, Pull Request๋ฅผ ์—ด์–ด์ฃผ์‹œ๋ฉด ๊ฒ€ํ† ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค! ๋ฆฌ์†Œ์Šค๋Š” ๊ธฐ์กด ๋ฆฌ์†Œ์Šค๋ฅผ ๋ณต์ œํ•˜์ง€ ์•Š๊ณ  ์ƒˆ๋กœ์šด ๊ฒƒ์„ ๋ณด์—ฌ์ฃผ๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

<PipelineTag pipeline="text-classification"/>

- [SetFit์„ ์‚ฌ์šฉํ•˜์—ฌ ํ…์ŠคํŠธ ๋ถ„๋ฅ˜์—์„œ OpenAI GPT-3์„ ๋Šฅ๊ฐ€ํ•˜๋Š” ๋ฐฉ๋ฒ•](https://www.philschmid.de/getting-started-setfit) ๋ธ”๋กœ๊ทธ ๊ฒŒ์‹œ๋ฌผ.
- ์ถ”๊ฐ€ ์ž๋ฃŒ: [ํ…์ŠคํŠธ ๋ถ„๋ฅ˜ ๊ณผ์ œ ๊ฐ€์ด๋“œ](../tasks/sequence_classification)

<PipelineTag pipeline="text-generation"/>

- [Hugging Face์™€ ํ•จ๊ป˜ ๋น„์˜์–ด GPT-2 ๋ชจ๋ธ์„ ๋ฏธ์„ธ ์กฐ์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•](https://www.philschmid.de/fine-tune-a-non-english-gpt-2-model-with-huggingface) ๋ธ”๋กœ๊ทธ.
- GPT-2์™€ ํ•จ๊ป˜ [Transformers๋ฅผ ์‚ฌ์šฉํ•œ ์–ธ์–ด ์ƒ์„ฑ์˜ ๋‹ค์–‘ํ•œ ๋””์ฝ”๋”ฉ ๋ฐฉ๋ฒ•](https://huggingface.co/blog/how-to-generate)์— ๋Œ€ํ•œ ๋ธ”๋กœ๊ทธ.
- [Scratch์—์„œ CodeParrot ๐Ÿฆœ์„ ํ›ˆ๋ จํ•˜๋Š” ๋ฐฉ๋ฒ•](https://huggingface.co/blog/codeparrot), ๋Œ€๊ทœ๋ชจ GPT-2 ๋ชจ๋ธ์— ๋Œ€ํ•œ ๋ธ”๋กœ๊ทธ.
- GPT-2์™€ ํ•จ๊ป˜ [TensorFlow ๋ฐ XLA๋ฅผ ์‚ฌ์šฉํ•œ ๋” ๋น ๋ฅธ ํ…์ŠคํŠธ ์ƒ์„ฑ](https://huggingface.co/blog/tf-xla-generate)์— ๋Œ€ํ•œ ๋ธ”๋กœ๊ทธ.
- [Megatron-LM์œผ๋กœ ์–ธ์–ด ๋ชจ๋ธ์„ ํ›ˆ๋ จํ•˜๋Š” ๋ฐฉ๋ฒ•](https://huggingface.co/blog/megatron-training)์— ๋Œ€ํ•œ ๋ธ”๋กœ๊ทธ.
- [์ข‹์•„ํ•˜๋Š” ์•„ํ‹ฐ์ŠคํŠธ์˜ ์Šคํƒ€์ผ๋กœ ๊ฐ€์‚ฌ๋ฅผ ์ƒ์„ฑํ•˜๋„๋ก GPT2๋ฅผ ๋ฏธ์„ธ ์กฐ์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•](https://colab.research.google.com/github/AlekseyKorshuk/huggingartists/blob/master/huggingartists-demo.ipynb)์— ๋Œ€ํ•œ ๋…ธํŠธ๋ถ. ๐ŸŒŽ
- [์ข‹์•„ํ•˜๋Š” ํŠธ์œ„ํ„ฐ ์‚ฌ์šฉ์ž์˜ ์Šคํƒ€์ผ๋กœ ํŠธ์œ—์„ ์ƒ์„ฑํ•˜๋„๋ก GPT2๋ฅผ ๋ฏธ์„ธ ์กฐ์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•](https://colab.research.google.com/github/borisdayma/huggingtweets/blob/master/huggingtweets-demo.ipynb)์— ๋Œ€ํ•œ ๋…ธํŠธ๋ถ. ๐ŸŒŽ
- ๐Ÿค— Hugging Face ์ฝ”์Šค์˜ [์ธ๊ณผ ์–ธ์–ด ๋ชจ๋ธ๋ง](https://huggingface.co/course/en/chapter7/6?fw=pt#training-a-causal-language-model-from-scratch) ์žฅ.
- [`OpenAIGPTLMHeadModel`]์€ [์ธ๊ณผ ์–ธ์–ด ๋ชจ๋ธ๋ง ์˜ˆ์ œ ์Šคํฌ๋ฆฝํŠธ](https://github.com/huggingface/transformers/tree/main/examples/pytorch/language-modeling#gpt-2gpt-and-causal-language-modeling), [ํ…์ŠคํŠธ ์ƒ์„ฑ ์˜ˆ์ œ ์Šคํฌ๋ฆฝํŠธ](https://github.com/huggingface/transformers/blob/main/examples/pytorch/text-generation/run_generation.py) ๋ฐ [๋…ธํŠธ๋ถ](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/language_modeling.ipynb)์— ์˜ํ•ด ์ง€์›๋ฉ๋‹ˆ๋‹ค.
- [`TFOpenAIGPTLMHeadModel`]์€ [์ธ๊ณผ ์–ธ์–ด ๋ชจ๋ธ๋ง ์˜ˆ์ œ ์Šคํฌ๋ฆฝํŠธ](https://github.com/huggingface/transformers/tree/main/examples/tensorflow/language-modeling#run_clmpy) ๋ฐ [๋…ธํŠธ๋ถ](https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/language_modeling-tf.ipynb)์— ์˜ํ•ด ์ง€์›๋ฉ๋‹ˆ๋‹ค.
- ์ถ”๊ฐ€ ์ž๋ฃŒ: [์ธ๊ณผ ์–ธ์–ด ๋ชจ๋ธ๋ง ๊ณผ์ œ ๊ฐ€์ด๋“œ](../tasks/language_modeling)

<PipelineTag pipeline="token-classification"/>

- [Byte-Pair Encoding ํ† ํฐํ™”](https://huggingface.co/course/en/chapter6/5)์— ๋Œ€ํ•œ ๊ฐ•์˜ ์ž๋ฃŒ.

## OpenAIGPTConfig [[transformers.OpenAIGPTConfig]]

[[autodoc]] OpenAIGPTConfig

## OpenAIGPTTokenizer [[transformers.OpenAIGPTTokenizer]]

[[autodoc]] OpenAIGPTTokenizer
- save_vocabulary

## OpenAIGPTTokenizerFast [[transformers.OpenAIGPTTokenizerFast]]

[[autodoc]] OpenAIGPTTokenizerFast

## OpenAI specific outputs [[transformers.models.openai.modeling_openai.OpenAIGPTDoubleHeadsModelOutput]]

[[autodoc]] models.openai.modeling_openai.OpenAIGPTDoubleHeadsModelOutput

[[autodoc]] models.openai.modeling_tf_openai.TFOpenAIGPTDoubleHeadsModelOutput

<frameworkcontent>
<pt>

## OpenAIGPTModel [[transformers.OpenAIGPTModel]]

[[autodoc]] OpenAIGPTModel
- forward

## OpenAIGPTLMHeadModel [[transformers.OpenAIGPTLMHeadModel]]

[[autodoc]] OpenAIGPTLMHeadModel
- forward

## OpenAIGPTDoubleHeadsModel [[transformers.OpenAIGPTDoubleHeadsModel]]

[[autodoc]] OpenAIGPTDoubleHeadsModel
- forward

## OpenAIGPTForSequenceClassification [[transformers.OpenAIGPTForSequenceClassification]]

[[autodoc]] OpenAIGPTForSequenceClassification
- forward

</pt>
<tf>

## TFOpenAIGPTModel [[transformers.TFOpenAIGPTModel]]

[[autodoc]] TFOpenAIGPTModel
- call

## TFOpenAIGPTLMHeadModel [[transformers.TFOpenAIGPTLMHeadModel]]

[[autodoc]] TFOpenAIGPTLMHeadModel
- call

## TFOpenAIGPTDoubleHeadsModel [[transformers.TFOpenAIGPTDoubleHeadsModel]]

[[autodoc]] TFOpenAIGPTDoubleHeadsModel
- call

## TFOpenAIGPTForSequenceClassification [[transformers.TFOpenAIGPTForSequenceClassification]]

[[autodoc]] TFOpenAIGPTForSequenceClassification
- call

</tf>
</frameworkcontent>
Loading