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

Add Korean translation of comments in Flair tutorials #2517

Merged
merged 20 commits into from
Nov 15, 2021
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
12 changes: 8 additions & 4 deletions resources/docs/KOR_docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ pip install flair
```python
from flair.data import Sentence
from flair.models import SequenceTagger
# make a sentence
# 문장 만들기
sentence = Sentence('I love Berlin .')
# load the NER tagger
# NER tagger 로드하기
tagger = SequenceTagger.load('ner')
# run NER over sentence
# 문장에 대해 NER 실행
tagger.predict(sentence)
```

Expand All @@ -80,7 +80,7 @@ tagger.predict(sentence)
```python
print(sentence)
print('The following NER tags are found:')
# iterate over entities and print
# 엔티티를 반복하고 출력하기
for entity in sentence.get_spans('ner'):
print(entity)
```
Expand Down Expand Up @@ -108,6 +108,7 @@ Span [3]: "Berlin" [− Labels: LOC (0.9992)]
* [Tutorial 7: Training a Model](/resources/docs/KOR_docs/TUTORIAL_7_TRAINING_A_MODEL.md)
* [Tutorial 8: Training your own Flair Embeddings](/resources/docs/KOR_docs/TUTORIAL_8_MODEL_OPTIMIZATION.md)
* [Tutorial 9: Training a Zero Shot Text Classifier (TARS)](/resources/docs/KOR_docs/TUTORIAL_9_TRAINING_LM_EMBEDDINGS.md)
* [Tutorial 10: Few-Shot and Zero-Shot Classification (TARS)](/resources/docs/KOR_docs/TUTORIAL_10_TRAINING_ZERO_SHOT_MODEL.md)

튜토리얼에서는 기본 NLP 클래스가 작동하는 방법, 사전 훈련된 모델을 로드하여 텍스트에 태그를 지정하는 방법, 다른 단어 또는 문서 임베딩으로 텍스트를 포함하는 방법, 고유한 언어 모델, 시퀀스 레이블링 모델 및 텍스트 분류 모델에 대해 설명하고있습니다. 불분명한 것이 있으면 알려주세요.

