Documentation  
Custom Classifiers

Custom Models

Taylor allows you to build and deploy your own custom classification models. Define your own labels and get back your own model.

Below is a comprehensive guide to building your custom classification models.

Getting Started

To create a custom model, follow the below steps:

  1. Sign in (opens in a new tab) to Taylor with Google, Microsoft, or GitHub.
  2. Navigate to the Custom Models (opens in a new tab) page.
  3. Click + New Model and fill in the fields.

Create Classifier

  • MODEL TYPE: Select Classifier.
  • MODEL NAME: Give your model a name (e.g. "sentiment_classifier", "abuse_risk_score", etc).
  • CLASSIFIER INPUT: Give a high-level understanding of the inputs. The input field is the text you want to classify (e.g. user messages, Zendesk tickets, etc).
  • CLASSIFIER OUTPUT: Give a high-level understanding of the outputs. The output field is the type of label (e.g. sentiment, topic, 1 - 5 fraud risk score, etc).
  • LABELS: Define the labels as a dict. Please note descriptions for each label are not required. If you do not want to provide descriptions, use an empty string "".
    • For example, if you are building a sentiment classifier, you might have labels like "positive", "negative", "neutral", and "no sentiment". If you are building a topic classifier, you might have labels like "sports", "politics", "technology". You may provide up to 200 labels.
      {
        "positive": "includes approval, support, like, satisfaction, happiness",
        "negative": "includes disapproval, criticism, dislike, disappointment, anger, sadness",
        "neutral": "balanced, indifferent, some positive and some negative, conflicted, factual",
        "no sentiment": "no sentiment expressed, factual, neutral, objective, informative"
      }
  • UNLABELED DATA: You may optionally provide unlabeled data. The data should be in the format of a list of dicts, where each dict has a text key and a label key. The label key should be the label you want to assign to the text. For example:
    [
      {"text": "I love this product!", "label": "positive"},
      {"text": "I hate this product!", "label": "negative"},
      {"text": "This product is okay.", "label": "neutral"},
      {"text": "This product is a waste of money.", "label": "negative"}
    ]
  1. Click Submit to finish creating your model.
  2. Once your model is created, test your model in the Playground (opens in a new tab). When you're ready to integrate the model in your production environment, use the below sample code to make requests to your model.

API Request

To make a request to your custom model, make a POST request with the following parameters:

Required Parameters

  • model (string): The name of your model. This is case sensitive.
  • texts (list of strings): The text you want to classify. You can provide multiple texts in a single request. Each text should be a string. The maximum number of texts you can provide in a single request is 20.

Optional Parameters

  • threshold (float, default=0.1): The minimum score required for a label to be included in the response. The threshold should be a float between 0 and 1. The right threshold depends on your use case. If you set a high threshold, you may not get any labels.
  • top_k (int, default=10): The maximum number of labels to return for each text segment. top_k is applied after the threshold filter, so you are not guaranteed to get k labels unless you set the threshold to 0.
  • prefix (string, default=""): When provided, labels will be filtered to only include those that start with the prefix. This is useful for models that return hierarchical labels, as you can specify to only classify within a predetermined domain. For example, if you are classifying medical texts with our Topics Classifier, you can set the prefix to "/health" to only get the topic labels related to Health.

Sample Request

import requests
api_key = "xx-your-api-key-here"
 
res = requests.post(
    "https://api.trytaylor.ai/api/private_classifiers/predict",
    headers={"Authorization": f"Bearer {api_key}"},
    json={
        "model": "xx-your-model-name-here",
        "texts": [
            "What is the capital of France?",
            "walking dead season 4 best episodes",
            "Write a Python function to print the first 10 Fibonacci numbers.",
        ],
        "threshold": 0.05,
        "top_k": 3
    }
)
 
print(res.json())