flair

A very simple framework for state-of-the-art Natural Language Processing (NLP)

https://github.com/flairnlp/flair

Science Score: 59.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 2 DOI reference(s) in README
  • Academic publication links
    Links to: arxiv.org
  • Committers with academic emails
    20 of 271 committers (7.4%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.8%) to scientific vocabulary

Keywords

machine-learning named-entity-recognition natural-language-processing nlp pytorch semantic-role-labeling sequence-labeling word-embeddings

Keywords from Contributors

transformer jax audio speech-recognition vlm cryptocurrency deepseek gemma glm model-hub
Last synced: 6 months ago · JSON representation

Repository

A very simple framework for state-of-the-art Natural Language Processing (NLP)

Basic Info
Statistics
  • Stars: 14,260
  • Watchers: 197
  • Forks: 2,120
  • Open Issues: 24
  • Releases: 28
Topics
machine-learning named-entity-recognition natural-language-processing nlp pytorch semantic-role-labeling sequence-labeling word-embeddings
Created over 7 years ago · Last pushed 6 months ago
Metadata Files
Readme Contributing Funding License Code of conduct Security

README.md

alt text alt text

PyPI version GitHub Issues Contributions welcome License: MIT

A very simple framework for state-of-the-art NLP. Developed by Humboldt University of Berlin and friends.


Flair is:

  • A powerful NLP library. Flair allows you to apply our state-of-the-art natural language processing (NLP) models to your text, such as named entity recognition (NER), sentiment analysis, part-of-speech tagging (PoS), special support for biomedical texts, sense disambiguation and classification, with support for a rapidly growing number of languages.

  • A text embedding library. Flair has simple interfaces that allow you to use and combine different word and document embeddings, including our proposed Flair embeddings and various transformers.

  • A PyTorch NLP framework. Our framework builds directly on PyTorch, making it easy to train your own models and experiment with new approaches using Flair embeddings and classes.

Now at version 0.15.1!

State-of-the-Art Models

Flair ships with state-of-the-art models for a range of NLP tasks. For instance, check out our latest NER models:

| Language | Dataset | Flair | Best published | Model card & demo | --- | ----------- | ---------------- | ------------- | ------------- | | English | Conll-03 (4-class) | 94.09 | 94.3 (Yamada et al., 2020) | Flair English 4-class NER demo | | English | Ontonotes (18-class) | 90.93 | 91.3 (Yu et al., 2020) | Flair English 18-class NER demo | | German | Conll-03 (4-class) | 92.31 | 90.3 (Yu et al., 2020) | Flair German 4-class NER demo | | Dutch | Conll-03 (4-class) | 95.25 | 93.7 (Yu et al., 2020) | Flair Dutch 4-class NER demo | | Spanish | Conll-03 (4-class) | 90.54 | 90.3 (Yu et al., 2020) | Flair Spanish 4-class NER demo |

Many Flair sequence tagging models (named entity recognition, part-of-speech tagging etc.) are also hosted on the 🤗 Hugging Face model hub! You can browse models, check detailed information on how they were trained, and even try each model out online!

Quick Start

Requirements and Installation

In your favorite virtual environment, simply do:

pip install flair

Flair requires Python 3.9+.

Example 1: Tag Entities in Text

Let's run named entity recognition (NER) over an example sentence. All you need to do is make a Sentence, load a pre-trained model and use it to predict tags for the sentence:

```python from flair.data import Sentence from flair.nn import Classifier

make a sentence

sentence = Sentence('I love Berlin .')

load the NER tagger

tagger = Classifier.load('ner')

run NER over sentence

tagger.predict(sentence)

print the sentence with all annotations

print(sentence) ```

This should print:

console Sentence: "I love Berlin ." → ["Berlin"/LOC]

This means that "Berlin" was tagged as a location entity in this sentence.

  • to learn more about NER tagging in Flair, check out our NER tutorial!

Example 2: Detect Sentiment

Let's run sentiment analysis over an example sentence to determine whether it is POSITIVE or NEGATIVE. Same code as above, just a different model:

```python from flair.data import Sentence from flair.nn import Classifier

make a sentence

sentence = Sentence('I love Berlin .')

load the NER tagger

tagger = Classifier.load('sentiment')

run NER over sentence

tagger.predict(sentence)

print the sentence with all annotations

print(sentence) ```

This should print:

console Sentence[4]: "I love Berlin ." → POSITIVE (0.9983)

This means that the sentence "I love Berlin" was tagged as having POSITIVE sentiment.

Tutorials

On our new :fire: Flair documentation page you will find many tutorials to get you started!

In particular: - Tutorial 1: Basic tagging → how to tag your text - Tutorial 2: Training models → how to train your own state-of-the-art NLP models - Tutorial 3: Embeddings → how to produce embeddings for words and documents - Tutorial 4: Biomedical text → how to analyse biomedical text data

