# Column Mapping in Autotrain

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcolumn-mapping-in-autotrain%2F149786%3E%5C
**Category:** 🤗AutoTrain\
**Created:** [April 10, 2025, 12:55pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcolumn-mapping-in-autotrain%2F149786 "2025-04-10T12:55:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nitinmahawadiwar](https://avatars.discourse-cdn.com/v4/letter/n/ec9cab/32.png) [@nitinmahawadiwar](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnitinmahawadiwar)%5C
**Post date:** [April 10, 2025, 12:55pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcolumn-mapping-in-autotrain%2F149786%2F1 "2025-04-10T12:55:18Z")

</div>

Hello,  
can someone help me to understand the Column Mapping field.  
Created a new space, selected base model as meta-llama/CodeLlama-7b-hf (Custom)  
I have a training dataset as “prompt”,“completion” in CSV format. The csv is having specil trainings with snowflake sql.  
Selected the training dataset (for now I am trying with 60 till the error resolves).  
When I click on Start training, its giving me 500 error with following logs.

any help would be appreciated. !!!

Logs:=====  
KeyError: ‘{“text”: “prompt”, “label”: “completion”}’

raise KeyError(key) from err

File “/app/env/lib/python3.10/site-packages/pandas/core/indexes/base.py”, line 3812, in get\_loc

indexer = self.columns.get\_loc(key)

File “/app/env/lib/python3.10/site-packages/pandas/core/frame.py”, line 4102, in **getitem**

train\_df.loc[:, “autotrain\_text”] = train\_df[self.text\_column]

File “/app/env/lib/python3.10/site-packages/autotrain/preprocessor/text.py”, line 399, in prepare\_columns

train\_df, valid\_df = self.prepare\_columns(train\_df, valid\_df)

File “/app/env/lib/python3.10/site-packages/autotrain/preprocessor/text.py”, line 417, in prepare

return preprocessor.prepare()

File “/app/env/lib/python3.10/site-packages/autotrain/dataset.py”, line 677, in prepare

data\_path = dset.prepare()

File “/app/env/lib/python3.10/site-packages/autotrain/app/ui\_routes.py”, line 673, in handle\_form

return await dependant.call(\*\*values)

File “/app/env/lib/python3.10/site-packages/fastapi/routing.py”, line 212, in run\_endpoint\_function

raw\_response = await run\_endpoint\_function(

File “/app/env/lib/python3.10/site-packages/fastapi/routing.py”, line 301, in app

response = await f(request)

File “/app/env/lib/python3.10/site-packages/starlette/routing.py”, line 73, in app

await app(scope, receive, sender)

File “/app/env/lib/python3.10/site-packages/starlette/\_exception\_handler.py”, line 42, in wrapped\_app

raise exc

File “/app/env/lib/python3.10/site-packages/starlette/\_exception\_handler.py”, line 53, in wrapped\_app

await wrap\_app\_handling\_exceptions(app, request)(scope, receive, send)

File “/app/env/lib/python3.10/site-packages/starlette/routing.py”, line 76, in app

await self.app(scope, receive, send)

File “/app/env/lib/python3.10/site-packages/starlette/routing.py”, line 288, in handle

await route.handle(scope, receive, send)

File “/app/env/lib/python3.10/site-packages/starlette/routing.py”, line 735, in app

await self.middleware\_stack(scope, receive, send)

File “/app/env/lib/python3.10/site-packages/starlette/routing.py”, line 715, in **call**

await app(scope, receive, sender)

File “/app/env/lib/python3.10/site-packages/starlette/\_exception\_handler.py”, line 42, in wrapped\_app

raise exc

File “/app/env/lib/python3.10/site-packages/starlette/\_exception\_handler.py”, line 53, in wrapped\_app

await wrap\_app\_handling\_exceptions(self.app, conn)(scope, receive, send)

File “/app/env/lib/python3.10/site-packages/starlette/middleware/exceptions.py”, line 62, in **call**

await self.app(scope, receive, send\_wrapper)

File “/app/env/lib/python3.10/site-packages/starlette/middleware/sessions.py”, line 85, in **call**

await self.app(scope, receive, \_send)

File “/app/env/lib/python3.10/site-packages/starlette/middleware/errors.py”, line 165, in **call**

raise exc

File “/app/env/lib/python3.10/site-packages/starlette/middleware/errors.py”, line 187, in **call**

await self.middleware\_stack(scope, receive, send)

File “/app/env/lib/python3.10/site-packages/starlette/applications.py”, line 113, in **call**

await super(). **call** (scope, receive, send)

File “/app/env/lib/python3.10/site-packages/fastapi/applications.py”, line 1054, in **call**

return await self.app(scope, receive, send)

File “/app/env/lib/python3.10/site-packages/uvicorn/middleware/proxy\_headers.py”, line 60, in **call**

result = await app( # type: ignore[func-returns-value]

File “/app/env/lib/python3.10/site-packages/uvicorn/protocols/http/h11\_impl.py”, line 403, in run\_asgi

Traceback (most recent call last):

The above exception was the direct cause of the following exception:

KeyError: ‘{“text”: “prompt”, “label”: “completion”}’

File “pandas/\_libs/hashtable\_class\_helper.pxi”, line 7089, in pandas.\_libs.hashtable.PyObjectHashTable.get\_item

File “pandas/\_libs/hashtable\_class\_helper.pxi”, line 7081, in pandas.\_libs.hashtable.PyObjectHashTable.get\_item

File “index.pyx”, line 196, in pandas.\_libs.index.IndexEngine.get\_loc

File “index.pyx”, line 167, in pandas.\_libs.index.IndexEngine.get\_loc

return self.\_engine.get\_loc(casted\_key)

File “/app/env/lib/python3.10/site-packages/pandas/core/indexes/base.py”, line 3805, in get\_loc

Traceback (most recent call last):

ERROR: Exception in ASGI application

INFO | 2025-04-10 09:40:56 | autotrain.app.ui\_routes:handle\_form:657 - Column mapping: {‘text’: ‘{“text”: “prompt”, “label”: “completion”}’}

INFO | 2025-04-10 09:40:56 | autotrain.app.ui\_routes:handle\_form:656 - Task: lm\_training

INFO | 2025-04-10 09:40:55 | autotrain.app.ui\_routes:handle\_form:540 - hardware: local-ui

INFO | 2025-04-10 09:38:47 | autotrain.app.ui\_routes:fetch\_params:415 - Task: llm:sft

INFO: 10.16.39.194:8520 - “GET / HTTP/1.1” 307 Temporary Redirect

INFO: 10.16.39.194:8520 - “GET /auth?code=fpUZnHXFMhiMrFxj&state=WDcu9dn7fUrvKpoO55yf0EGFza5REh HTTP/1.1” 307 Temporary Redirect

INFO: 10.16.10.93:40761 - “GET /login/huggingface?\_\_sign=eyJhbGciOiJFZERTQSJ9.eyJyZWFkIjp0cnVlLCJwZXJtaXNzaW9ucyI6eyJyZXBvLmNvbnRlbnQucmVhZCI6dHJ1ZX0sIm9uQmVoYWxmT2YiOnsia2luZCI6InVzZXIiLCJfaWQiOiI2N2RhODdkYjE1YjVjMjUyMmFlNWUwYmEiLCJ1c2VyIjoibml0aW5tYWhhd2FkaXdhciJ9LCJpYXQiOjE3NDQyNzc5MTAsInN1YiI6Ii9zcGFjZXMvbml0aW5tYWhhd2FkaXdhci9hdXRvdHJhaW5lZC1jb2RlbGxhbWE3YiIsImV4cCI6MTc0NDM2NDMxMCwiaXNzIjoiaHR0cHM6Ly9odWdnaW5nZmFjZS5jbyJ9.3C8BCuYZU4XIQzaW4qXSRDoUrUqauB9\_1YcUFkKV\_\_9fUHj6OVpS\_xkECJ4F-ihZNMHTnn19oWFgNTRv-dKCAw HTTP/1.1” 302 Found

ERROR | 2025-04-10 09:38:32 | autotrain.app

INFO | 2025-04-10 09:38:47 | autotrain.app.ui\_routes:fetch\_params:415 - Task: llm:sft

INFO: 10.16.39.194:8520 - “GET / HTTP/1.1” 307 Temporary Redirect

INFO: 10.16.39.194:8520 - “GET /auth?code=fpUZnHXFMhiMrFxj&state=WDcu9dn7fUrvKpoO55yf0EGFza5REh HTTP/1.1” 307 Temporary Redirect

INFO: 10.16.10.93:40761 - “GET /login/huggingface?\_\_sign=eyJhbGciOiJFZERTQSJ9.eyJyZWFkIjp0cnVlLCJwZXJtaXNzaW9ucyI6eyJyZXBvLmNvbnRlbnQucmVhZCI6dHJ1ZX0sIm9uQmVoYWxmT2YiOnsia2luZCI6InVzZXIiLCJfaWQiOiI2N2RhODdkYjE1YjVjMjUyMmFlNWUwYmEiLCJ1c2VyIjoibml0aW5tYWhhd2FkaXdhciJ9LCJpYXQiOjE3NDQyNzc5MTAsInN1YiI6Ii9zcGFjZXMvbml0aW5tYWhhd2FkaXdhci9hdXRvdHJhaW5lZC1jb2RlbGxhbWE3YiIsImV4cCI6MTc0NDM2NDMxMCwiaXNzIjoiaHR0cHM6Ly9odWdnaW5nZmFjZS5jbyJ9.3C8BCuYZU4XIQzaW4qXSRDoUrUqauB9\_1YcUFkKV\_\_9fUHj6OVpS\_xkECJ4F-ihZNMHTnn19oWFgNTRv-dKCAw HTTP/1.1” 302 Found

ERROR | 2025-04-10 09:38:32 | autotrain.app.ui\_routes:load\_index:381 - Failed to get user and orgs: object of type ‘\_TemplateResponse’ has no len()

INFO: 10.16.10.93:31173 - “GET /?\_\_sign=eyJhbGciOiJFZERTQSJ9.eyJyZWFkIjp0cnVlLCJwZXJtaXNzaW9ucyI6eyJyZXBvLmNvbnRlbnQucmVhZCI6dHJ1ZX0sIm9uQmVoYWxmT2YiOnsia2luZCI6InVzZXIiLCJfaWQiOiI2N2RhODdkYjE1YjVjMjUyMmFlNWUwYmEiLCJ1c2VyIjoibml0aW5tYWhhd2FkaXdhciJ9LCJpYXQiOjE3NDQyNzc5MTAsInN1YiI6Ii9zcGFjZXMvbml0aW5tYWhhd2FkaXdhci9hdXRvdHJhaW5lZC1jb2RlbGxhbWE3YiIsImV4cCI6MTc0NDM2NDMxMCwiaXNzIjoiaHR0cHM6Ly9odWdnaW5nZmFjZS5jbyJ9.3C8BCuYZU4XIQzaW4qXSRDoUrUqauB9\_1YcUFkKV\_\_9fUHj6OVpS\_xkECJ4F-ihZNMHTnn19oWFgNTRv-dKCAw HTTP/1.1” 307 Temporary Redirect

INFO: Uvicorn running on [http://0.0.0.0:7860](http://0.0.0.0:7860) (Press CTRL+C to quit)

INFO: Application startup complete.

INFO: Waiting for application startup.

INFO: Started server process [61]

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [April 11, 2025, 4:26am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcolumn-mapping-in-autotrain%2F149786%2F2 "2025-04-11T04:26:32Z")

</div>

Hmm… @abhishek

> **[KeyError 500 · huggingface autotrain-advanced · Discussion #871](https://github.com/huggingface/autotrain-advanced/discussions/871)**
>
> I would love to be using AutoTrain / Huggingface for finetuning... but have hit a block. A couple of us have been attempting to run finetuning, but have hit the KeyError 500, repeatedly. We have wa...

> <https://github.com/huggingface/autotrain-advanced/issues/226>
>
> I tried to execute the following command,
> \`\`\`
> autotrain llm --train --project\_…name my-llm --model meta-llama/Llama-2-7b-hf --data\_path ./ --use\_peft --use\_int4 --learning\_rate 2e-4 --train\_batch\_size 12 --num\_train\_epochs 3 --trainer sft
> \`\`\`
> but I keep getting a 'key error'.
> \`\`\`
> \> ERROR train has failed due to an exception:
> \> ERROR Traceback (most recent call last):
> File "/home/liang/miniconda3/envs/huggingface/lib/python3.10/site-packages/autotrain/utils.py", line 280, in wrapper
> return func(\*args, \*\*kwargs)
> File "/home/liang/miniconda3/envs/huggingface/lib/python3.10/site-packages/autotrain/trainers/clm/\_\_main\_\_.py", line 297, in train
> trainer.train()
> File "/home/liang/miniconda3/envs/huggingface/lib/python3.10/site-packages/transformers/trainer.py", line 1555, in train
> return inner\_training\_loop(
> File "/home/liang/miniconda3/envs/huggingface/lib/python3.10/site-packages/transformers/trainer.py", line 1815, in \_inner\_training\_loop
> for step, inputs in enumerate(epoch\_iterator):
> File "/home/liang/miniconda3/envs/huggingface/lib/python3.10/site-packages/accelerate/data\_loader.py", line 556, in \_\_iter\_\_
> next\_batch, next\_batch\_info = self.\_fetch\_batches(main\_iterator)
> File "/home/liang/miniconda3/envs/huggingface/lib/python3.10/site-packages/accelerate/data\_loader.py", line 519, in \_fetch\_batches
> batches.append(next(iterator))
> File "/home/liang/miniconda3/envs/huggingface/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 633, in \_\_next\_\_
> data = self.\_next\_data()
> File "/home/liang/miniconda3/envs/huggingface/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 677, in \_next\_data
> data = self.\_dataset\_fetcher.fetch(index) # may raise StopIteration
> File "/home/liang/miniconda3/envs/huggingface/lib/python3.10/site-packages/torch/utils/data/\_utils/fetch.py", line 32, in fetch
> data.append(next(self.dataset\_iter))
> File "/home/liang/miniconda3/envs/huggingface/lib/python3.10/site-packages/trl/trainer/utils.py", line 464, in \_\_iter\_\_
> buffer.append(self.formatting\_func(next(iterator)))
> File "/home/liang/miniconda3/envs/huggingface/lib/python3.10/site-packages/trl/trainer/utils.py", line 440, in \<lambda\>
> self.formatting\_func = lambda x: x\[dataset\_text\_field\]
> KeyError: 'text'
> \`\`\`
> My dataset looks like below:
> \`\`\`
> text, label
> 12345, 1
> \`\`\`
