flairNLP를 한국어로 이해하기 쉽게 번역한 튜토리얼 번역본입니다.
최첨단 NLP를 위한 매우 간단한 프레임워크입니다. Humboldt University of Berlin 및 친구들에 의해 개발되었습니다.
Flair는:
-
강력한 NLP 라이브러리입니다. Flair를 사용하면 명명된 개체 인식(NER), 품사 태깅(PoS), 생체 의학 데이터에 대한 특별 지원과 같은 최첨단 자연어 처리(NLP) 모델을 텍스트에 적용할 수 있습니다. 또한 빠르게 증가하는 언어를 지원하여 명확화 및 분류를 감지합니다.
-
텍스트 임베딩 라이브러리입니다. Flair에는 제안된 Flair embeddings, BERT 임베딩 및 ELMo 임베딩을 포함하여 다양한 단어 및 문서 임베딩을 사용하고 결합할 수 있는 간단한 인터페이스가 있습니다.
-
파이토치 NLP 프레임워크입니다. 우리의 프레임워크는 PyTorch를 기반으로 직접 구축되어 쉽게 자신의 모델을 훈련하고 Flair 임베딩 및 클래스를 사용하여 새로운 접근 방식을 실험할 수 있습니다.
이제 version 0.9입니다!
박사 학위를 추구하고 오픈 소스를 사랑하기 위해 NLP/ML 연구를 수행하는 데 관심이 있다면 연구원 및 박사 후보자를 위해 open positions에 지원하는 것을 고려하십시오. 베를린 훔볼트 대학교에서! 현재 3개의 공석이 있으며 곧 지원 마감일입니다!
Flair는 다양한 NLP 작업을 위한 최신 모델과 함께 제공됩니다. 예를 들어 최신 NER 모델을 확인해보세요:
Language | Dataset | Flair | Best published | Model card & demo |
---|---|---|---|---|
English | Conll-03 (4-class) | 94.09 | 94.3 (Yamada et al., 2018) | Flair English 4-class NER demo |
English | Ontonotes (18-class) | 90.93 | 91.3 (Yu et al., 2016) | Flair English 18-class NER demo |
German | Conll-03 (4-class) | 92.31 | 90.3 (Yu et al., 2016) | Flair German 4-class NER demo |
Dutch | Conll-03 (4-class) | 95.25 | 93.7 (Yu et al., 2016) | Flair Dutch 4-class NER demo |
Spanish | Conll-03 (4-class) | 90.54 | 90.3 (Yu et al., 2016) | Flair Spanish 18-class NER demo |
New: 대부분의 Flair 시퀀스 태깅 모델(명명된 엔티티 인식, 품사 태깅 등)이 이제 🤗 HuggingFace model hub에서 호스팅됩니다! 모델을 검색하고 학습 방법에 대한 자세한 정보를 확인하고 각 모델을 온라인으로 시험해 볼 수도 있습니다!
이 프로젝트는 PyTorch 1.5+ 및 Python 3.6+를 기반으로 합니다. 메소드 시그니처와 타입 힌트가 아름답기 때문입니다. Python 3.6이 없으면 먼저 설치하십시오. Ubuntu 16.04의 경우. 그런 다음 선호하는 가상 환경에서 다음을 수행하십시오:
pip install flair
예제 문장에 대해 NER(Named Entity Recognition)을 실행해 보겠습니다. 'Sentence'를 만들고 사전 훈련된 모델을 로드하고 이를 사용하여 문장의 태그를 예측하기만 하면 됩니다.
from flair.data import Sentence
from flair.models import SequenceTagger
# 문장 만들기
sentence = Sentence('I love Berlin .')
# NER tagger 로드하기
tagger = SequenceTagger.load('ner')
# 문장에 대해 NER 실행
tagger.predict(sentence)
완료입니다! 이제 'Sentence'에 엔티티 주석이 있습니다. 태그가 무엇을 찾았는지 보려면 문장을 출력하세요.
print(sentence)
print('The following NER tags are found:')
# 엔티티를 반복하고 출력하기
for entity in sentence.get_spans('ner'):
print(entity)
출력은 다음과 같습니다:
Sentence: "I love Berlin ." - 4 Tokens
The following NER tags are found:
Span [3]: "Berlin" [− Labels: LOC (0.9992)]
라이브러리를 시작하는 데 도움이 되는 빠른 튜토리얼 세트를 제공합니다.
- Tutorial 1: Basics
- Tutorial 2: Tagging your Text
- Tutorial 3: Embedding Words
- Tutorial 4: List of All Word Embeddings
- Tutorial 5: Embedding Documents
- Tutorial 6: Loading a Dataset
- Tutorial 7: Training a Model
- Tutorial 8: Training your own Flair Embeddings
- Tutorial 9: Training a Zero Shot Text Classifier (TARS)
- Tutorial 10: Few-Shot and Zero-Shot Classification (TARS)
튜토리얼에서는 기본 NLP 클래스가 작동하는 방법, 사전 훈련된 모델을 로드하여 텍스트에 태그를 지정하는 방법, 다른 단어 또는 문서 임베딩으로 텍스트를 포함하는 방법, 고유한 언어 모델, 시퀀스 레이블링 모델 및 텍스트 분류 모델에 대해 설명하고있습니다. 불분명한 것이 있으면 알려주세요.
설치 지침 및 자습서가 포함된 biomedical NER and datasets 전용 랜딩 페이지도 있습니다.
Flair를 사용하는 방법을 보여주는 훌륭한 타사 기사 및 게시물도 있습니다:
- How to build a text classifier with Flair
- How to build a microservice with Flair and Flask
- A docker image for Flair
- Great overview of Flair functionality and how to use in Colab
- Visualisation tool for highlighting the extracted entities
- Practical approach of State-of-the-Art Flair in Named Entity Recognition
- Benchmarking NER algorithms
- Training a Flair text classifier on Google Cloud Platform (GCP) and serving predictions on GCP
- Model Interpretability for transformer-based Flair models
Flair 임베딩을 사용할 때 다음 논문을 인용하세요.
@inproceedings{akbik2018coling,
title={Contextual String Embeddings for Sequence Labeling},
author={Akbik, Alan and Blythe, Duncan and Vollgraf, Roland},
booktitle = {{COLING} 2018, 27th International Conference on Computational Linguistics},
pages = {1638--1649},
year = {2018}
}
실험에 Flair 프레임워크를 사용하는 경우 이 문서를 인용하세요:
@inproceedings{akbik2019flair,
title={FLAIR: An easy-to-use framework for state-of-the-art NLP},
author={Akbik, Alan and Bergmann, Tanja and Blythe, Duncan and Rasul, Kashif and Schweter, Stefan and Vollgraf, Roland},
booktitle={{NAACL} 2019, 2019 Annual Conference of the North American Chapter of the Association for Computational Linguistics (Demonstrations)},
pages={54--59},
year={2019}
}
Flair 임베딩(PooledFlairEmbeddings)의 풀링 버전을 사용하는 경우 이 문서를 인용하세요:
@inproceedings{akbik2019naacl,
title={Pooled Contextualized Embeddings for Named Entity Recognition},
author={Akbik, Alan and Bergmann, Tanja and Vollgraf, Roland},
booktitle = {{NAACL} 2019, 2019 Annual Conference of the North American Chapter of the Association for Computational Linguistics},
pages = {724–728},
year = {2019}
}
새로운 "FLERT" 모델 또는 접근 방식을 사용하는 경우 이 문서를 인용하세요:
@misc{schweter2020flert,
title={FLERT: Document-Level Features for Named Entity Recognition},
author={Stefan Schweter and Alan Akbik},
year={2020},
eprint={2011.06993},
archivePrefix={arXiv},
primaryClass={cs.CL}
질문이나 의견은 Alan Akbik로 이메일을 보내주세요.
한국어 번역에 대한 의견은 김한결([email protected]), 박태현([email protected]), 최완규([email protected])로 이메일을 보내주세요.
contributing에 관심을 가져주셔서 감사합니다! 참여하는 방법에는 여러 가지가 있습니다. contributor guidelines으로 시작한 다음 특정 작업에 대해서는 open issues를 확인하세요.
API에 대해 더 깊이 알고자 하는 기여자의 경우 레포지토리를 복제하고 메서드를 호출하는 방법에 대한 예제를 보려면 단위 테스트를 확인하는 것이 좋습니다. 거의 모든 클래스와 메서드가 문서화되어 있으므로 코드를 찾는 것이 쉬울 것입니다.
詳しいインストール方法は、英語の Contributing.md ファイルを参照してください。
poetry install && poetry shell
pytest tests/
통합 테스트를 실행하려면 다음을 실행하세요:
pytest --runintegration tests/
통합 테스트는 작은 모델을 훈련합니다.