{"record":{"id":"b6b14c8b694cc752","repo":"unslothai/unsloth","slug":"mode-title-training-requires-a-string-text-col","errorCode":null,"errorMessage":"{mode_title} training requires a string 'text' column but none was found in {split_scope} (columns: {col_names}).","messagePattern":"(.+?) training requires a string 'text' column but none was found in (.+?) \\(columns: (.+?)\\)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"studio/backend/utils/datasets/raw_text.py","lineNumber":130,"sourceCode":"\n\ndef prepare_raw_text_dataset(\n    dataset: Dataset,\n    *,\n    mode_label: str = \"raw text\",\n    split_name: str | None = None,\n    eos_token: str | None = None,\n    append_eos: bool = False,\n) -> RawTextPreparationResult:\n    notices: list[RawTextNotice] = []\n    mode_title = mode_label.capitalize()\n    split_scope = _split_scope(split_name)\n\n    col_names = resolve_column_names(dataset)\n    if \"text\" not in col_names:\n        string_cols = _string_columns(dataset)\n        if not string_cols:\n            raise ValueError(\n                f\"{mode_title} training requires a string 'text' column but none \"\n                f\"was found in {split_scope} (columns: {col_names}).\"\n            )\n\n        renamed_col = string_cols[0]\n        if len(string_cols) > 1:\n            notices.append(\n                RawTextNotice(\n                    message = (\n                        f\"{mode_title}: dataset has {len(string_cols)} string \"\n                        f\"columns ({string_cols}); auto-selecting '{renamed_col}' \"\n                        \"as the training text. Rename the intended column to \"\n                        \"'text' to override.\"\n                    ),\n                    level = \"warning\",\n                    update_status = True,\n                )\n            )","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/utils/datasets/raw_text.py#L112-L148","documentation":"Raised by raw-text preparation when the dataset has no 'text' column AND no string-typed columns exist at all to auto-select. When string columns do exist, the first is auto-selected as training text (with a notice, and a disambiguation notice if there are several); this error is the terminal case where no candidate column exists.","triggerScenarios":"Calling raw-text preparation on a dataset whose columns are all non-string (numeric features, label ids, images, lists), e.g. a pre-tokenized dataset with input_ids/attention_mask, or a pure tabular feature dataset.","commonSituations":"Loading an already-tokenized dataset (input_ids only) into a raw-text trainer; selecting a feature/embedding table dataset; datasets where text was replaced by numeric encodings during preprocessing.","solutions":["Check resolve_column_names(dataset) output (shown in the error) to see what columns actually exist.","If the dataset is pre-tokenized, use the tokenized/TRL training path instead of raw-text mode.","Load the original untokénized dataset revision and train from its string text column.","If a numeric column genuinely encodes text (e.g. byte values), convert it back to strings and rename to 'text'.","Pass a different split that contains the raw text column."],"exampleFix":"# before\nprepare_raw_text(load_dataset(\"user/pretokenized\"))  # columns: input_ids, labels -> ValueError\n\n# after\nprepare_raw_text(load_dataset(\"user/raw-corpus\"))  # columns: text -> ok","handlingStrategy":"type-guard","validationCode":"def dataset_supports_raw_text(dataset) -> bool:\n    \"\"\"True when a 'text' column or at least one string column exists.\"\"\"\n    feats = dataset.features\n    if \"text\" in feats:\n        return True\n    return any(\n        getattr(f, \"dtype\", None) == \"string\" or isinstance(f, str)\n        for f in feats.values()\n    )","typeGuard":"def has_string_column(features: dict) -> bool:\n    return any(getattr(f, \"dtype\", None) == \"string\" for f in features.values())","tryCatchPattern":"try:\n    result = prepare_raw_text(ds)\nexcept ValueError as e:\n    if \"requires a string 'text' column\" in str(e):\n        raise SystemExit(\n            f\"Dataset columns {list(ds.features)} contain no text; \"\n            \"load the untokénized source dataset.\"\n        ) from e\n    raise","preventionTips":["Inspect dataset.features before selecting raw-text training mode.","Pre-tokenized datasets (input_ids/labels) belong on the tokenized training path.","Watch for the auto-select notice naming which string column was chosen — confirm it is the intended text.","When multiple string columns exist, rename the intended one to 'text' to avoid ambiguity."],"tags":["dataset","raw-text","schema","pre-tokenized"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}