unslothai/unsloth · error · ValueError

No 'messages' or 'conversations' or 'texts' column found.

Error message

No 'messages' or 'conversations' or 'texts' column found.

What it means

ValueError from convert_chatml_to_alpaca's row-level _convert: when no chat_column was supplied, it falls back to examples.get('messages') / 'conversations' / 'texts', and if none of the three exists the conversion has nothing to read and raises. Unlike the streaming wrappers this fires during map on any dataset kind, batch by batch.

Source

Thrown at studio/backend/utils/datasets/format_conversion.py:216

):
    """
    Convert ChatML (messages OR conversations) to Alpaca format.

    Supports:
    - "messages" or "conversations" column
    - "role"/"content" (standard) or "from"/"value" (ShareGPT)
    """
    is_iterable = is_streaming_dataset(dataset)

    def _convert(examples):
        chatml_data = examples.get(chat_column) if chat_column else None
        if chatml_data is None:
            chatml_data = (
                examples.get("messages") or examples.get("conversations") or examples.get("texts")
            )

        if chatml_data is None:
            raise ValueError("No 'messages' or 'conversations' or 'texts' column found.")

        instructions = []
        outputs = []
        inputs = []

        for convo in chatml_data:
            instruction = ""
            output = ""

            for msg in convo:
                # Standard and ShareGPT key names
                role = msg.get("role") or msg.get("from")
                content = msg.get("content") or msg.get("value")

                # First user message -> instruction
                if role in ["user", "human", "input"] and not instruction:
                    instruction = content
                # First assistant message -> output

View on GitHub (pinned to 203007d190)

Solutions

  1. Pass the real column name: convert_chatml_to_alpaca(dataset, chat_column='chat')
  2. Rename your column to a recognized name before converting: dataset.rename_column('chat', 'messages')
  3. If the dataset is already Alpaca (instruction/output), you do not need this conversion — skip it

Example fix

# before
alpaca = convert_chatml_to_alpaca(dataset)  # column named 'chat' -> raises

# after
alpaca = convert_chatml_to_alpaca(dataset, chat_column='chat')
# or: dataset = dataset.rename_column('chat', 'messages')
Defensive patterns

Strategy: validation

Validate before calling

RECOGNIZED_CHAT_COLUMNS = ("messages", "conversations", "texts")

def has_recognized_chat_column(dataset, chat_column: str | None = None) -> bool:
    if chat_column is not None:
        return chat_column in dataset.column_names
    return any(c in dataset.column_names for c in RECOGNIZED_CHAT_COLUMNS)

Type guard

def find_chatml_column(dataset) -> str | None:
    cols = set(dataset.column_names)
    for c in ("messages", "conversations", "texts"):
        if c in cols:
            return c
    return None

Prevention

When it happens

Trigger: Calling convert_chatml_to_alpaca(dataset) without chat_column when the conversation column is named something else ('chat', 'history', 'dialog'); or passing chat_column='messages' on a dataset where that column does not exist (examples.get returns None and the fallback chain also misses).

Common situations: Preprocessed datasets whose columns were renamed; converting Alpaca-format data by mistake (it has no conversation column at all); column dropped by a prior select()/remove_columns() step.

Related errors


AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15). Data as JSON: /api/errors/f5f84bd3f227de0b. Report an issue: GitHub.