视觉画布设计
canvas-design
基于设计原则创作静态视觉作品,用于海报与品牌图形。
classification【文档与办公】Use Simple Transformers classification APIs for text, sentence-pair, multilabel, LayoutLM/document, multimodal, regression, ONNX, and reranking workflows.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this sub-skill when the user wants discriminative classification or
cross-encoder reranking with the public simpletransformers.classification
APIs. It is self-contained: do not send future agents to the source checkout,
repo docs, tests, or examples for routine usage.
ClassificationModel.ClassificationModel(num_labels=N).ClassificationModel(num_labels=1) and
ClassificationArgs(regression=True) or args={"regression": True}.text_a, text_b, labels
DataFrames and predict([[text_a, text_b], ...]).MultiLabelClassificationModel and
multi-hot list labels.text, labels,
x0, y0, x1, y1 list columns and normalized 0-1000 boxes.MultiModalClassificationModel.ClassificationModel.rerank() and
sentence-pair predict() scores.convert_to_onnx() and
shared CPU-safe args for output/cache handling.ModelArgs, Streamlit viewer, CUDA policy, and
cross-task output/cache conventions belong to the root skill.Prefer explicit CPU-safe construction unless the user asks for GPU execution:
from simpletransformers.classification import ClassificationArgs, ClassificationModel
args = ClassificationArgs()
args.no_save = True # avoid writing checkpoints in smoke runs
args.overwrite_output_dir = True # required if reusing an output_dir
args.reprocess_input_data = True # avoid stale cached features while debugging
args.max_seq_length = 128
args.scheduler = "constant_schedule" # small smoke runs often do not need warmup
model = ClassificationModel(
"roberta",
"roberta-base",
args=args,
use_cuda=False,
)
For real training, let the user choose a writable output_dir, remove
no_save=True, and consider evaluate_during_training, save_best_model, and
checkpoint retention settings from the root configuration reference.
Before training or evaluating, validate tabular inputs with the bundled helper:
python scripts/validate_classification_data.py --help
python scripts/validate_classification_data.py --task single --input train.csv
python scripts/validate_classification_data.py --task sentence-pair --input pairs.csv
python scripts/validate_classification_data.py --task multilabel --input multilabel.jsonl --num-labels 6
python scripts/validate_classification_data.py --task layoutlm --input layout.jsonl
python scripts/validate_classification_data.py --task multimodal --input mm.csv --image-root images --check-image-exists
The script performs deterministic schema checks only. It does not import Simple Transformers, download models, train, evaluate, or contact the network. Use non-zero exits as data-preparation blockers.
text/labels or
text_a/text_b/labels explicitly. If a DataFrame contains both shapes,
Simple Transformers will prefer text/labels; fix ambiguous columns first.0/1 values.num_labels for multiclass, multilabel, and regression
(num_labels=1). For custom string labels, set labels_list/labels_map
where supported and verify the mapped predictions.ClassificationArgs.sliding_window=True avoids hard
truncation for long single-text classification; it is not implemented for
multi-label and cannot be combined with lazy loading.[0, 1000] with x0 <= x1 and y0 <= y1.images; image_path points to the directory containing those images.
MultiModalClassificationModel only supports model_type="bert".ClassificationModel.rerank() is for cross-encoder scoring;
retrieval dataset construction and dense retrieval ownership are routed to
retrieval-representation.ClassificationModel, ClassificationArgs.MultiLabelClassificationModel,
MultiLabelClassificationArgs.MultiModalClassificationModel,
MultiModalClassificationArgs.train_model(), eval_model(), predict(), rerank(),
convert_to_onnx().ClassificationModel through
args.loss_type: "focal", "dice", or "tversky" with loss_args.test_custom_model_post_init is relevant to
custom classification heads and Transformers compatibility.use_cuda=False for CPU-only or
smoke runs.train_model()/eval_model()/predict() loop,
then expand epochs, metrics, outputs, and backend settings only after schema
and import issues are resolved.