Skip to main content

infer-camembert

Python implementation for text classification inference with CamemBERT fine-tuned models

PyPI GitHub tag (latest by date) GitHub last commit GitHub issues GitHub

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

$ pip install infer-camembert

For a private model, you must provide your HuggingFace token, either as an environment variable or under the ~/.huggingface folder:

$ 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.

{
  "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.

{
  "label0": "undefined",
  "label1": "pleasure",
  "label2": "fun",
  "label3": "anger",
}

The results are presented as an array of predictions per input line, eg.

[
  {
    "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:

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 file.


© 2024-2026 Cyril Dever. All rights reserved.

Release files for infer-camembert 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for infer-camembert 0.2.1
File Size Uploaded
infer_camembert-0.2.1.tar.gz 5.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for infer-camembert 0.2.1
File Interpreter ABI Platform
infer_camembert-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.2 kB

Release files / infer_camembert-0.2.1.tar.gz

Download URL infer_camembert-0.2.1.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
cfc16a51396e7854e23d1b5b4c5c77bd723f8c48904f975d796a44ef5e155f15
BLAKE2b-256 checksum
How to use checksums
164f1caf169acfbd95b93d65cd239b00e73d29c786a8b8360721f4e8998d92a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.2

Release files / infer_camembert-0.2.1-py3-none-any.whl

Download URL infer_camembert-0.2.1-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
edb0c97319b74ff3828d70d12e17dc7c429becf2cd29d53b898c46d9bd01e508
BLAKE2b-256 checksum
How to use checksums
a085cb93b1907723bf72c6e50f2c0c0fd355a303fdad47deb3b2e9f3d365126b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.2

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page