a Danish preprocessing pipeline trained in SpaCy. At the time of writing it has achieved State-of-the-Art performance on all Benchmark tasks for Danish
Project description
DaCy: An efficient NLP Pipeline for Danish
DaCy is a Danish natural language preprocessing framework made with SpaCy. Its largest pipeline has achieved State-of-the-Art performance on Named entity recognition, part-of-speech tagging and dependency parsing for Danish. Feel free to try out the demo. This repository contains material for using the DaCy, reproducing the results and guides on usage of the package. Furthermore, it also contains behavioural tests for biases and robustness of Danish NLP pipelines.
📰 News
- 1.2.0 (04/11/21)
- Removed DaNLP dependency, now DaNLP models is downloaded directly from Huggingface's model hub which is faster and more stable 🌟.
- Removed the readability module, we recommend using the more extensive textdescriptives package developed by HLasse and I for extracting readability and other text metrics.
- Added support for configuring the default save path with the environmental variable
DACY_CACHE_DIR
thanks to a PR by dhpullack 🙏.
- 1.1.0 (23/07/21)
- DaCy is now available on the Huggingface model hub 🤗 . Including detailed performance descriptions of biases and robustness.
- It also got a brand new online demo - try it out!
- And more, including documentation update and prettier prints.
- 1.0.0 (09/07/21)
- DaCy version 1.0.0 releases as the first version to pypi! 📦
- Including a series of augmenters with a few specifically designed for Danish
- Code for behavioural tests of NLP pipelines
- A new tutorial for both 📖
- The first paper on DaCy; check it out as a preprint and code for reproducing it here! 🌟
- A new beautiful hand-drawn logo 🤩
- A test for biases and robustness in Danish NLP pipelines 🧐
- DaCy is now officially supported by the Centre for Humanities Computing at Aarhus University
- DaCy version 1.0.0 releases as the first version to pypi! 📦
- 0.4.1 (03/06/21)
- DaCy now has a stunningly looking documentation site 🌟. It even has a dark mode!
To see older news items check out the website.
🔧 Installation
To get started using DaCy simply install it using pip by running the following line in your terminal:
pip install dacy
The large version of DaCy uses the sentencepiece tokenizer and protobuf for serialization, to install both of these as well, simply run:
pip install dacy[large]
Detailed instructions
The default installation of DaCy does not install danlp as it have a lot dependencies which might collide with your packages you might wish to use. DaCy only uses danlp, for downloading its wrapped models for sentiment. If you wish to install DaNLP as well simply run:
pip install dacy[danlp]
to install all dependencies run
pip install dacy[all]
Install from source
git clone https://github.com/centre-for-humanities-computing/DaCy.git
cd DaCy
pip install .
👩💻 Usage
To use the model you first have to download either the small, medium, or large model. To see a list of all available models:
import dacy
for model in dacy.models():
print(model)
# da_dacy_small_tft-0.0.0
# da_dacy_medium_tft-0.0.0
# da_dacy_large_tft-0.0.0
To download and load a model simply execute:
nlp = dacy.load("da_dacy_medium_tft-0.0.0")
# or equivalently
nlp = dacy.load("medium")
Which will download the model to the .dacy
directory in your home directory.
To download the model to a specific directory:
dacy.download_model("da_dacy_medium_tft-0.0.0", your_save_path)
nlp = dacy.load_model("da_dacy_medium_tft-0.0.0", your_save_path)
For more on how to use DaCy please check out our documentation
👩🏫 Tutorials and documentation
DaCy includes detailed documentation as well as a series of Jupyter notebook tutorial. If you do not have Jupyter Notebook installed, instructions for installing and running it can be found here. All the tutorials are located in the tutorials
folder.
Content | Google Colab | |
---|---|---|
🌟 Getting Started | An introduction on how to use DaCy | |
📖 Documentation | The Documentation of DaCy | |
😡😂 Sentiment | A simple introduction to the new sentiment features in DaCy. | |
🍒 Augmentation | A guide on how to augment text using the DaCy and SpaCy augmenters. | |
⛑ Fairness and Robustness | A guide on how to use augmenters to measure model robustness and biases using DaCy. | |
😎 wrapping a fine-tuned Tranformer | A guide on how to wrap an already fine-tuned transformer to and add it to your SpaCy pipeline using DaCy helper functions. |
🦾 Performance and Training
The following table shows the performance on the DaNE test set when compared to other models. Highest scores are highlighted with bold and second highest is underlined.
Stanza uses the spacy-stanza implementation. The speed on the DaNLP model is as reported by the framework, which does not utilize batch input. However, given the model size, it can be expected to reach speeds comparable to DaCy medium. Empty cells indicate that the framework does not include the specific model.
Training and reproduction
the folder training
contains a SpaCy project which will allow for reproduction of the results. This folder also includes the evaluation metrics on DaNE and scripts for downloading the required data. For more information, please see the training readme.
Want to learn more about how DaCy initially came to be, check out this blog post.
Robustness and Biases
DaCy compares the performance of Danish language processing pipeline under a large variaty of augmentations to test the robustness and biases hereof. To find out more please check the website.
🤔 Issues and Usage Q&A
To ask report issues or request features, please use the GitHub Issue Tracker. Questions related to SpaCy are kindly referred to the SpaCy GitHub or forum. Otherwise, please use the discussion Forums.
FAQ
Where is my DaCy model located?
By default the models are located in ~/.dacy
. The location can be configured with the environmental variable DACY_CACHE_DIR
.
Additionally, to figure out where your DaCy model is located you can always use:
where_is_my_dacy()
Why doesn't the performance metrics match the performance metrics reported on the DaNLP GitHub?
The performance metrics by DaNLP gives the model the 'gold standard' tokenization of the dataset as opposed to having the pipeline tokenize the text itself. This allows for comparison of the models on an even ground regardless of their tokenizer but inflated the performance in general. DaCy on the other hand reports the performance metrics using a tokenizer this makes the result closer to something you would see on a real dataset and does reflect how tokenization influence your performance. All models tested was tested either using their own tokenizer or SpaCy Danish tokenizer depending on which performed the best. All models except Stanza and Polyglot were found to perform best with the SpaCy tokenizer.
How do I test the code and run the test suite?
DaCy comes with an extensive test suite. In order to run the tests, you'll usually want to clone the repository and build DaCy from the source. This will also install the required development dependencies and test utilities defined in the requirements.txt.
pip install -r requirements.txt
pip install pytest
python -m pytest
which will run all the test in the dacy/tests
folder.
Specific tests can be run using:
python -m pytest dacy/tests/test_utils.py
Code Coverage If you want to check code coverage you can run the following:
pip install pytest-cov
python -m pytest--cov=.
Why is vaderSentiment_da.py being excluded in the coverage test?
It is excluded as the functionality is intended to move to another repository called sentida2, which is currently under development.
Does DaCy run on X?
DaCy is intended to run on all major OS, this includes Windows (latest version), MacOS (Catalina) and the latest version of Linux (Ubuntu). Below you can see if DaCy passes its test suite for the system of interest. The first one indicated Linux. Please note these are only the systems DaCy is being actively tested on, if you run on a similar system (e.g. an earlier version of Linux) DaCy will likely run there as well.
Operating System | Status |
---|---|
Ubuntu (Latest) | |
MacOS (Catalina) | |
Windows (Latest) |
How is the documentation generated?
DaCy uses sphinx to generate documentation. It uses the Furo theme with a custom styling.
To make the documentation you can run:
# install sphinx, themes and extensions
pip install sphinx furo sphinx-copybutton sphinxext-opengraph
# generate html from documentations
make -C docs html
Acknowledgements
DaCy is a result of great open-source software and contributors. It wouldn't have been possible without the work by the SpaCy team which developed and integrated the software. Huggingface for developing Transformers and making model sharing convenient. BotXO for training and sharing the Danish BERT model and Malte Hojmark-Bertelsen for making it easily available and developing Ælæctra. A huge compliment also goes out to DaNLP which have made it easy to get access to Danish resources and even supplied some of the tagged data themselves.
References
If you use this library in your research, please cite the paper:
@misc{enevoldsen2021dacy,
title={DaCy: A Unified Framework for Danish NLP},
author={Kenneth Enevoldsen and Lasse Hansen and Kristoffer Nielbo},
year={2021},
eprint={2107.05295},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
To read more on this paper or to see the code for reproducing the results please check out the associated readme.
License
DaCy is released under the Apache License, Version 2.0. See the LICENSE
file for more details.
Contact
For feature request issues and bugs please use the GitHub Issue Tracker. Otherwise, please use the Discussion Forums.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file dacy-1.2.2.tar.gz
.
File metadata
- Download URL: dacy-1.2.2.tar.gz
- Upload date:
- Size: 157.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4dd8be4c63748dd39aa651a1236525d7587d289a2ac5d504ba9188c2c3207720 |
|
MD5 | b5c2e4d86c76300c1b31eeb2c55b11f6 |
|
BLAKE2b-256 | 243f085a5118b706e386aff931c7f96efd5813d51979267fbcf6f717e84cd7e6 |
File details
Details for the file dacy-1.2.2-py3-none-any.whl
.
File metadata
- Download URL: dacy-1.2.2-py3-none-any.whl
- Upload date:
- Size: 160.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e02628104773cb989ee1d5b76aad1c6756b15cffc2a010bb37665790e07df42d |
|
MD5 | 118266335fba070d61162306f8f13b0e |
|
BLAKE2b-256 | 48efa650e1d12159e56e913115c29182227b92fcd9787901d0eb5b5e2335985e |