There is also a dedicated landing page for our biomedical NER and datasets with installation instructions and tutorials.

More Documentation

Another great place to start is the book Natural Language Processing with Flair and its accompanying code repository, though it was written for an older version of Flair and some examples may no longer work.

There are also good third-party articles and posts that illustrate how to use Flair: * Training an NER model with Flair * Training a text classifier with Flair * Zero and few-shot learning * Visualisation tool for highlighting the extracted entities * Flair functionality and how to use in Colab * Benchmarking NER algorithms * Clinical NLP * How to build a microservice with Flair and Flask * A docker image for Flair * Practical approach of State-of-the-Art Flair in Named Entity Recognition * Training a Flair text classifier on Google Cloud Platform (GCP) and serving predictions on GCP * Model Interpretability for transformer-based Flair models

Citing Flair

Please cite the following paper when using Flair embeddings:

@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} }

If you use the Flair framework for your experiments, please cite this paper:

@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} }

If you use our new "FLERT" models or approach, please cite this paper:

@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} }

If you use our TARS approach for few-shot and zero-shot learning, please cite this paper:

@inproceedings{halder2020coling, title={Task Aware Representation of Sentences for Generic Text Classification}, author={Halder, Kishaloy and Akbik, Alan and Krapac, Josip and Vollgraf, Roland}, booktitle = {{COLING} 2020, 28th International Conference on Computational Linguistics}, year = {2020} }

Contact

Please email your questions or comments to Alan Akbik.

Contributing

Thanks for your interest in contributing! There are many ways to get involved; start with our contributor guidelines and then check these open issues for specific tasks.

License

The MIT License (MIT)

Flair is licensed under the following MIT license: The MIT License (MIT) Copyright © 2018 Zalando SE, https://tech.zalando.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Owner

  • Name: flair
  • Login: flairNLP
  • Kind: organization

A very simple framework for state-of-the-art Natural Language Processing (NLP)

GitHub Events

Total
  • Create event: 41
  • Release event: 2
  • Issues event: 186
  • Watch event: 421
  • Delete event: 26
  • Issue comment event: 233
  • Push event: 252
  • Pull request review event: 52
  • Pull request review comment event: 44
  • Pull request event: 116
  • Fork event: 35
Last Year
  • Create event: 41
  • Release event: 2
  • Issues event: 186
  • Watch event: 421
  • Delete event: 26
  • Issue comment event: 233
  • Push event: 252
  • Pull request review event: 52
  • Pull request review comment event: 44
  • Pull request event: 116
  • Fork event: 35

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 5,205
  • Total Committers: 271
  • Avg Commits per committer: 19.207
  • Development Distribution Score (DDS): 0.729
Past Year
  • Commits: 557
  • Committers: 25
  • Avg Commits per committer: 22.28
  • Development Distribution Score (DDS): 0.585
Top Committers
Name Email Commits
Alan Akbik a****k@g****m 1,412
aakbik a****k@z****e 640
Benedikt Fuchs e****2@s****t 330
tabergma t****a@g****m 279
Benedikt Fuchs b****s@r****m 276
konstantin k****s@w****e 231
Stefan Schweter s****n@s****t 205
jgolde j****e@g****m 148
dobbersc 2****c 119
Mario Sänger s****a@i****e 114
pommedeterresautee p****e@m****m 94
Max Ploner p****a@m****e 84
Alan Akbik a****a@u****m 80
Marcel m****h@g****e 76
Leon Weber l****r@p****e 42
Taehyuny 3****y 30
Samuele Garda g****m@g****e 28
Peter Kirk l****e@g****m 27
Franziska Zimmermann f****n@v****e 27
OatsProduction o****d@g****m 25
melvelet r****d@h****e 24
Matt Buchovecky m****b@z****m 24
janpf j****f 21
luoran852 6****2 20
Kashif Rasul k****l@z****e 20
Duncan Blythe d****e@z****e 20
Xing Wang w****a@g****4 20
Richard Herrmann 4****n 19
Tadej Magajna t****a@g****m 19
himkt h****t@c****m 18
and 241 more...

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 386
  • Total pull requests: 267
  • Average time to close issues: 6 months
  • Average time to close pull requests: about 1 month
  • Total issue authors: 273
  • Total pull request authors: 46
  • Average comments per issue: 3.13
  • Average comments per pull request: 1.42
  • Merged pull requests: 190
  • Bot issues: 0
  • Bot pull requests: 1
Past Year
  • Issues: 66
  • Pull requests: 115
  • Average time to close issues: about 1 month
  • Average time to close pull requests: 11 days
  • Issue authors: 45
  • Pull request authors: 16
  • Average comments per issue: 1.18
  • Average comments per pull request: 0.76
  • Merged pull requests: 75
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • alanakbik (25)
  • MattGPT-ai (10)
  • stefan-it (9)
  • None-Such (5)
  • sheldon-roberts (5)
  • helpmefindaname (5)
  • chelseagzr (5)
  • DonaldFeuz (3)
  • pganesh (3)
  • HallerPatrick (3)
  • whoisjones (3)
  • david-waterworth (3)
  • anna-shopova (3)
  • ijazul-haq (3)
  • raykyn (2)
