mix nasty.zero_shot (Nasty v0.3.0)

View Source

Zero-shot text classification using NLI models.

Classify text into arbitrary categories without training data.

Usage

# Classify single text
mix nasty.zero_shot \
  --text "I love this product!" \
  --labels positive,negative,neutral

# Classify from file
mix nasty.zero_shot \
  --input data/texts.txt \
  --labels technology,sports,politics,business \
  --output results.json

# Multi-label classification
mix nasty.zero_shot \
  --text "Urgent: Please review the attached document" \
  --labels urgent,action_required,informational \
  --multi-label \
  --threshold 0.5

Options

  • --text - Text to classify (use this or --input)
  • --input - Path to file with texts to classify (one per line)
  • --labels - Comma-separated list of candidate labels (required)
  • --output - Output file for results (default: stdout)
  • --model - NLI model to use (default: roberta_large_mnli) Options: roberta_large_mnli, bart_large_mnli, xlm_roberta_base
  • --multi-label - Enable multi-label classification (default: false)
  • --threshold - Minimum score for multi-label (default: 0.5)
  • --hypothesis-template - Custom hypothesis template (default: "This text is about {}")

Examples

# Sentiment analysis
mix nasty.zero_shot \
  --text "The movie was boring and predictable" \
  --labels positive,negative,neutral

# Topic classification
mix nasty.zero_shot \
  --text "Bitcoin reaches new all-time high" \
  --labels technology,finance,sports,politics

# Multi-label with custom threshold
mix nasty.zero_shot \
  --text "Scientists discover new AI breakthrough" \
  --labels science,technology,healthcare,education \
  --multi-label \
  --threshold 0.3