# LLM Labs (beta)

{% hint style="info" %}
**Supported labeling types**: Span labelin&#x67;**,** row labelin&#x67;**,** document labeling.
{% endhint %}

You can integrate models from LLM Labs with **ML-assisted labeling**. If you have already tested and deployed an experiment in a sandbox, you can use the deployed model in your labeling workflow.

## Create a model in Sandbox

To use **ML-assisted labeling** with LLM Labs, create and deploy a model from [Sandbox](/llm-projects/sandbox.md).

{% hint style="info" %}
The model's output must be in JSON format and aligned with the label set defined in your NLP project. This ensures compatibility with regex-based string matching in the labeling system.
{% endhint %}

For example, if your label/question set includes **Category** and **Suggestion**, the expected output should look like this:

```json
{
  "Category": ["Minute of Meeting"],
  "Suggestion": ["Move the 'Issues' section to the top of the notes instead of keeping it at the bottom."]
}
```

### Instruction example for JSON output

To ensure the LLM returns the correct JSON format, structure your prompt clearly. For example:

{% code overflow="wrap" %}

````
Given the document text, please extract the following information and present it in JSON format as shown below:
- *Category*: The type of text or notes provided. Please choose one from "Minutes of Meeting," "Draft," or "Budget Plan."
- *Suggestion*: A recommendation based on best practices for creating better notes for "Minutes of Meeting," "Draft," or "Budget Plan."

Instructions Summary:
1. Extract and present the information in the specified JSON format.
2. Ensure that all extracted data is accurate and corresponds directly to the content of each document.

Return the value of extracted fields in JSON structure in plain text, following this JSON FORMAT
{
"Category": [list of Category answer],
"Suggestion": [list of Suggestion answer]
}

VERY IMPORTANT
RETURN THE ANSWER WITHOUT ```json
EXTRACT ANSWER THAT PRECISELY WRITTEN IN DOCUMENT CONTEXT
````

{% endcode %}

### Advance hyperparameters in Sandbox

You can configure advanced hyperparameters in the Sandbox. In a model, go to the three-dot menu and click **Change model settings.** From there, you can define advanced hyperparameters using [OpenAI supported schema for Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs#supported-schemas).

<figure><img src="/files/V1Efj5ykQyFx4JGVNlao" alt="Image of Hyperparameter configurations modal"><figcaption></figcaption></figure>

Example of advanced hyperparameters configuration:

{% code overflow="wrap" %}

```json
{
  "response_format": {
    "type": "json_schema",
    "json_schema": {
      "name": "question_answers",
      "schema": {
        "type": "object",
        "properties": {
          "Category": {
            "type": "string",
            "enum": [
              "Minute of Meeting",
              "Draft",
              "Budget Plan"
            ],
            "description": "The answer for question 1, which must be one of the predefined answers or null."
          },
          "Suggestion": {
            "type": "string",
            "description": "The answer for question 2, which can be any string or null."
          }
        },
        "required": [
          "Category",
          "Suggestion"
        ],
      }
    }
  }
}
```

{% endcode %}

You can focus on adjusting the `properties` and `required` objects to match your label or question set.

## Use your model in ML-assisted labeling

Follow these steps to access your deployed model in **ML-assisted labeling**:

1. Create a custom project for row labeling, span labeling, or document labeling.
2. Click the gear icon from the extension panel on the right to open the **Manage extensions** dialog.
3. Enable the **ML-assisted labeling** extension.
4. Once enabled, select **LLM Labs** as the service provider and you will see the following fields:

   <figure><img src="/files/JzsHq1kqkzkKGIBKgb91" alt="Image of ML Assisted Labeling with LLM Labs for Span Based"><figcaption><p><strong>ML-assisted labeling</strong> with LLM Labs for span labeling</p></figcaption></figure>

   <figure><img src="/files/lnlCxmhJKIzjSS63WJuY" alt="Image of ML Assisted Labeling with LLM Labs for Row Based"><figcaption><p><strong>ML-assisted labeling</strong> with LLM Labs for row labeling</p></figcaption></figure>

   <figure><img src="/files/sPSLrYJtPPPRe2Xp6wxc" alt="Image of ML Assisted Labeling with LLM Labs for Document Based"><figcaption><p><strong>ML-assisted labeling</strong> with LLM Labs for document labeling</p></figcaption></figure>

   1. **Target text:** Select the input text used as reference.
   2. **Target question**: Select the output column to predict.
   3. **Model**: Select your deployed model from [LLM Labs](https://llm.datasaur.ai/).
   4. **Target pages**: Define specific pages you want to extract from a document.

## Start prediction

Click **Predict labels** to start predicting labels with your deployed model from LLM Labs.

<figure><img src="/files/s520u1DgM4vqG46ebmFt" alt="Image of ML Assisted with LLM Labs Provider Result for Span Based"><figcaption><p><strong>ML-assisted labeling</strong> with LLM Labs in span labeling</p></figcaption></figure>

<figure><img src="/files/B1t6DDGSBrVxhUNvh59i" alt="Image of ML Assisted with LLM Labs Provider Result for Row Based"><figcaption><p><strong>ML-assisted labeling</strong> with LLM Labs in row labeling</p></figcaption></figure>

<figure><img src="/files/cAmNyDQ2Ipyr5VP8EkQc" alt="Image of ML Assisted with LLM Labs Provider Result for Document Labeling"><figcaption><p><strong>ML-assisted labeling</strong> with LLM Labs in document labeling</p></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.datasaur.ai/assisted-labeling/ml-assisted-labeling/llm-labs-beta.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
