{
 "schema_version": 1,
 "generated": "2026-10-20",
 "id": "baruquerodrigues-llm-legislativo--study-from-scratch-transformer-code",
 "repo": "BaruqueRodrigues/llm-legislativo",
 "repo_url": "https://github.com/BaruqueRodrigues/llm-legislativo",
 "repo_slug": "baruquerodrigues-llm-legislativo",
 "title": "Study a from-scratch causal Transformer in PyTorch",
 "page_title": "How to study a from-scratch causal Transformer in PyTorch with LLM Legislativo",
 "summary": "Read and test an explicit GPT-style decoder built without pretrained weights or the Hugging Face Trainer.",
 "who": "An ML student or engineer who wants to learn how a causal decoder is built and trained, and does not want a black-box trainer.",
 "problem": "Most LLM code hides the model and training loop behind libraries, which makes the mechanics hard to learn.",
 "outcome": "A clear reading of the attention, weight tying, and gradient accumulation code, with the repo's unit tests as a check on understanding.",
 "steps": [
  "Clone the repo: (inferred) `git clone https://github.com/BaruqueRodrigues/llm-legislativo` (inferred, check the README)",
  "Open the model package at src/legislm/model/ and read the causal self-attention, GELU, and weight tying code.",
  "Read the training code in src/legislm/training/ to see how the loss is divided by the total number of valid targets in an update.",
  "Install the CPU lockfile with `pip install -r requirements-cpu.lock` and run the tests in tests/ with `pytest`. (inferred, check the README)"
 ],
 "agent_prompt": "Clone https://github.com/BaruqueRodrigues/llm-legislativo and explain how the causal attention and the gradient accumulation loss are implemented in src/legislm/model/ and src/legislm/training/. Output a short summary with file paths and line references. Verify each claim by reading the code, and say so if a file is missing.",
 "agents": [
  "any"
 ],
 "difficulty": "Intermediate",
 "time": "1 hour",
 "basis": "readme",
 "caveat": "The README install section is truncated in the source, so the setup commands above are partly inferred and need checking against the repo.",
 "category": "Research",
 "tags": [
  "Research"
 ],
 "lang": "python",
 "requirements": [
  "A Python environment (the README install section is cut off in the source, so exact setup steps are unconfirmed)",
  "Internet access to Hugging Face Hub and GitHub",
  "Enough disk space for the Parquet release if you download corpus files (the raw TAR archives total over 360 GiB)",
  "Basic familiarity with PyTorch and Hugging Face datasets for the model and corpus steps"
 ],
 "risk": "dual-use",
 "seen_in_the_wild": false,
 "mentioned_publicly": false,
 "risks": [],
 "best": true,
 "score": 1.0,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/baruquerodrigues-llm-legislativo/study-from-scratch-transformer-code/",
 "md": "https://dedupedai.com/use-cases/baruquerodrigues-llm-legislativo/study-from-scratch-transformer-code/index.md",
 "disclaimer": "Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked \"Seen in the wild\", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email hello@dedupedai.com and we will look at it promptly.",
 "api": "https://dedupedai.com/api/v1/usecases/baruquerodrigues-llm-legislativo--study-from-scratch-transformer-code.json",
 "api_version": "v1"
}
