AdithyaSK's picture
AdithyaSK HF Staff
Update FineEnvs article links and SmolDataEnvs naming
c966b75 verified
|
Raw History Blame Contribute Delete
8.45 kB
metadata
pretty_name: SmolDataEnvs Multi-harness SFT
language:
  - en
task_categories:
  - text-generation
tags:
  - sft
  - trl
  - tool-use
  - multi-harness
  - synthetic
size_categories:
  - 10K<n<100K
configs:
  - config_name: all
    default: true
    data_files:
      - split: train
        path: conversations/*/*.parquet
  - config_name: opencode
    data_files:
      - split: train
        path: conversations/opencode/*.parquet
  - config_name: claude-code
    data_files:
      - split: train
        path: conversations/claude-code/*.parquet
  - config_name: codex
    data_files:
      - split: train
        path: conversations/codex/*.parquet
  - config_name: mini-swe-agent
    data_files:
      - split: train
        path: conversations/mini-swe-agent/*.parquet
  - config_name: lfm25_2_6b
    data_files:
      - split: train
        path: lfm25_2_6b/*/*.parquet
  - config_name: qwen35_2b
    data_files:
      - split: train
        path: qwen35_2b/*/*.parquet

SmolDataEnvs Multi-harness SFT

Ready-to-load TRL SFT data from Qwen3.8-27B trajectories on data-analysis tasks. It contains 17,929 assistant responses from 3,189 successful rollouts, covering 888 unique tasks and four harnesses.

Each conversational row is one recorded prompt plus the next assistant completion and its available tool schemas. Previous assistant messages and tool outputs are context; only the current completion is supervised. No incompatible conversation roots are stitched together.

Choose a configuration

Configuration Examples Rollouts Use
all (default) 17,929 3,189 Portable prompt/completion messages, all harnesses
opencode 4,825 801 OpenCode messages
claude-code 4,581 781 Claude Code messages
codex 4,078 797 Codex messages
mini-swe-agent 4,445 810 Mini-SWE-Agent messages
lfm25_2_6b 17,929 3,189 Validated LFM2.5-2.6B input IDs and labels
qwen35_2b 17,929 3,189 Validated Qwen3.5-2B input IDs and labels
from datasets import load_dataset

# datasets 5.0.0 preserves the heterogeneous message/tool fields.
ds = load_dataset("FineEnvs/SmolDataEnvs-multiharness-sft", "all", split="train")
print(ds[0]["prompt"], ds[0]["completion"], ds[0]["tools"])

prompt, completion and tools use the Datasets Json feature. They load as Python lists/dictionaries, not JSON strings. This preserves tool arguments without injecting null-valued keys or flattening nested structures. Files are Parquet; no custom dataset loader is required.

Metadata includes example_id, task_id, rollout_id, turn_id, harness, difficulty, common_task, rollout_turn_count, teacher/model revisions and the source rollout hash.

Quick SFT: LFM2.5-2.6B

The tokenized configuration is the simplest and fastest route for the two validated models. It avoids repeated tokenization and already contains exact completion-only labels (-100 for context). Install requirements.txt first; the TRL commit is pinned because label handling is version-sensitive.

import torch
from datasets import load_dataset
from transformers import AutoModelForCausalLM, AutoTokenizer
from trl import SFTConfig, SFTTrainer

model_id = "LiquidAI/LFM2.5-2.6B"
revision = "654f9463ce32b05d0429d76fe1f580b27d4c1ac0"
ds = load_dataset("FineEnvs/SmolDataEnvs-multiharness-sft", "lfm25_2_6b", split="train")
ds = ds.select_columns(["input_ids", "labels"])
tokenizer = AutoTokenizer.from_pretrained(model_id, revision=revision)
model = AutoModelForCausalLM.from_pretrained(
    model_id, revision=revision, dtype=torch.bfloat16, attn_implementation="sdpa",
)
trainer = SFTTrainer(
    model=model,
    processing_class=tokenizer,
    train_dataset=ds,
    args=SFTConfig(
        output_dir="lfm-multiharness-sft",
        num_train_epochs=2, learning_rate=3e-6, lr_scheduler_type="constant",
        per_device_train_batch_size=1, gradient_accumulation_steps=8,
        bf16=True, optim="paged_adamw_8bit", gradient_checkpointing=True,
        max_length=None, packing=False, loss_type="chunked_nll",
        dataset_kwargs={"skip_prepare_dataset": True},
        assistant_only_loss=False, save_strategy="epoch", report_to="none",
    ),
)
trainer.train()
trainer.save_model("lfm-multiharness-sft/final")
tokenizer.save_pretrained("lfm-multiharness-sft/final")

These tokenized configurations are specific to the pinned student model/tokenizer revisions. Do not use them for other models. Labels are unshifted; TRL applies the causal shift. Teacher IDs/logprobs are not student targets.

Run either model with one script

train_sft.py supports both models, tokenized or conversational input, harness filtering, and matched-task selection. Defaults reproduce the training hyperparameters above, with epoch checkpoint saves. It saves a dataset revision receipt and the model's original inference template.

hf download FineEnvs/SmolDataEnvs-multiharness-sft --repo-type dataset \
  --include train_sft.py requirements.txt --local-dir multiharness-sft
cd multiharness-sft
pip install -r requirements.txt

python train_sft.py --model lfm --output-dir lfm-sft
python train_sft.py --model qwen --output-dir qwen-sft

Run the two commands in separate GPU allocations to train concurrently. Full fine-tuning uses long sequences: maximum 68,673 tokens for LFM and 73,577 for Qwen. The reference configuration uses one 80 GB H100 per trainer, without truncation.

# Use readable messages and native TRL completion-only tokenization instead.
python train_sft.py --model qwen --dataset-config all --output-dir qwen-messages

# Restrict to OpenCode, or to tasks that have successes in all four harnesses.
python train_sft.py --model lfm --harness opencode --output-dir lfm-opencode
python train_sft.py --model lfm --common-tasks --output-dir lfm-matched

The conversational recipe uses completion_only_loss=True. LFM needs the bundled training template to avoid a generation-prefix mismatch. Qwen's training prefix follows the recorded response's reasoning presence. The script restores the original inference template before saving; reference evaluation uses Qwen thinking disabled and LFM thinking preserved. Other models require their own prefix/mask checks.

Selection and provenance

  • Source: FineEnvs/qwen38-27b-harbor-rollouts, revision 3d826b6854acdb4e4918e5047cdf9f70eb38602e.
  • Teacher: Qwen/Qwen3.8-27B, revision 1d4bf0f2ff6012fd82039f2fa52739d0dd7c60c0. Collection used Harbor with Daytona sandboxes and retained the first correct, valid captured rollout per task/harness, with at most three attempts.
  • The attempted pool contained 1,000 tasks: 400 medium and 600 hard. Published successes cover 377 medium and 511 hard unique tasks. This is success-selected demonstration data, not an estimate of pass@1.
  • Four credential-containing rollouts remain excluded. No test-task, test-notebook or normalized test-question overlap was found with the fixed 250-task evaluation set used in these experiments.
  • common_task=True identifies 692 tasks with successes in every harness, or 2,768 matched rollouts. common_tasks.json lists their IDs. If making an additional train/validation split, group by task_id so related turns and harnesses remain together.
  • Sampling is standard turn-level SFT. rollout_turn_count is metadata; it does not automatically equalize rollout or harness weights. For a controlled OpenCode-versus-multi-harness comparison, also match task selection and training budget.
  • manifest.json records source checksums, counts, tokenizer revisions, template hashes and student token statistics. Original full captures and teacher logprobs remain in the source dataset.

Validation

Every exported row is round-trip checked through Parquet. Student input IDs and labels match the completed full-corpus native TRL audits; historical context is masked and completions contain supervised tokens. The reference training setup also passed save/resume, longest-example and four-harness evaluation smokes. Hub loading and a CPU TRL update are checked separately in verification.json.

The default configuration is portable. Model-specific features, APIs and mask semantics were tested with the exact versions in requirements.txt; changing tokenizers/templates requires revalidation. Task/data licenses from the source dataset continue to apply.