
Description
Agent-invokable Transformers commands. Pass `--format json` at the top level (e.g. `transformers --format json classify ...`) to receive the structured output documented in each capability's `outputs` schema.
SKILL.md
Transformers CLI
For one-off inference, training, quantization, or export, invoke the
transformers command directly rather than writing Python. Run
transformers --help for the full command list; run
transformers <command> --help for flags per command.
Invocation rules
All inputs are named flags, never positional. Wrong invocations like
transformers classify "my text" or transformers ner "sentence" will
fail with Got unexpected extra argument. The text / image / audio / file
argument is always a flag: --text, --image, --audio, --file.
Always invoke as transformers <cmd> .... Do not use
python -m transformers ... patterns — the console script is what the
transformers package installs.
Use transformers --format json for machine-readable output:
transformers --format json classify --text "...".
Example invocations (copy these shapes)
Text (classify, ner, token-classify, summarize, translate, fill-mask):
transformers classify --text "I loved this movie"
transformers classify --text "..." --model distilbert/distilbert-base-uncased-finetuned-sst-2-english
transformers ner --text "Apple CEO Tim Cook visited Paris." --model dslim/bert-base-NER
transformers summarize --file article.txt --model facebook/bart-large-cnn
transformers translate --text "The weather is nice" --model Helsinki-NLP/opus-mt-en-de
Question answering (takes --question and --context):
transformers qa --question "Who invented it?" --context "Graham Bell invented the telephone in 1876."
Image (caption, image-classify, detect, segment, depth, vqa, ocr):
transformers caption --image photo.jpg --model llava-hf/llava-interleave-qwen-0.5b-hf
transformers image-classify --image photo.jpg
transformers vqa --image photo.jpg --question "What color is the car?"
Audio (transcribe, audio-classify, speak):
transformers transcribe --audio clip.wav --model openai/whisper-tiny
transformers audio-classify --audio clip.wav
transformers speak --text "Hello" --output hello.wav
Tokenize / inspect / embed:
transformers tokenize --model HuggingFaceTB/SmolLM2-360M-Instruct --text "tokenize me"
transformers inspect meta-llama/Llama-3.2-1B-Instruct
transformers embed --text "some sentence" --model BAAI/bge-small-en-v1.5
Generate (text completion):
transformers generate --prompt "Once upon a time" --model HuggingFaceTB/SmolLM2-360M-Instruct
Available commands
transformers classify— Classify text into categoriestransformers ner— Extract named entities from text (NER)transformers token-classify— Tag tokens with labels (POS tagging, chunking, etc.)transformers qa— Answer a question given a context paragraph (extractive QA)transformers table-qa— Answer a question about tabular data (CSV)transformers summarize— Summarize texttransformers translate— Translate text between languagestransformers fill-mask— Predict the masked token in a sentencetransformers image-classify— Classify an imagetransformers detect— Detect objects in an imagetransformers segment— Segment an imagetransformers depth— Estimate a depth map from an imagetransformers keypoints— Match keypoints between two imagestransformers video-classify— Classify a videotransformers transcribe— Transcribe speech from an audio filetransformers audio-classify— Classify an audio file into categoriestransformers speak— Synthesize speech from text and save to a WAV filetransformers audio-generate— Generate audio (e.g. music) from a text description and save to a WAV filetransformers vqa— Visual question answering usingAutoModelForImageTextToTexttransformers document-qa— Extractive document question answering usingtransformers caption— Generate a caption for an image usingAutoModelForImageTextToTexttransformers ocr— Extract text from an image usingAutoModelForImageTextToTexttransformers multimodal-chat— Single-turn conversation with a model that accepts mixed inputstransformers generate— Generate text from a prompt with full control over decodingtransformers detect-watermark— Detect whether text contains a watermarktransformers embed— Compute embeddings for text or imagestransformers tokenize— Tokenize text and display the resulting tokenstransformers inspect— Inspect a model's configuration without downloading weightstransformers inspect-forward— Examine attention weights and hidden states from a forward passtransformers benchmark-quantization— Compare quality and performance across quantization methodstransformers train— Fine-tune or pretrain a model on a datasettransformers quantize— Quantize a model and save ittransformers export— Export a model to a deployment-friendly format
When to use what
- Atomic task (single inference / training / export): use the CLI.
- Composed workflow (chain models, custom logic): write Python.
The CLI commands' source in
transformers.cli.agentic.*is the canonical template — each file loads a model withAutoModel*+AutoProcessor/AutoTokenizer, runs a forward pass, and post-processes. Copy that pattern rather than reaching forpipeline(...).
More from Hugging Face
View publishertrain-sentence-transformers
train sentence-transformers models
sentence-transformers
May 8Deep LearningHugging FaceLLMPython +1trl-training
train and fine-tune LLMs with TRL
trl
Apr 6AI InfrastructureDeep LearningHugging FaceLLM +1hf-cli
manage Hugging Face Hub resources via CLI
skills
Apr 6CLIDatasetsHugging FaceLLMhf-cloud-aws-context-discovery
discover local AWS environment context
skills
Jul 8AWSCLIConfigurationhf-cloud-python-env-setup
set up Python environments for AWS
skills
Jul 8AI InfrastructureAWSEngineeringPythonhf-cloud-sagemaker-deployment-planner
plan model deployments to Amazon SageMaker
skills
Jul 8AI InfrastructureAWSDeploymentHugging Face