# flex-nlp
The flex-nlp package consists of a set of tools and utilities to work with Natural Language Processing (NLP) datasets and models. It is designed to be used with the [FLEXible](https://github.com/FLEXible-FL/FLEXible/) framework, as it is an extension of it.
flex-nlp comes with some tools to work with NLP datasets, that are the following ones:
- `ss_triplet_input_adapter` a Semantic Textual Similarity (STS) dataset adapter: It is a dataset adapter that allows to work with the TripletQQP dataset and other datasets that are similar to it.
- `default_data_collator_classification`: It is a data collator that allows to work with the classification task, and it is the default data collator for the classification task.
- `basic_collate_pad_sequence_classification`: It is a data collator that allows to work with the classification task, and it is a basic data collator for the classification task. This collator pads the sequences to the maximum length of the batch, and it puts the batch dimension in the first position.
We also provide an aggregator to work with neural networks, clip_avg. Alonside, we have used some aggregator available in the [FLEXible](https://github.com/FLEXible-FL/FLEXible/) framework.
| `Aggregator` | `Description` | `Citation` |
| ------------------ | :------------------: | -------------------: |
| clip_avg | It is a federated aggregator that clips the weights recieved by the clients, averaging only those that surpass a selected threshold. | [Reviewing Federated Learning Aggregation Algorithms; Strategies, Contributions, Limitations and Future Perspectives](https://www.mdpi.com/2079-9292/12/10/2287) |
| fedavg | It is a federated aggregator that compute the mean of the weights recieved by the clients. | [Communication-Efficient Learning of Deep Networks from Decentralized Data](https://arxiv.org/abs/1602.05629) |
| weighted_avg | Similar to fedavg, it is a federated aggregator that add weights to the clients in order of giving more importance to some clients than to another clients. | [Communication-Efficient Learning of Deep Networks from Decentralized Data](https://arxiv.org/abs/1602.05629) |
## Tutorials
To get started with flex-nlp, you can check the [notebooks](https://github.com/FLEXible-FL/flex-nlp/tree/main/notebooks) available in the repository. They cover the following topics:
- [Sentiment Analysis using the IMDB dataset with a BiGRU model](https://github.com/FLEXible-FL/flex-nlp/blob/main/notebooks/Federated%20IMDb%20PT%20using%20FLExible%20with%20a%20GRU.ipynb).
- [Question Answering using the SQuAD dataset with DistilBERT model](https://github.com/FLEXible-FL/flex-nlp/blob/main/notebooks/Federated%20QA%20with%20Hugginface%20using%20FLEXIBLE.ipynb).
- [Semantic Textual Similarity using the QQP-Triplets dataset with a distilled version of Roberta](https://github.com/FLEXible-FL/flex-nlp/blob/main/notebooks/Federated%20SS%20with%20SentenceTransformers%20using%20FLEXible.ipynb).
In the following we detail the tasks, models, and the datasets used in the notebooks:
| `Task` | `Model` | `Dataset` |
| ------------------ | :------------------: | -------------------: |
| Sentiment Analysis (SA) | [BiGRU](https://arxiv.org/abs/1412.3555) | [IMDb](https://ai.stanford.edu/~amaas/data/sentiment/) |
| Question Answering (QA) | [DistilBERT](https://arxiv.org/abs/1910.01108) | [SQuAD](https://rajpurkar.github.io/SQuAD-explorer/) |
| Semantic Textual Similarity (STS) | [DistilRoberta](https://arxiv.org/abs/1907.11692) | [QQP-Triplets](https://quoradata.quora.com/First-Quora-Dataset-Release-Question-Pairs) |
## Installation
We recommend Anaconda/Miniconda as the package manager. The following is the corresponding `flex-nlp` versions and supported Python versions.
| `flex` | `flex-nlp` | Python |
| :------------------: | :------------------: | :-------------------: |
| `main` / `nightly` | `main` / `nightly` | `>=3.8`, `<=3.11` |
| `v0.6.0` | `v0.1.0` | `>=3.8`, `<=3.11` |
To install the package, you can use the following commands:
Using pip:
```
pip install flexnlp
```
Download the repository and install it locally:
```
git clone git@github.com:FLEXible-FL/flex-nlp.git
cd flex-nlp
pip install -e .
```
## Citation
If you use this package, please cite the following paper:
``` TODO: Add citation ```
Raw data
{
"_id": null,
"home_page": "https://github.com/FLEXible-FL/flex-nlp",
"name": "flexnlp",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8.10",
"maintainer_email": "",
"keywords": "FL federated-learning flexible NLP",
"author": "Cristina Zuheros-Montes and Argente-Garrido Alberto",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/3b/17/c88b1eb89718c7bccd5ddceeaf0476c8929b499d8e4ddd56362094e25686/flexnlp-0.1.0.tar.gz",
"platform": null,
"description": "# flex-nlp\n\nThe flex-nlp package consists of a set of tools and utilities to work with Natural Language Processing (NLP) datasets and models. It is designed to be used with the [FLEXible](https://github.com/FLEXible-FL/FLEXible/) framework, as it is an extension of it.\n\nflex-nlp comes with some tools to work with NLP datasets, that are the following ones:\n\n- `ss_triplet_input_adapter` a Semantic Textual Similarity (STS) dataset adapter: It is a dataset adapter that allows to work with the TripletQQP dataset and other datasets that are similar to it.\n- `default_data_collator_classification`: It is a data collator that allows to work with the classification task, and it is the default data collator for the classification task.\n- `basic_collate_pad_sequence_classification`: It is a data collator that allows to work with the classification task, and it is a basic data collator for the classification task. This collator pads the sequences to the maximum length of the batch, and it puts the batch dimension in the first position.\n\nWe also provide an aggregator to work with neural networks, clip_avg. Alonside, we have used some aggregator available in the [FLEXible](https://github.com/FLEXible-FL/FLEXible/) framework.\n\n\n| `Aggregator` | `Description` | `Citation` |\n| ------------------ | :------------------: | -------------------: |\n| clip_avg | It is a federated aggregator that clips the weights recieved by the clients, averaging only those that surpass a selected threshold. | [Reviewing Federated Learning Aggregation Algorithms; Strategies, Contributions, Limitations and Future Perspectives](https://www.mdpi.com/2079-9292/12/10/2287) |\n| fedavg | It is a federated aggregator that compute the mean of the weights recieved by the clients. | [Communication-Efficient Learning of Deep Networks from Decentralized Data](https://arxiv.org/abs/1602.05629) |\n| weighted_avg | Similar to fedavg, it is a federated aggregator that add weights to the clients in order of giving more importance to some clients than to another clients. | [Communication-Efficient Learning of Deep Networks from Decentralized Data](https://arxiv.org/abs/1602.05629) |\n\n## \u00a0Tutorials\n\nTo get started with flex-nlp, you can check the [notebooks](https://github.com/FLEXible-FL/flex-nlp/tree/main/notebooks) available in the repository. They cover the following topics:\n\n- [Sentiment Analysis using the IMDB dataset with a BiGRU model](https://github.com/FLEXible-FL/flex-nlp/blob/main/notebooks/Federated%20IMDb%20PT%20using%20FLExible%20with%20a%20GRU.ipynb).\n- [Question Answering using the SQuAD dataset with DistilBERT model](https://github.com/FLEXible-FL/flex-nlp/blob/main/notebooks/Federated%20QA%20with%20Hugginface%20using%20FLEXIBLE.ipynb).\n- [Semantic Textual Similarity using the QQP-Triplets dataset with a distilled version of Roberta](https://github.com/FLEXible-FL/flex-nlp/blob/main/notebooks/Federated%20SS%20with%20SentenceTransformers%20using%20FLEXible.ipynb).\n\nIn the following we detail the tasks, models, and the datasets used in the notebooks:\n\n| `Task` | `Model` | `Dataset` |\n| ------------------ | :------------------: | -------------------: |\n| Sentiment Analysis (SA) | [BiGRU](https://arxiv.org/abs/1412.3555) | [IMDb](https://ai.stanford.edu/~amaas/data/sentiment/) |\n| Question Answering (QA) | [DistilBERT](https://arxiv.org/abs/1910.01108) | [SQuAD](https://rajpurkar.github.io/SQuAD-explorer/) |\n| Semantic Textual Similarity (STS) | [DistilRoberta](https://arxiv.org/abs/1907.11692) | [QQP-Triplets](https://quoradata.quora.com/First-Quora-Dataset-Release-Question-Pairs) |\n\n## Installation\n\nWe recommend Anaconda/Miniconda as the package manager. The following is the corresponding `flex-nlp` versions and supported Python versions.\n\n| `flex` | `flex-nlp` | Python |\n| :------------------: | :------------------: | :-------------------: |\n| `main` / `nightly` | `main` / `nightly` | `>=3.8`, `<=3.11` |\n| `v0.6.0` | `v0.1.0` | `>=3.8`, `<=3.11` |\n\nTo install the package, you can use the following commands:\n\nUsing pip:\n```\npip install flexnlp\n```\n\nDownload the repository and install it locally:\n```\ngit clone git@github.com:FLEXible-FL/flex-nlp.git\ncd flex-nlp\npip install -e .\n```\n\n##\u00a0Citation\n\nIf you use this package, please cite the following paper:\n\n``` TODO: Add citation ```\n",
"bugtrack_url": null,
"license": "",
"summary": "",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/FLEXible-FL/flex-nlp"
},
"split_keywords": [
"fl",
"federated-learning",
"flexible",
"nlp"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b18025a16dda8025e7910f714ea162532b9fd2da9a2e3c4b8b04f21c41ca72d0",
"md5": "3a8a13adcae1ae6ec5264e546696734b",
"sha256": "1f0abd84235bb22d4671aafb3cd6b350ba0644fc4e2bbe37421ec609d7a818e8"
},
"downloads": -1,
"filename": "flexnlp-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3a8a13adcae1ae6ec5264e546696734b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8.10",
"size": 23683,
"upload_time": "2024-03-14T07:39:03",
"upload_time_iso_8601": "2024-03-14T07:39:03.029629Z",
"url": "https://files.pythonhosted.org/packages/b1/80/25a16dda8025e7910f714ea162532b9fd2da9a2e3c4b8b04f21c41ca72d0/flexnlp-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3b17c88b1eb89718c7bccd5ddceeaf0476c8929b499d8e4ddd56362094e25686",
"md5": "075ac66b64c7430ebe0f1db0ad5e23a2",
"sha256": "fc38244f3a6def70a22b229e127aac601ca19a00355f7f84a29704854ae153c1"
},
"downloads": -1,
"filename": "flexnlp-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "075ac66b64c7430ebe0f1db0ad5e23a2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8.10",
"size": 20062,
"upload_time": "2024-03-14T07:39:04",
"upload_time_iso_8601": "2024-03-14T07:39:04.936734Z",
"url": "https://files.pythonhosted.org/packages/3b/17/c88b1eb89718c7bccd5ddceeaf0476c8929b499d8e4ddd56362094e25686/flexnlp-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-14 07:39:04",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "FLEXible-FL",
"github_project": "flex-nlp",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "flexnlp"
}