Skip to main content

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 to Taylor with Google or GitHub.

  2. Navigate to the Models page.

  3. Click Create a Model and fill in the fields.

    • MODEL NAME: Give your model a name (e.g. "sentiment_classifier", "abuse_risk_score", etc).
    • INPUT / OUTPUT: Give a high-level understanding of the inputs & outputs. The input field is the text you want to classify (e.g. user messages, Zendesk tickets, etc), and 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"
        }
  4. Click Create Model to finish creating your model.

  5. Once your model is created, test your model in the Playground. 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())