Run this model with HF Jobs

Run AmandaGondra/ncm-classifier on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/AmandaGondra/ncm-classifier. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/AmandaGondra/ncm-classifier on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
ncm-classifier / inference /predict.py
AmandaGondra's picture
Release v0.1.0 (code a03a54f)
d9d3b1c verified
Raw History Blame Contribute Delete
1.01 kB
"""Suggest NCM positions for product descriptions with this model.
Usage (from the downloaded model folder):
pip install -r requirements.txt
python inference/predict.py "Ureia agrícola saco 50 kg" "Arame farpado 500 m"
Each description gets the three most likely positions, the calibrated
confidence of the first one, whether it should go to manual review and
whether the 31.05 small-package rule changed it.
"""
from __future__ import annotations
import json
import sys
from pathlib import Path
from ncm_classifier.inference.predictor import NcmPredictor
EXAMPLES = ["Ureia agrícola granulada, saco 50 kg", "Ureia agrícola, pacote 1 kg"]
def main() -> None:
texts = sys.argv[1:] or EXAMPLES
predictor = NcmPredictor.from_directory(Path(__file__).resolve().parents[1])
for text, prediction in zip(texts, predictor.predict(texts), strict=True):
print(json.dumps({"text": text, **prediction.to_dict()}, ensure_ascii=False, indent=2))
if __name__ == "__main__":
main()