Custom API

Supported Labeling Types: Span Labeling, Row Labeling, Bounding Box Labeling , Document labeling

We also support Custom API in case you want to use your own model for ML-assisted labeling by simply providing the API URL. Ensure your custom API follows the required request structure to integrate smoothly with the Datasaur platform. Here’s how to set it up:

Setting Up Your Custom API for ML-Assisted Labeling

  1. Create an API: Build an API for your model that adheres to a specific request and response format compatible with the Datasaur App. For guidance, refer to the API Creation Example.

  2. Request and Response Structure: You can find example request and response body near the API URL input field or in the examples below.

  3. Entering Your API URL: Once your API is ready, fill in the API URL in the designated field under the extension.

  4. For Span Based project

    1. Sentences per request (0 = all): Determine how many text you want to include in 1 request to your API service.

  5. For Row Based project

    1. Target Text: Choose the text input that your model will use as a reference.

    2. Target Question: Select the output column your model will predict.

    3. Faster Prediction Speed: Optionally, toggle this feature to run predictions faster via the backend.

  6. Confidence Score: Adjust the value according to your needs.

  7. Apply Labels: After setting up, click "Predict Labels" to automatically apply labels to your document based on your model's predictions.

Custom API for Span Based

Image of ML Assisted with Custom API for Span Based
ML Assisted with Custom API for Span Based
Request Body
{
    "id": "[project_id]",
    "name": "[project_name]",
    "documents": [
      {
        "id": "[document_id_1]",
        "sentences": [
          {
            "id": 0, // zero-based line number of the document
            "text": "first message",
            "metadata": []
          },
          {
            "id": 1,
            "text": "first message",
            "metadata": []
          },
        ]
      }
    ]
  }
Response Body
{
  "id": "[project_id]",
  "documents": [
    {
      "id": "[document_id_1]",
      "labels": [
        {
          "id": 0,
          "entities": [
            {
              "label": "LOCATION",
              "start_char": 10,
              "end_char": 18,
              "layer": 0
            },
            {
              "label": "PERSON",
              "start_char": 20,
              "end_char": 29,
              "layer": 1
            },
          ]
        },
        {
          "id": 1,
          "entities": []
        }
      ]
    }
  ]
}

Custom API for Row Based

Image of ML Assisted with Custom API for Row Based
ML Assisted with Custom API for Row Based
Request Body
[
  { "id": 0, "text": "I feel good." },
  { "id": 1, "text": "I don't like it." }
]
Response Body
[
  { "id": 0, "label": "POSITIVE" },
  { "id": 1, "label": "NEGATIVE" }
]

Custom API for Bounding Box Labeling

Image of ML Assisted with Custom API for Bounding Box Labeling
ML Assisted with Custom API for Bounding Box Labeling
Request Body
{
    "document": {
      "id": "[document_id_1]",
      "presignedURL": "[document_presigned_url]",
    },
    "readingResult": [
      {
        "id":"[bbox_id_1]",
        "label": "O",
        "caption": "First"
        "shapes": [
          {
            "pageIndex": 0,
            "points": [
                {
                  "x": 211.51411561127316,
                  "y": 99.08677657682311
                },
                {
                  "x": 266.385241834969,
                  "y": 99.08677657682311
                },
                {
                  "x": 266.385241834969,
                  "y": 105.74680188808318
                },
                {
                  "x": 211.51411561127316,
                  "y": 105.74680188808318
                }
              ]
            }
          }
        ]
      },
      {
        "id":"[bbox_id_2]",
        "label": "O",
        "caption": "Message"
        "shapes": [
          {
            "pageIndex": 0,
            "points": [
                {
                  "x": 269.38763779813405,
                  "y": 99.09397660418664
                },
                {
                  "x": 318.98117111775315,
                  "y": 99.09397660418664
                },
                {
                  "x": 318.98117111775315,
                  "y": 105.73240183335614
                },
                {
                  "x": 269.38763779813405,
                  "y": 105.73240183335614
                }
              ]
            }
          }
        ]
      }
    ]
  }
Response Body
{
    "id": "[document_id_1]",
    "labels": [
      {
        "id":"[bbox_id_1]",
        "label": "LOCATION",
        "caption": "First",
        "confidence_score": 0.90,
        "shapes": [
          {
            "pageIndex": 0,
            "points": [
              {
                "x": 211.51411561127316,
                "y": 99.08677657682311
              },
              {
                "x": 266.385241834969,
                "y": 99.08677657682311
              },
              {
                "x": 266.385241834969,
                "y": 105.74680188808318
              },
              {
                "x": 211.51411561127316,
                "y": 105.74680188808318
              }
            ]
          }
        ]
      },
      {
        "id":"[bbox_id_2]",
        "label": "PERSON",
        "caption": "Message",
        "confidence_score": 0.90,
        "shapes": [
          {
            "pageIndex": 0,
            "points": [
              {
                "x": 269.38763779813405,
                "y": 99.09397660418664
              },
              {
                "x": 318.98117111775315,
                "y": 99.09397660418664
              },
              {
                "x": 318.98117111775315,
                "y": 105.73240183335614
              },
              {
                "x": 269.38763779813405,
                "y": 105.73240183335614
              }
            ]
          }
        ]
      }
    ]
  }

Custom API for Document Based

ML Assisted with Custom API for Document Based
Request Body
{
  "document": {
    "id": "[document_id_1]",
    "presignedURL": "[document_presigned_url]"
  }
}
Response Body
{
  "id": "[document_id_1]",
  "[your_document_question_a]": "POSITIVE",
  "[your_document_question_b_with_multiple_answer]": ["NEWS", "ARTICLE"]
}

Last updated