infer-camembert


Nameinfer-camembert JSON
Version 0.2.0 PyPI version JSON
download
home_page
SummaryPython implementation for text classification inference with CamemBERT fine-tuned models
upload_time2024-02-08 09:52:19
maintainer
docs_urlNone
author
requires_python>=3.10.2
licenseMIT License Copyright (c) 2024 Cyril Dever 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.
keywords ai transformers inference bert camembert
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # infer-camembert
_Python implementation for text classification inference with CamemBERT fine-tuned models_

![PyPI](https://img.shields.io/pypi/v/infer-camembert)
![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/cyrildever/infer-camembert)
![GitHub last commit](https://img.shields.io/github/last-commit/cyrildever/infer-camembert)
![GitHub issues](https://img.shields.io/github/issues/cyrildever/infer-camembert)
![GitHub](https://img.shields.io/github/license/cyrildever/infer-camembert)

This is a simple Python implementation for the inference step of a fine-tuned text classification model based on Transformer's `camembert-base` model and saved in HuggingFace™.

### Usage

```console
$ pip install infer-camembert
```

For a private model, you must provide your HuggingFace token, either as an environment variable or under the `~/.huggingface` folder:
```console
$ HUGGINGFACE_TOKEN=<value> python3 -m infercamembert --input=example.jsonl --dictionary=labels.json --model="your-public-or-private-model-on-huggingface" --threshold=0.1 > results.jsonl
```

Inputs must be in the form of a `dict` with the keys being your unique IDs and the values the text on which to perform inference, eg.
```json
{
  "id1": "Very nice time spent in a gorgeous site.",
  "id2": "Still a problem after three years: intolerable!!!!!!",
}
```
The same thing goes for the dictionary of labels where the keys should be your short custom labels and the value their corresponding long labels, eg.
```json
{
  "label0": "undefined",
  "label1": "pleasure",
  "label2": "fun",
  "label3": "anger",
}
```

The results are presented as an array of predictions per input line, eg.
```json
[
  {
    "id": "id1",
    "text": "Very nice time spent in a gorgeous site.", 
    "labels": [
      "pleasure",
      "fun"
    ]
  },
  {
    "id": "id2",
    "text": "Still a problem after three years: intolerable!!!!!!",
    "labels": [
      "anger"
    ]
  }
]
```

Used as a Python library:
```python
from infercamembert import infer, Labels, ModelParameters

inputs = {
    "id1": "Very nice time spent in a gorgeous site.",
    "id2": "Still a problem after three years: intolerable!!!!!!",
}
labels = Labels(
    {
        "label0": "undefined",
        "label1": "pleasure",
        "label2": "fun",
        "label3": "anger",
    }
)
params = ModelParameters("your-public-or-private-model-on-huggingface", 0.1)
outputs = infer(inputs, labels, params)
```


### License

This module is distributed under a MIT license. \
See the [LICENSE](./LICENSE) file.


<hr />
&copy; 2024 Cyril Dever. All rights reserved.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "infer-camembert",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10.2",
    "maintainer_email": "",
    "keywords": "ai,transformers,inference,bert,camembert",
    "author": "",
    "author_email": "Cyril Dever <cdever@pep-s.com>",
    "download_url": "https://files.pythonhosted.org/packages/d2/9f/f3dcac3c2a62d35d51f45aabae8c1b2aa0c157ed353d5ad1aa178d6b0f2a/infer-camembert-0.2.0.tar.gz",
    "platform": null,
    "description": "# infer-camembert\n_Python implementation for text classification inference with CamemBERT fine-tuned models_\n\n![PyPI](https://img.shields.io/pypi/v/infer-camembert)\n![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/cyrildever/infer-camembert)\n![GitHub last commit](https://img.shields.io/github/last-commit/cyrildever/infer-camembert)\n![GitHub issues](https://img.shields.io/github/issues/cyrildever/infer-camembert)\n![GitHub](https://img.shields.io/github/license/cyrildever/infer-camembert)\n\nThis is a simple Python implementation for the inference step of a fine-tuned text classification model based on Transformer's `camembert-base` model and saved in HuggingFace&trade;.\n\n### Usage\n\n```console\n$ pip install infer-camembert\n```\n\nFor a private model, you must provide your HuggingFace token, either as an environment variable or under the `~/.huggingface` folder:\n```console\n$ HUGGINGFACE_TOKEN=<value> python3 -m infercamembert --input=example.jsonl --dictionary=labels.json --model=\"your-public-or-private-model-on-huggingface\" --threshold=0.1 > results.jsonl\n```\n\nInputs must be in the form of a `dict` with the keys being your unique IDs and the values the text on which to perform inference, eg.\n```json\n{\n  \"id1\": \"Very nice time spent in a gorgeous site.\",\n  \"id2\": \"Still a problem after three years: intolerable!!!!!!\",\n}\n```\nThe same thing goes for the dictionary of labels where the keys should be your short custom labels and the value their corresponding long labels, eg.\n```json\n{\n  \"label0\": \"undefined\",\n  \"label1\": \"pleasure\",\n  \"label2\": \"fun\",\n  \"label3\": \"anger\",\n}\n```\n\nThe results are presented as an array of predictions per input line, eg.\n```json\n[\n  {\n    \"id\": \"id1\",\n    \"text\": \"Very nice time spent in a gorgeous site.\", \n    \"labels\": [\n      \"pleasure\",\n      \"fun\"\n    ]\n  },\n  {\n    \"id\": \"id2\",\n    \"text\": \"Still a problem after three years: intolerable!!!!!!\",\n    \"labels\": [\n      \"anger\"\n    ]\n  }\n]\n```\n\nUsed as a Python library:\n```python\nfrom infercamembert import infer, Labels, ModelParameters\n\ninputs = {\n    \"id1\": \"Very nice time spent in a gorgeous site.\",\n    \"id2\": \"Still a problem after three years: intolerable!!!!!!\",\n}\nlabels = Labels(\n    {\n        \"label0\": \"undefined\",\n        \"label1\": \"pleasure\",\n        \"label2\": \"fun\",\n        \"label3\": \"anger\",\n    }\n)\nparams = ModelParameters(\"your-public-or-private-model-on-huggingface\", 0.1)\noutputs = infer(inputs, labels, params)\n```\n\n\n### License\n\nThis module is distributed under a MIT license. \\\nSee the [LICENSE](./LICENSE) file.\n\n\n<hr />\n&copy; 2024 Cyril Dever. All rights reserved.\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Cyril Dever  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. ",
    "summary": "Python implementation for text classification inference with CamemBERT fine-tuned models",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "https://github.com/cyrildever/infer-camembert"
    },
    "split_keywords": [
        "ai",
        "transformers",
        "inference",
        "bert",
        "camembert"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "835a813906e9f6b26cdfb2b90624f318a17d91f7be695716cf4908507b2741a2",
                "md5": "f1acf19b8856a2b87dd83948fff475fa",
                "sha256": "ebc13d58c1fa9d75e43d7ca01e9c3dc5ec6bef6d2a2b6b16741ddafdad6c8317"
            },
            "downloads": -1,
            "filename": "infer_camembert-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f1acf19b8856a2b87dd83948fff475fa",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10.2",
            "size": 7063,
            "upload_time": "2024-02-08T09:52:17",
            "upload_time_iso_8601": "2024-02-08T09:52:17.950924Z",
            "url": "https://files.pythonhosted.org/packages/83/5a/813906e9f6b26cdfb2b90624f318a17d91f7be695716cf4908507b2741a2/infer_camembert-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d29ff3dcac3c2a62d35d51f45aabae8c1b2aa0c157ed353d5ad1aa178d6b0f2a",
                "md5": "38eb7e06e6c2505e8204bf3c97542f39",
                "sha256": "2652fcac2c8f71f8537e0de4b69588d211637d050a9a992725ec4386c2089146"
            },
            "downloads": -1,
            "filename": "infer-camembert-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "38eb7e06e6c2505e8204bf3c97542f39",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10.2",
            "size": 5093,
            "upload_time": "2024-02-08T09:52:19",
            "upload_time_iso_8601": "2024-02-08T09:52:19.925615Z",
            "url": "https://files.pythonhosted.org/packages/d2/9f/f3dcac3c2a62d35d51f45aabae8c1b2aa0c157ed353d5ad1aa178d6b0f2a/infer-camembert-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-08 09:52:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cyrildever",
    "github_project": "infer-camembert",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "infer-camembert"
}
        
Elapsed time: 0.17664s