{
  "slug": "few-shot-text-classifier",
  "name": "gizza-ai/few-shot-text-classifier",
  "version": "0.1.0",
  "title": "Few-shot Text Classifier — label text from examples — gizza.ai",
  "description": "Classify text from labeled examples. Choose TF-IDF, nearest-neighbor or centroid scoring, then get predictions, confidence and explanations.",
  "tags": [
    "text classification",
    "few shot",
    "tf-idf",
    "machine learning",
    "nlp",
    "labeling",
    "classifier",
    "text analysis"
  ],
  "category": "text",
  "urls": {
    "page": "https://gizza.ai/tools/few-shot-text-classifier/",
    "markdown": "https://gizza.ai/tools/few-shot-text-classifier/index.md",
    "descriptor": "https://gizza.ai/tools/few-shot-text-classifier/tool.json",
    "deep_link_example": "https://gizza.ai/tools/few-shot-text-classifier/?examples=billing%2Cinvoice%20charge%20refund%0Abilling%2Csubscription%20payment%20failed%0Asupport%2Cpassword%20reset%20login%20issue%0Asupport%2Caccount%20locked%20cannot%20sign%20in&text=I%20cannot%20sign%20in%20after%20resetting%20my%20password.&separator=auto&input_mode=single&method=centroid&k=3&similarity=cosine&weighting=tfidf&analyzer=word&ngram_max=1&lowercase=true&strip_accents=true&remove_stopwords=true&sublinear_tf=true&min_df=1&min_confidence=0.0&top_k=3&explain=true&output=report"
  },
  "cli": "gizza tool few-shot-text-classifier \"billing,invoice charge refund\nbilling,subscription payment failed\nsupport,password reset login issue\nsupport,account locked cannot sign in\" 'text=I cannot sign in after resetting my password.'",
  "tool": {
    "description": "Classify text by similarity to a handful of user-provided labeled examples — few-shot classification with no model download, no API key and no training run. Paste a support set of one example per line as label<separator>text (separator auto-detected from tab, comma, pipe or colon), then classify one document or batch-label every line of a list. Features are word or character n-grams weighted by tf-idf, plain term frequency or presence; labels are decided by nearest centroid, similarity-weighted k nearest neighbours, or the single best-matching example, compared with cosine, dot product, euclidean distance or Jaccard overlap. Options cover case folding, accent stripping, English stop words, sublinear term frequency, a minimum document frequency, and a confidence floor below which the answer comes back as `uncertain`. Returns the predicted label, per-label similarity and confidence, the shared terms that drove the match and the nearest example, as an aligned report, JSON or CSV. Fully deterministic and runs entirely locally.",
    "parameters": {
      "additionalProperties": false,
      "properties": {
        "analyzer": {
          "default": "word",
          "description": "What a feature is. word (default) splits on non-alphanumeric characters and uses whole words. char slides a window over the text and uses character n-grams instead, which tolerates typos, inflection and languages that do not space-separate words — set ngram_max to 3-5 when you pick it.",
          "enum": [
            "word",
            "char"
          ],
          "type": "string"
        },
        "examples": {
          "description": "The labeled support set: one example per line, written as label<separator>text, for example `billing,invoice charge refund`. Two examples per label is the practical minimum and 3-8 per label is the sweet spot — this is few-shot, so a handful is enough. The first separator on a line splits the label from the text, so the text itself may contain more of them; surrounding double quotes are stripped, so a pasted two-column CSV works, and lines starting with # are treated as comments. Needs at least 2 distinct labels. Capped at 1 MiB, 5000 examples and 200 labels.",
          "type": "string"
        },
        "explain": {
          "default": true,
          "description": "Include the terms shared between the input and the winning label, ranked by how much they contributed, plus the single nearest training example and its similarity. Default true. In batch mode this becomes a compact top-terms column per row.",
          "type": "boolean"
        },
        "input_mode": {
          "default": "single",
          "description": "What text holds: single (default) classifies the whole value as one document; lines classifies every non-blank line separately and returns one row per line, for batch-labelling a list.",
          "enum": [
            "single",
            "lines"
          ],
          "type": "string"
        },
        "k": {
          "default": 3,
          "description": "How many nearest examples vote when method=knn. 3 (default) is a good starting point; 1 makes it a pure nearest-neighbour rule and larger values smooth out one-off matches. Never exceeds the number of examples you supplied. Maximum 50. Ignored by the centroid and best-match methods.",
          "maximum": 50,
          "minimum": 1,
          "type": "integer"
        },
        "lowercase": {
          "default": true,
          "description": "Fold the examples and the input to lower case before tokenizing, so `Refund` and `refund` are the same feature. Default true. Turn it off when capitalisation itself is a signal, for example ALL-CAPS shouting.",
          "type": "boolean"
        },
        "method": {
          "default": "centroid",
          "description": "How example similarities become a label decision. centroid (default) averages each label's examples into one prototype vector and compares against those — the steadiest choice with only a few examples per label. knn scores every example, keeps the k most similar overall and lets them vote weighted by similarity, which handles labels that cover several distinct topics. best-match takes each label's single closest example, so one strongly matching example is enough to win.",
          "enum": [
            "centroid",
            "knn",
            "best-match"
          ],
          "type": "string"
        },
        "min_confidence": {
          "default": 0.0,
          "description": "Confidence the winning label must reach, from 0 to 1, before it is reported as the prediction. 0 (default) always commits to the top label. Set 0.5 or 0.6 to have weak, ambiguous inputs come back as `uncertain` instead, with a note explaining which label was leading. Confidence is each label's share of the total vote weight, so it always sums to 100% across labels.",
          "maximum": 1,
          "minimum": 0,
          "type": "number"
        },
        "min_df": {
          "default": 1,
          "description": "Minimum number of examples a term must appear in to stay in the vocabulary. 1 (default) keeps everything, which is usually right for a few-shot support set; 2 drops terms that appear in only one example and shrinks the vocabulary. Maximum 100. If it would empty the vocabulary you get an error instead.",
          "maximum": 100,
          "minimum": 1,
          "type": "integer"
        },
        "ngram_max": {
          "default": 1,
          "description": "Longest n-gram used as a feature. With analyzer=word this includes every length from 1 up to this value, so 1 (default) is a plain bag of words and 2 also learns adjacent pairs such as `password reset`. With analyzer=char it is the exact character-window length, where 3-5 works best. Maximum 6.",
          "maximum": 6,
          "minimum": 1,
          "type": "integer"
        },
        "output": {
          "default": "report",
          "description": "Output format: report (default) is an aligned human-readable summary with the prediction, label scores, explanation, settings and training statistics; json is the same information as a machine-readable object; csv is one row per classified text with text, prediction, confidence, similarity and top terms, for pasting into a spreadsheet.",
          "enum": [
            "report",
            "json",
            "csv"
          ],
          "type": "string"
        },
        "remove_stopwords": {
          "default": false,
          "description": "Drop common English function words (the, and, is, to, …) before features are formed. Default false, because with few examples every word carries signal. Turn it on for topic classification of longer English documents.",
          "type": "boolean"
        },
        "separator": {
          "default": "auto",
          "description": "How each example line is split into label and text: auto (default — picks whichever of tab, comma, pipe or colon appears on the most lines), or force one of tab, comma, pipe, colon. Force it when your example text contains the auto-detected character more often than the labels do.",
          "enum": [
            "auto",
            "tab",
            "comma",
            "pipe",
            "colon"
          ],
          "type": "string"
        },
        "similarity": {
          "default": "cosine",
          "description": "How two feature vectors are compared. cosine (default) measures angle only, so long and short texts compare fairly. dot is the raw dot product, which rewards longer texts with more matching terms. euclidean is straight-line distance reported as 1/(1+distance), so it is always above zero even with nothing in common. jaccard compares term sets only — shared terms over total distinct terms — and ignores the weighting setting. Every metric is reported so that higher means more similar.",
          "enum": [
            "cosine",
            "dot",
            "euclidean",
            "jaccard"
          ],
          "type": "string"
        },
        "strip_accents": {
          "default": false,
          "description": "Fold accented Latin letters onto their ASCII base (café → cafe, straße → strasse) before tokenizing, so accented and unaccented spellings match. Default false. Turn it on for European-language text that is typed inconsistently.",
          "type": "boolean"
        },
        "sublinear_tf": {
          "default": false,
          "description": "Replace the raw term frequency with 1 + ln(count), so a word repeated ten times counts a little more than one repeated once instead of ten times as much. Default false. Turn it on for longer documents with repetitive vocabulary.",
          "type": "boolean"
        },
        "text": {
          "description": "The text to classify against the support set. With input_mode=single the whole value is one document; with input_mode=lines each non-blank line is classified separately. Capped at 256 KiB and 1000 batch lines.",
          "type": "string"
        },
        "top_k": {
          "default": 3,
          "description": "How many of the highest-scoring labels to list with their similarity and confidence. Default 3; 0 lists every label. Maximum 50. The prediction itself is always the top label regardless of this setting.",
          "maximum": 50,
          "minimum": 0,
          "type": "integer"
        },
        "weighting": {
          "default": "tfidf",
          "description": "How term counts become feature weights. tfidf (default) multiplies the term frequency by a smoothed inverse document frequency, so words common to every example count for less and distinctive words dominate. tf uses the raw counts. binary uses presence/absence only, which suits very short texts such as titles or search queries.",
          "enum": [
            "tfidf",
            "tf",
            "binary"
          ],
          "type": "string"
        }
      },
      "required": [
        "examples",
        "text"
      ],
      "type": "object"
    }
  }
}