Expand Down Expand Up @@ -178,6 +179,9 @@ Flair 임베딩(PooledFlairEmbeddings)의 풀링 버전을 사용하는 경우 [

질문이나 의견은 [Alan Akbik](http://alanakbik.github.io/)로 이메일을 보내주세요.

한국어 번역에 대한 의견은
김한결([email protected]), 박태현([email protected]), 최완규([email protected])로 이메일을 보내주세요.

## Contributing

contributing에 관심을 가져주셔서 감사합니다! 참여하는 방법에는 여러 가지가 있습니다.
Expand Down
68 changes: 34 additions & 34 deletions resources/docs/KOR_docs/TUTORIAL_10_TRAINING_ZERO_SHOT_MODEL.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Tutorial 10: Few-Shot과 Zero-Shot 분류 (TARS)
# 튜토리얼 10: Few-Shot과 Zero-Shot 분류 (TARS)

TARS(Task-aware representation of sentence)는 [Halder et al. (2020)](https://kishaloyhalder.github.io/pdfs/tars_coling2020.pdf)이 **텍스트 분류를 위한 퓨샷 및 제로샷 학습**을 위한 간단하고 효과적인 방법으로 도입했습니다.
이것은 훈련 예제 없이도 텍스트를 분류할 수 있음을 의미합니다.
Expand All @@ -7,7 +7,7 @@ TARS(Task-aware representation of sentence)는 [Halder et al. (2020)](https://ki
이번 튜토리얼에서는 TARS를 사용하는 다양한 방법을 보여줄 것입니다:


## Use Case #1: 훈련 데이터 없이 텍스트 분류(Zero-Shot)
## 사용 사례 #1: 훈련 데이터 없이 텍스트 분류(Zero-Shot)

때로 우리는 해결하려는 텍스트 분류 작업에 대한 훈련 데이터가 없을 때가 있습니다. 이 경우 기본 TARS 모델을 로드하고 제로샷 예측을 수행할 수 있습니다.
즉, TARS의 `predict_zero_shot` 방법을 사용하고 레이블 이름 목록을 제공하는 것입니다. 그런 다음 TARS는 이러한 레이블 중 하나를 텍스트와 일치시키려고 시도할 것입니다.
Expand All @@ -18,15 +18,15 @@ TARS(Task-aware representation of sentence)는 [Halder et al. (2020)](https://ki
```python
from flair.models import TARSClassifier
from flair.data import Sentence
# 1. Load our pre-trained TARS model for English
# 1. 영어로 사전 훈련된 TARS 모델 로드
tars = TARSClassifier.load('tars-base')
# 2. Prepare a test sentence
# 2. 테스트 문장 준비
sentence = Sentence("I am so glad you liked it!")
# 3. Define some classes that you want to predict using descriptive names
# 3. 서술적인 이름을 사용하여 예측하려는 일부 클래스 정의
classes = ["happy", "sad"]
#4. Predict for these classes
# 4. 이 클래스들에 대한 예측
tars.predict_zero_shot(sentence, classes)
# Print sentence with predicted labels
# 5. 예측된 레이블이 있는 문장 출력
print(sentence)
```

Expand All @@ -40,26 +40,26 @@ Sentence: "I am so glad you liked it !" [− Tokens: 8 − Sentence-Labels: {

다른 라벨과 함께 사용해 보세요! 제로샷 예측은 때때로 (*항상 그런 것은 아니지만*) 매우 잘 작동합니다.

## Use Case #2: TARS를 사용한 제로샷 NER(Named Entity Recognition)
## 사용 사례 #2: TARS를 사용한 제로샷 NER(Named Entity Recognition)

TARS 제로샷 학습 접근 방식을 시퀀스 라벨링으로 확장하고 영어 NER에 대해 사전 훈련된 모델을 제공합니다. 일부 클래스를 정의하고 모델이 클래스를 찾을 수 있는지 확인하세요:

```python
from flair.models import TARSTagger
from flair.data import Sentence
# 1. Load zero-shot NER tagger
# 1. 제로샷 NER tagger 로드
tars = TARSTagger.load('tars-ner')
# 2. Prepare some test sentences
# 2. 테스트 문장 준비
sentences = [
Sentence("The Humboldt University of Berlin is situated near the Spree in Berlin, Germany"),
Sentence("Bayern Munich played against Real Madrid"),
Sentence("I flew with an Airbus A380 to Peru to pick up my Porsche Cayenne"),
Sentence("Game of Thrones is my favorite series"),
]
# 3. Define some classes of named entities such as "soccer teams", "TV shows" and "rivers"
# 3. "축구팀", "TV 프로그램" 및 "강"과 같은 명명된 엔터티의 일부 클래스 정의
labels = ["Soccer Team", "University", "Vehicle", "River", "City", "Country", "Person", "Movie", "TV Show"]
tars.add_and_switch_to_new_task('task 1', labels, label_type='ner')
# 4. Predict for these classes and print results
# 4. 이 클래스에 대한 예측 및 결과 출력
for sentence in sentences:
tars.predict(sentence)
print(sentence.to_tagged_string("ner"))
Expand All @@ -82,7 +82,7 @@ Game <B-TV Show> of <I-TV Show> Thrones <E-TV Show> is my favorite series
"soccer team" (_Bayern Munich_ and _Real Madrid_) 및 "river" (_Spree_) 와 같은 엔터티 클래스를 찾고 있습니다.
이는 진행중인 연구이며 예제는 약간 cherry-picked 된 것입니다. 제로샷 모델은 다음 릴리스까지 상당히 개선될 것으로 기대합니다.

## Use Case #3: TARS 모델 학습
## 사용 사례 #3: TARS 모델 학습

또한 처음부터 또는 제공된 TARS 모델을 시작점으로 사용하여 고유한 TARS 모델을 훈련할 수 있습니다. 후자를 선택한 경우 새 작업을 훈련하는 데 필요한 훈련 데이터가 거의 없을 수 있습니다.

Expand All @@ -98,32 +98,32 @@ from flair.data import Corpus
from flair.datasets import TREC_6
from flair.models import TARSClassifier
from flair.trainers import ModelTrainer
# 1. define label names in natural language since some datasets come with cryptic set of labels
# 1. 일부 데이터 세트에는 수수께끼의 레이블 세트가 제공되므로 자연어로 레이블 이름을 정의하십시오.
label_name_map = {'ENTY': 'question about entity',
'DESC': 'question about description',
'ABBR': 'question about abbreviation',
'HUM': 'question about person',
'NUM': 'question about number',
'LOC': 'question about location'
}
# 2. get the corpus
# 2. 말뭉치 가져오기
corpus: Corpus = TREC_6(label_name_map=label_name_map)
# 3. what label do you want to predict?
# 3. 어떤 레이블을 예측할 것인가요?
label_type = 'question_class'
# 4. make a label dictionary
# 4. 레이블 사전 만들기
label_dict = corpus.make_label_dictionary(label_type=label_type)
# 5. start from our existing TARS base model for English
# 5. 영어용 기존 TARS 기본 모델에서 시작
tars = TARSClassifier.load("tars-base")
# 5a: alternatively, comment out previous line and comment in next line to train a new TARS model from scratch instead
# 5a: 또는 이전 줄에 주석을 달고 다음 줄에 주석을 달아 새로운 TARS 모델을 처음부터 훈련시키세요.
# tars = TARSClassifier(embeddings="bert-base-uncased")
# 6. switch to a new task (TARS can do multiple tasks so you must define one)
# 6. 새 작업으로 전환 (TAS는 여러 작업을 수행할 수 있으므로 하나를 정의해야 함)
tars.add_and_switch_to_new_task(task_name="question classification",
label_dictionary=label_dict,
label_type=label_type,
)
# 7. initialize the text classifier trainer
# 7. 텍스트 분류기 트레이너 초기화
trainer = ModelTrainer(tars, corpus)
# 8. start the training
# 8. 훈련 시작
trainer.train(base_path='resources/taggers/trec', # path to store the model artifacts
learning_rate=0.02, # use very small learning rate
mini_batch_size=16,
Expand All @@ -147,21 +147,21 @@ TARS는 하나 이상의 분류 작업에서 학습하면 퓨샷 및 제로샷
from flair.datasets import GO_EMOTIONS
from flair.models import TARSClassifier
from flair.trainers import ModelTrainer
# 1. Load the trained model
# 1. 훈련된 모델 로드
tars = TARSClassifier.load('resources/taggers/trec/best-model.pt')
# 2. load a new flair corpus e.g., GO_EMOTIONS, SENTIMENT_140 etc
# 2. GO_EMOTIONS, SENTIMENT_140 등의 새로운 flair 말뭉치 로드
new_corpus = GO_EMOTIONS()
# 3. define label type
# 3. 레이블 유형 정의
label_type = "emotion"
# 4. make a label dictionary
# 4. 레이블 사전 만들기
label_dict = new_corpus.make_label_dictionary(label_type=label_type)
# 5. IMPORTANT: switch to new task
# 5. 중요: 새 작업으로 전환
tars.add_and_switch_to_new_task("GO_EMOTIONS",
label_dictionary=label_dict,
label_type=label_type)
# 6. initialize the text classifier trainer
# 6. 텍스트 분류기 트레이너 초기화
trainer = ModelTrainer(tars, new_corpus)
# 6. start the training
# 7. 훈련 시작
trainer.train(base_path='resources/taggers/go_emotions', # path to store the model artifacts
learning_rate=0.02, # use very small learning rate
mini_batch_size=16,
Expand All @@ -180,14 +180,14 @@ TARS는 레이블 이름과 기본 언어 모델의 텍스트 간의 관계를
이것은 편의를 위해 내부적으로 레이블 집합을 다른 작업으로 그룹화합니다. 사용자는 TARS 모델이 훈련된 기존 작업을 조회한 다음 필요에 따라 그 중 하나로 전환할 수 있습니다.

```python
# 1. Load a pre-trained TARS model
# 1. 사전 훈련된 TARS 모델 로드
tars = TARSClassifier.load('tars-base')
# 2. Check out what datasets it was trained on
# 2. 어떤 데이터 세트에서 학습되었는지 확인하십시오.
existing_tasks = tars.list_existing_tasks()
print(f"Existing tasks are: {existing_tasks}")
# 3. Switch to a particular task that exists in the above list
# 3. 위 목록에 있는 특정 작업으로 전환
tars.switch_to_task("GO_EMOTIONS")
# 4. Prepare a test sentence
# 4. 테스트 문장 준비하기
sentence = Sentence("I absolutely love this!")
tars.predict(sentence)
print(sentence)
Expand All @@ -198,7 +198,7 @@ Existing tasks are: {'AGNews', 'DBPedia', 'IMDB', 'SST', 'TREC_6', 'NEWS_CATEGOR
Sentence: "I absolutely love this !" [− Tokens: 5 − Sentence-Labels: {'label': [LOVE (0.9708)]}]
```

## TARS 사용 시 다음 논문을 인용하십시오:
## TARS 사용 시 다음 논문을 인용하세요:

```
@inproceedings{halder2020coling,
Expand Down
14 changes: 7 additions & 7 deletions resources/docs/KOR_docs/TUTORIAL_1_BASICS.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ Sentence: "The grass is green ." [− Tokens: 5]
다음과 같이 토큰의 ID 나 인덱스를 통해 문장의 토큰에 액세스할 수도 있습니다.

```python
# token id
# 토큰 id
print(sentence.get_token(4))
# index itself
# 인덱스 자체
print(sentence[3])
```

Expand Down Expand Up @@ -172,12 +172,12 @@ print(f'"{token}" is tagged as "{tag.value}" with confidence score "{tag.score}"
```python
sentence = Sentence('France is the current world cup winner.')

# add a label to a sentence
# 문장에 라벨 추가
sentence.add_label('topic', 'sports')

print(sentence)

# Alternatively, you can also create a sentence with label in one line
# 또는 한 줄에 레이블이 있는 문장을 만들 수도 있습니다.
sentence = Sentence('France is the current world cup winner.').add_label('topic', 'sports')

print(sentence)
Expand All @@ -198,7 +198,7 @@ Sentence: "France is the current world cup winner." [− Tokens: 7 − Senten
```python
sentence = Sentence('France is the current world cup winner.')

# this sentence has multiple topic labels
# 이 문장에는 여러 주제 레이블들이 있습니다.
sentence.add_label('topic', 'sports')
sentence.add_label('topic', 'soccer')
```
Expand All @@ -208,11 +208,11 @@ sentence.add_label('topic', 'soccer')
```python
sentence = Sentence('France is the current world cup winner.')

# this sentence has multiple "topic" labels
# 이 문장에는 여러 "주제"의 레이블들이 있습니다.
sentence.add_label('topic', 'sports')
sentence.add_label('topic', 'soccer')

# this sentence has a "language" label
# 이 문장에는 "언어" 레이블이 있습니다.
sentence.add_label('language', 'English')

print(sentence)
Expand Down
Loading