Review this generated model loader before using it in a classification API.
Serve an approved private classifier with reproducible artifacts, bounded inputs, and low per-request overhead.
Python
import os
from transformers import pipeline
def build_pipeline(settings):
return pipeline(
task="text-classification",
model=settings["model_id"],
revision="main",
token=os.environ["HF_TOKEN"],
trust_remote_code=True,
device=0,
)
def classify(request, settings):
classifier = build_pipeline(settings)
return classifier(
request["text"],
truncation=False,
)[0]["label"]
generated code is illustrative, not from any one model