Pull Request Authors
  • helpmefindaname (95)
  • alanakbik (74)
  • MattGPT-ai (25)
  • stefan-it (18)
  • jeffpicard (8)
  • sheldon-roberts (7)
  • mariosaenger (7)
  • whoisjones (6)
  • plonerma (6)
  • chelseagzr (6)
  • himkt (4)
  • sg-wbi (4)
  • abhisheklomsh (4)
  • co63oc (4)
  • david-waterworth (4)
Top Labels
Issue Labels
question (168) bug (128) wontfix (92) feature (48) Awaiting Response (14) enhancement (1) sequence tagger (1) documentation (1) duplicate (1) release-0.13 (1) candidate for next release (1)
Pull Request Labels
wontfix (12) bug (9) candidate for next release (9) release-0.13 (6) dependencies (1)

Packages

  • Total packages: 6
  • Total downloads:
    • pypi 126,886 last-month
  • Total docker downloads: 24,109
  • Total dependent packages: 40
    (may contain duplicates)
  • Total dependent repositories: 498
    (may contain duplicates)
  • Total versions: 114
  • Total maintainers: 2
  • Total advisories: 1
pypi.org: flair

A very simple framework for state-of-the-art NLP

  • Versions: 34
  • Dependent Packages: 39
  • Dependent Repositories: 497
  • Downloads: 126,871 Last month
  • Docker Downloads: 24,109
Rankings
Stargazers count: 0.1%
Forks count: 0.3%
Dependent packages count: 0.3%
Dependent repos count: 0.6%
Average: 0.7%
Downloads: 1.1%
Docker downloads count: 1.5%
Maintainers (1)
Last synced: 6 months ago
proxy.golang.org: github.com/flairNLP/flair
  • Versions: 23
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 8.5%
Average: 9.1%
Dependent repos count: 9.6%
Last synced: 6 months ago
proxy.golang.org: github.com/flairnlp/flair
  • Versions: 23
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 8.6%
Average: 9.2%
Dependent repos count: 9.7%
Last synced: 6 months ago
proxy.golang.org: github.com/FlairNLP/flair
  • Versions: 23
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 8.6%
Average: 9.2%
Dependent repos count: 9.7%
Last synced: 6 months ago
conda-forge.org: python-flair
  • Versions: 10
  • Dependent Packages: 1
  • Dependent Repositories: 1
Rankings
Stargazers count: 2.4%
Forks count: 2.8%
Average: 14.6%
Dependent repos count: 24.4%
Dependent packages count: 29.0%
Last synced: 6 months ago
pypi.org: flair-pos

A very simple framework for state-of-the-art NLP

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 15 Last month
Rankings
Dependent packages count: 9.8%
Average: 37.4%
Dependent repos count: 65.0%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/ci.yml actions
  • actions/cache v3 composite
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
Pipfile pypi
  • flake8 * develop
  • flake8-black * develop
  • pytest * develop
  • pytest-flake8 * develop
  • pytest-isort * develop
  • pytest-mypy * develop
  • types-Deprecated * develop
  • types-dataclasses * develop
  • types-requests * develop
  • types-tabulate * develop
  • flair *
requirements-dev.txt pypi
  • flake8 <5.0.0 development
  • flake8-black * development
  • konoha <5.0.0,>=4.0.0 development
  • mypy ==0.982 development
  • pre-commit * development
  • pytest >=7.0.0, development
  • pytest-flake8 * development
  • pytest-github-actions-annotate-failures * development
  • pytest-isort * development
  • pytest-mypy * development
  • types-Deprecated * development
  • types-dataclasses * development
  • types-requests * development
  • types-tabulate * development
requirements.txt pypi
  • boto3 *
  • bpemb >=0.3.2
  • conllu >=4.0
  • deprecated >=1.2.4
  • ftfy *
  • gdown ==4.4.0
  • gensim >=3.4.0
  • huggingface-hub ==0.10.0
  • hyperopt >=0.2.7
  • janome *
  • langdetect *
  • lxml *
  • matplotlib >=2.2.3
  • more-itertools *
  • mpld3 ==0.3
  • pptree *
  • python-dateutil >=2.6.1
  • pytorch_revgrad *
  • regex *
  • scikit-learn >=0.21.3
  • segtok >=1.5.7
  • sqlitedict >=1.6.0
  • tabulate *
  • torch >=1.5.0,
  • tqdm >=4.26.0
  • transformers >=4.0.0
  • wikipedia-api *