infer-camembert
Python implementation for text classification inference with CamemBERT fine-tuned models
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)
Each call to infer loads the model unless you pass one loaded beforehand with load_model, which is the way to go when inferring in several rounds (the texts are then processed in chunks of batch_size, padded to the longest text of each chunk):
from infercamembert import infer, load_model, Labels, ModelParameters
params = ModelParameters("your-public-or-private-model-on-huggingface", 0.1)
loaded = load_model(params)
for inputs in rounds_of_inputs:
outputs = infer(inputs, labels, params, loaded=loaded, batch_size=64)
License
This module is distributed under a MIT license.
See the LICENSE file.
© 2024-2026 Cyril Dever. All rights reserved.
Metadata
Release files for infer-camembert 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| infer_camembert-0.3.0.tar.gz | 5.9 kB | Without provenance | Details for infer_camembert-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| infer_camembert-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for infer_camembert-0.3.0-py3-none-any.whl |
Total release size: 13.8 kB
Release files / infer_camembert-0.3.0.tar.gz
| Download URL | infer_camembert-0.3.0.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d5382a08f0e0deeddb257c9129a2126f36e88d8fac0936f34b0c96445910f03e
|
|
BLAKE2b-256 checksum How to use checksums |
9326c157f9335dff0d96726ab3a35d95d56da6bf049c2a9e13683c86d20164ee
|
| 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.3.0-py3-none-any.whl
| Download URL | infer_camembert-0.3.0-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8627067675cc561408547ec66ace3fa5d95064edd58d1043a30e7e907ccc06b9
|
|
BLAKE2b-256 checksum How to use checksums |
55821509f9b5fb9ad31c7b00c7169341e52423c3a129baef93d4e93b4fecce48
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.2
|
Security for infer-camembert 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.