# Text Classification

{% embed url="<https://youtu.be/-blQVbccAF0>" %}
Natural Language Processing with Clarifai
{% endembed %}

Text models can be trained to understand the meaning of text passages. We offer a general text embedding model, as well as a specialized text moderation model. This walkthrough shows you how to create a custom text model from our text embedding model.

## Create an app

Create a new application and select “Text” as your default workflow.

![](/files/-MC8ZhMLq5tI81-KmRuw)

## Navigate to Explorer Mode

![](/files/-MC8ZhMNrgbTNdOCgk7f)

## Add your inputs

### Option 1: Browse your files

You can upload your text directly from a `.csv` file. This means you can work with your favorite spreadsheet software or text editor when preparing your data for upload. Just use the provided "CSV template" to get started.

![](/files/-MC8ZhMSCzwsxhUoJOtZ)

Next, add your text data. At a minimum, you should add text to the `input.data.text.raw` field. You can add one concept per column to the `input.data.concepts[*].id` fields. For the `input.data.concepts[*].value` column, there are two options: enter the number `1` if the concept *is* present in the input, enter the value `0` if the concept is *not* present in the input (a negative example). If no value is entered, a default value of `1` will be assigned to your input.

You can add columns for as many concepts as you like, and you can add new columns to add values for any other values supported by the API:

| Field                               | Description                                                                       |
| ----------------------------------- | --------------------------------------------------------------------------------- |
| input.id                            | A unique identifier for your input                                                |
| input.data.text.raw                 | The "text" for your input                                                         |
| input.data.concepts\[i].id          | Your custom concept                                                               |
| input.data.concepts\[i].value       | The value for your custom concept (`1` for true, `0` for false)                   |
| input.metadata                      | Any additional metadata in valid [JSON](https://www.json.org/json-en.html) format |
| input.data.geo.geo\_point.latitude  | Latitude for geodata                                                              |
| input.data.geo.geo\_point.longitude | Longitude for geodata                                                             |

Finally, you will need to save your work as a `.csv` file. If you are editing in Google Sheets, go to File >>> Download >>> Comma-separated values (.csv, current sheet). If you are using Excel, go to File >>> Save As >>> Browse >>> Save as Type >>> CSV.

Once you have downloaded the `.csv` file, you can then upload it by clicking on “Browse your files”

### Option 2: Add text

Just click “add text” and directly enter your text in the text field.

Label your inputs If you “add text” you will need to then label your inputs in Portal.

![](/files/-MC8ZhMW5D1vnkBflKrr)

#### Add custom concepts

Click on an input and add new concepts in the right hand sidebar. Just click in the empty form field under “Custom Model Predictions”, enter your concept, and hit “return”.

![](/files/-MC8ZhMYwVuUSxucuPkX)

## Navigate to Model Mode

![](/files/-MQShJbYIrQKRSjzAMec)

## Select Context-based Classifier

![](/files/-MC8ZhMaSp4nSxAANcqQ)

* **MODEL ID (OPTIONAL)** - Optional custom model ID of your choosing.
* **DISPLAY NAME** - This is the name of your new custom model. Enter a descriptive name.
* **OUTPUT\_INFO.DATA.CONCEPTS** - Click in the empty form field and select all of the custom concepts that you have added one-by-one.
* **OUTPUT\_INFO.OUTPUT\_CONFIG.CONCEPTS\_MUTUALLY\_EXCLUSIVE** - Use the default setting.
* **OUTPUT\_INFO.OUTPUT\_CONFIG.CLOSED\_ENVIRONMENT** - Set CLOSED\_ENVIRONMENT to “Yes”.
* **OUTPUT\_INFO.OUTPUT\_CONFIG.EMBED\_MODEL\_VERSION\_ID** - Use the default setting.

Once you click “Create Model”, a new screen will appear.

Click “Train Model” in the upper right hand corner of the screen.

## Try out your new model

Navigate to “Explorer Mode” and “Add Inputs”. Add some new text inputs, and then navigate back to “Explorer Mode”

You will see custom concept predictions in the right hand sidebar when you click on an individual input.


---

# 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://old-docs.clarifai.com/guide/v7.0/how-to/portal/custom-text-walkthrough.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.
