torchlight-threads / README.md
samadpls's picture
Describe what the model was trained to do
8ef99e3 verified
|
Raw History Blame Contribute Delete
9 kB
metadata
license: cc-by-4.0
language:
  - en
pretty_name: torchlight threads
task_categories:
  - question-answering
  - text-generation
tags:
  - pytorch
  - code
  - sft
  - forum
  - debugging
size_categories:
  - 10K<n<100K
configs:
  - config_name: sft
    default: true
    data_files:
      - split: train
        path: sft/train.jsonl
      - split: validation
        path: sft/validation.jsonl
  - config_name: eval
    data_files:
      - split: test
        path: eval/test.jsonl
  - config_name: threads
    data_files:
      - split: train
        path: threads/threads.jsonl

torchlight

GitHub samadpls.com License: CC BY 4.0 Language: English

🔥 torchlight threads

PyTorch questions from the PyTorch forums, each paired with the answer that actually resolved it, whoever wrote it.

The threads are the 22,293 topics that ptrblck, the forum's most active answerer, took part in, plus 193 recent solved topics from other answerers for evaluation. Which answer counts comes from the forum's own signals, not from who wrote it: the accepted solution, or the post the asker said fixed their problem.

The dataset was built to fine-tune and evaluate torchlight, a small PyTorch helper trained to give a specific fix when it can and to ask for a minimal repro when it can't.

At a glance

Threads crawled and cleaned 22,484
Usable rows (sft + eval) 7,354, from 6,841 threads
Answer examples 6,581 (5,669 gold, 912 silver)
Clarification examples 513
Evaluation questions 260, all gold and all reviewed
Threads reviewed by an agent 1,269 (408 kept, 449 combined, 412 dropped)

⚡ Quick start

from datasets import load_dataset

sft = load_dataset("samadpls/torchlight-threads", "sft")
evaluation = load_dataset("samadpls/torchlight-threads", "eval", split="test")
threads = load_dataset("samadpls/torchlight-threads", "threads", split="train")

print(sft["train"][0]["messages"])

Configs

Config Split Rows What it holds
sft train 6,925 Chat examples (messages) for supervised fine-tuning, threads created before 2024-07-01
sft validation 169 Same format, threads from 2024-07-01 to 2025-01-01
eval test 260 Questions with a reviewed reference answer, threads created on or after 2025-01-01
threads train 22,484 Every crawled thread, cleaned, with its resolution and the reason it was excluded, if it was

The splits are by date, never random, so every evaluation question is newer than anything in training.

The threads config holds every thread, including the ones behind the evaluation questions; its only split is called train because Hugging Face needs a split name. Each row's real split is in its split column. If you train on threads, keep only rows where split is train, or you will train on the test answers.

How answers were chosen

  1. Accepted solution. If a post is marked as the solution, it is the answer. When the asker marked their own thank-you post, the answer is the post they were thanking.
  2. Asker confirmation. Otherwise, if the asker later said the fix worked ("that solved it", "works now"), the answer is the post they were replying to.
  3. Review. A small LLM agent following prompts/review.md reviewed every evaluation answer, plus training answers that were only a question, under 60 characters, mostly a link, or pointing at other posts. It kept the post, dropped the thread, or combined several posts into one answer.
  4. Grounding check. A combined answer is rejected unless every code block in it appears verbatim in its source posts.

Tiers: gold answers are accepted solutions; silver answers were confirmed by the asker. The eval config is gold only.

What a row looks like

An sft answer example
user       How does torchvision.transforms.Normalize work
           Whenever I Normalize my input images with its mean and std, and when i plot the
           images to visualize i get this message along with plots of images which are
           distorted in a way. Clipping input data to the valid range ...
assistant  The easiest way would be to plot them before normalizing.
           However, if that's not possible, you could also undo the normalization:
           (code that reverses Normalize with the same mean and std)

Each row also carries kind, tier, answer_origin, answer_post_numbers, answer_authors, thread_id, url and created_at.

The two kinds of sft examples
  • answer: the conversation up to the answer, ending with the answer as the final assistant turn. Earlier assistant turns are context only.
  • clarification: the opening question and a first reply that asked for missing details, such as a minimal executable snippet or the full error. These teach the model to ask instead of guessing.

System prompt

Rows contain only user and assistant turns, so you can train with any system prompt. torchlight trains with this one:

You are a careful PyTorch helper. Give specific, correct guidance with code where it helps. If a question lacks the details needed to answer it, ask for them, for example a minimal executable code snippet or the full error message, instead of guessing.

SYSTEM_PROMPT = "You are a careful PyTorch helper. ..."
sft = sft.map(
    lambda row: {"messages": [{"role": "system", "content": SYSTEM_PROMPT}] + row["messages"]}
)

Cleaning and filters

Every thread in all three configs is cleaned:

  • text quoted from earlier posts is removed;
  • images become [image];
  • emails and strings that look like API keys are redacted;
  • deleted and hidden posts are dropped;
  • code blocks are kept exactly as written.

6,841 of the 22,484 threads became examples. The rest stay in threads with the reason in excluded:

  • No accepted answer and no confirmation from the asker: 14,005 threads
  • Created before PyTorch 0.4 (May 2018): 743 threads
  • Question depends on an image: 173 threads
  • Answer is an image: 8 threads
  • Longer than 8 messages or 12,000 characters: 269 threads
  • Answer uses removed APIs such as volatile=True: 20 threads
  • Not in English: 1 thread
  • Dropped by the review agent: 412 threads
  • Combined answer whose code was not found in its sources: 2 threads
  • Evaluation threads without an accepted answer: 10 threads

Fields

Show all fields
Config Fields
sft messages, kind, tier, answer_origin (verbatim or composed), answer_post_numbers, answer_authors, thread_id, url, created_at
eval question, reference_answer, needs_clarification, answered_by_ptrblck, tier, answer_origin, answer_post_numbers, answer_authors, thread_id, url, created_at
threads thread_id, url, title, created_at, category_id, tags, asker, split, resolution, excluded, posts

⚠️ Limitations

  • Answers are only as correct as the forum's resolution signals. An accepted or confirmed answer can still be imperfect or tied to an older PyTorch version.
  • The data leans toward the questions ptrblck answered, so it is heavy on debugging, CUDA, training loops and shape errors.
  • Threads whose question or answer depends on an image were excluded.

License and attribution

Forum content is licensed under CC BY 4.0 by the LF Projects Terms of Use that the PyTorch forums follow, and this dataset is released under the same license. Credit goes to the forum's authors; every row carries the URL of the thread it came from.

Author

Built by Abdul Samad (samadpls.com · GitHub @samadpls) with torchlight. Questions and corrections: abdulsamadsid1@gmail.com.

Citation

@misc{samad2026torchlight,
  author = {Abdul Samad},
  title = {torchlight threads: resolved PyTorch forum questions and answers},
  year = {2026},
  url = {https://huggingface.co/datasets/samadpls/torchlight-threads}
}