unslothai/unsloth · error · ValueError
{mode_title} training requires a string 'text' column but no
Error message
{mode_title} training requires a string 'text' column but none was found in {split_scope} (columns: {col_names}). What it means
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.
Source
Thrown at studio/backend/utils/datasets/raw_text.py:130
def prepare_raw_text_dataset(
dataset: Dataset,
*,
mode_label: str = "raw text",
split_name: str | None = None,
eos_token: str | None = None,
append_eos: bool = False,
) -> RawTextPreparationResult:
notices: list[RawTextNotice] = []
mode_title = mode_label.capitalize()
split_scope = _split_scope(split_name)
col_names = resolve_column_names(dataset)
if "text" not in col_names:
string_cols = _string_columns(dataset)
if not string_cols:
raise ValueError(
f"{mode_title} training requires a string 'text' column but none "
f"was found in {split_scope} (columns: {col_names})."
)
renamed_col = string_cols[0]
if len(string_cols) > 1:
notices.append(
RawTextNotice(
message = (
f"{mode_title}: dataset has {len(string_cols)} string "
f"columns ({string_cols}); auto-selecting '{renamed_col}' "
"as the training text. Rename the intended column to "
"'text' to override."
),
level = "warning",
update_status = True,
)
)View on GitHub (pinned to 203007d190)
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.
Example fix
# before
prepare_raw_text(load_dataset("user/pretokenized")) # columns: input_ids, labels -> ValueError
# after
prepare_raw_text(load_dataset("user/raw-corpus")) # columns: text -> ok Defensive patterns
Strategy: type-guard
Validate before calling
def dataset_supports_raw_text(dataset) -> bool:
"""True when a 'text' column or at least one string column exists."""
feats = dataset.features
if "text" in feats:
return True
return any(
getattr(f, "dtype", None) == "string" or isinstance(f, str)
for f in feats.values()
) Type guard
def has_string_column(features: dict) -> bool:
return any(getattr(f, "dtype", None) == "string" for f in features.values()) Try / catch
try:
result = prepare_raw_text(ds)
except ValueError as e:
if "requires a string 'text' column" in str(e):
raise SystemExit(
f"Dataset columns {list(ds.features)} contain no text; "
"load the untokénized source dataset."
) from e
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- {mode_title} training requires at least one string 'text' va
- MiniMax-H3 was trained on aspect ratios from 1:4 to 4:1; thi
- data_dir is not a directory: {data_dir}
- No captioned video clips found. MiniMax-H3 trains from clips
- {Path(path).name} carries no video track.
AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15).
Data as JSON: /api/errors/b6b14c8b694cc752.
Report an issue: GitHub.