File size: 6,107 Bytes
33d4721
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# Understanding Column Mapping

Column mapping is a critical setup process in AutoTrain that informs the system 
about the roles of different columns in your dataset. Whether it's a tabular 
dataset, text classification data, or another type, the need for precise 
column mapping ensures that AutoTrain processes each dataset element correctly.

## How Column Mapping Works

AutoTrain has no way of knowing what the columns in your dataset represent. 
AutoTrain requires a clear understanding of each column's function within 
your dataset to train models effectively. This is managed through a 
straightforward mapping system in the user interface, represented as a dictionary. 
Here's a typical example:

```
{"text": "text", "label": "target"}
```

In this example, the `text` column in your dataset corresponds to the text data 
AutoTrain uses for processing, and the `target` column is treated as the 
label for training.

But let's not get confused! AutoTrain has a way to understand what each column in your dataset represents.
If your data is already in AutoTrain format, you dont need to change column mappings.
If not, you can easily map the columns in your dataset to the correct AutoTrain format.

In the UI, you will see column mapping as a dictionary:

```
{"text": "text", "label": "target"}
```

Here, the column `text` in your dataset is mapped to the AutoTrain column `text`, 
and the column `target` in your dataset is mapped to the AutoTrain column `label`.

Let's say you are training a text classification model and your dataset has the following columns:

```
full_text, target_sentiment
"this movie is great", positive
"this movie is bad", negative
```

You can map these columns to the AutoTrain format as follows:

```
{"text": "full_text", "label": "target_sentiment"}
```

If your dataset has the columns: `text` and `label`, you don't need to change the column mapping.

Let's take a look at column mappings for each task:

## LLM

Note: For all LLM tasks, if the text column(s) is not formatted i.e. if contains samples in chat format (dict or json), then you 
should use `chat_template` parameter. Read more about it in LLM Parameters Section.


### SFT / Generic Trainer

```
{"text": "text"}
```

`text`: The column in your dataset that contains the text data.


### Reward Trainer

```
{"text": "text", "rejected_text": "rejected_text"}
```

`text`: The column in your dataset that contains the text data.

`rejected_text`: The column in your dataset that contains the rejected text data.

### DPO / ORPO Trainer

```
{"prompt": "prompt", "text": "text", "rejected_text": "rejected_text"}
```

`prompt`: The column in your dataset that contains the prompt data.

`text`: The column in your dataset that contains the text data.

`rejected_text`: The column in your dataset that contains the rejected text data.


## Text Classification & Regression, Seq2Seq

For text classification and regression, the column mapping should be as follows:

```
{"text": "dataset_text_column", "label": "dataset_target_column"}
```

`text`: The column in your dataset that contains the text data.

`label`: The column in your dataset that contains the target variable.


## Token Classification


```
{"text": "tokens", "label": "tags"}
```

`text`: The column in your dataset that contains the tokens. These tokens must be a list of strings.

`label`: The column in your dataset that contains the tags. These tags must be a list of strings.

For token classification, if you are using a CSV, make sure that the columns are stringified lists.

## Tabular Classification & Regression

```
{"id": "id", "label": ["target"]}
```

`id`: The column in your dataset that contains the unique identifier for each row.

`label`: The column in your dataset that contains the target variable. This should be a list of strings.

For a single target column, you can pass a list with a single element.

For multiple target columns, e.g. a multi label classification task, you can pass a list with multiple elements.


# Image Classification

For image classification, the column mapping should be as follows:

```
{"image": "image_column", "label": "label_column"}
```

Image classification requires column mapping only when you are using a dataset from Hugging Face Hub.
For uploaded datasets, leave column mapping as it is.

# Sentence Transformers

For all sentence transformers tasks, one needs to map columns to `sentence1_column`, `sentence2_column`, `sentence3_column` & `target_column` column.
Not all columns need to be mapped for all trainers of sentence transformers.

## `pair`:

```
{"sentence1_column": "anchor", "sentence2_column": "positive"}
```

## `pair_class`:

```
{"sentence1_column": "premise", "sentence2_column": "hypothesis", "target_column": "label"}
```

## `pair_score`:

```
{"sentence1_column": "sentence1", "sentence2_column": "sentence2", "target_column": "score"}
```

## `triplet`:

```
{"sentence1_column": "anchor", "sentence2_column": "positive", "sentence3_column": "negative"}
```

## `qa`:

```
{"sentence1_column": "query", "sentence2_column": "answer"}
```


# Extractive Question Answering

For extractive question answering, the column mapping should be as follows:

```
{"text": "context", "question": "question", "answer": "answers"}
```

where `answer` is a dictionary with keys `text` and `answer_start`.


## Ensuring Accurate Mapping

To ensure your model trains correctly:

- Verify Column Names: Double-check that the names used in the mapping dictionary accurately reflect those in your dataset.

- Format Appropriately: Especially in token classification, ensure your data format matches expectations (e.g., lists of strings).

- Update Mappings for New Datasets: Each new dataset might require its unique mappings based on its structure and the task at hand.

By following these guidelines and using the provided examples as templates, 
you can effectively instruct AutoTrain on how to interpret and handle your 
data for various machine learning tasks. This process is fundamental for 
achieving optimal results from your model training endeavors.