AI Slop Code RIsk Monitor

FareedKhan-dev/train-llm-from-scratch

A straightforward method for training your LLM, from downloading data to generating text.

20.7 Elevated pattern signal View on GitHub

Maintenance and Governance Review

This report summarizes scanner evidence for FareedKhan-dev/train-llm-from-scratch, a Python project with 12,043 GitHub stars. SynthScan examined 19,135 lines of code across 199 source files, recording 317 pattern matches distributed across 16 syntactic categories. The legacy adjusted pattern signal is 20.7 (Elevated pattern signal); it is not an authorship estimate.

Use the findings to ask whether maintainers can explain intent, verify dependencies, simplify unnecessary scaffolding, and focus review effort. Risk Payload v1 adds ownership, supply-chain, over-engineering, and review-effort vectors when available. These are prompts for human verification, not probabilities, security findings, or measured maintenance costs.

20.7
Adjusted Signal
20.7
Raw Pattern Score
100%
Time Factor
2026-10-02
Last Push
12.0K
Stars
Python
Language
19.1K
Lines of Code
199
Files
317
Pattern Hits
2026-10-12
Scan Date
0.05
HC Hit Rate

Risk Review · v3

Use each vector to guide manual verification of the underlying findings.

Cognitive Ownership Risk 40.0/100 · MEDIUM

Can maintainers explain intent, assumptions, and trade-offs? 152 finding(s).

Hallucinated Dependency & Supply Chain Risk 33.5/100 · MEDIUM

Are imports declared and package/API names verified? 141 finding(s).

Agent Over-Engineering Ratio 35.7/100 · MEDIUM

Are wrappers, guards, and repeated structures necessary? 135 finding(s).

PR Review Velocity Impact 64.2/100 · HIGH

Which changes need focused human review? 317 finding(s).

What These Metrics Mean

Adjusted Signal
Legacy pattern score normalized per 1,000 scanned lines and multiplied by the repository-level time factor. It is not an estimate of AI authorship.
Raw Pattern Score
Sum of severity- and context-weighted pattern findings before applying the time factor.
Time Factor
A coarse multiplier based on repository last-push metadata. It does not identify when individual code was written.
Pattern Hits
Count of configured pattern findings. Review each location and surrounding code before acting.
HC Hit Rate
High- and critical-severity findings per scanned file. Severity is a configured detector weight, not proof of a vulnerability or authorship.
Lines / Files
Scan coverage denominators used by the legacy normalized score.

Pattern-Signal History

This chart tracks the legacy adjusted pattern score across scan runs. Changes can reflect source changes, scan coverage, or detector/scoring versions; they do not measure AI adoption or prove that a team refactored code. Compare runs only when their scoring versions are compatible. The dashed line tracks the raw pattern-hit count.

Severity Breakdown

Groups findings by configured severity weight. Severity is not a confidence estimate, security rating, or proof that a package is missing. Verify imports against the project's manifests and inspect each finding in its local design context.

CRITICAL 0HIGH 10MEDIUM 13LOW 294

Directory Score Breakdown

This horizontal bar chart shows where configured pattern scores accumulate across directories. Treat the bars as locations to inspect, not as evidence of authorship or code quality. Use the file-level findings to decide whether a directory needs a focused ownership, dependency, complexity, or review check.

Pattern Findings

The scanner identified 317 distinct pattern matches across 16 syntactic categories. Each entry below represents a discrete location in the source code where the engine recorded a detector match to inspect in context. Expand any category row to inspect the individual file paths, line numbers, code snippets, and the lexical context (CODE, COMMENT, or STRING) in which each match was detected.

Reading the findings table: The Severity column indicates the configured finding weight (CRITICAL / HIGH / MEDIUM / LOW). The Context column identifies whether the match occurred inside executable code, an inline comment, or a string literal — legacy comment-context matches receive a ×1.5 score weight. The ⚡ bolt icon marks clustered matches: three or more patterns within a 10-line window, each receiving an additional ×1.5 density multiplier under the legacy scoring model.

Unused Imports135 hits · 135 pts
SeverityFileLineSnippetContext
LOWui/metrics.py3CODE
LOWui/theme.py3CODE
LOWui/stages.py7CODE
LOWui/jobs.py10CODE
LOWui/app.py7CODE
LOWui/docs_render.py11CODE
LOWui/stage_page.py7CODE
LOWui/config_forms.py9CODE
LOWui/pages/8_Evaluate.py3CODE
LOWui/pages/9_Chat.py3CODE
LOWui/pages/1_Data.py3CODE
LOWconfig/presets.py27CODE
LOWconfig/post_training_config.py20CODE
LOWconfig/loader.py28CODE
LOWtests/test_inference.py3CODE
LOWtests/test_post_training_losses.py3CODE
LOWtests/conftest.py12CODE
LOWtests/conftest.py29CODE
LOWtests/test_classic_model.py3CODE
LOWtests/test_student_track.py8CODE
LOWtests/test_model_report.py3CODE
LOWtests/test_tokenizer.py3CODE
LOWtests/test_ddp_moe.py3CODE
LOWtests/test_factory.py3CODE
LOWtests/test_checkpoint_io.py10CODE
LOWtests/test_optim.py3CODE
LOWtests/test_preference_truncation.py10CODE
LOWtests/test_checkpoint_resume.py8CODE
LOWtests/test_type_checks.py3CODE
LOWtests/test_modern_model.py9CODE
LOWtests/test_config.py3CODE
LOWtests/test_device.py3CODE
LOWtests/test_sampling.py3CODE
LOWtests/test_pipeline_e2e.py12CODE
LOWtests/test_lora.py3CODE
LOWdocs/diagrams/make_plots.py14CODE
LOWscripts/eval_post_training.py16CODE
LOWscripts/benchmark.py14CODE
LOWscripts/train_ppo.py13CODE
LOWscripts/prepare_tiny_data.py29CODE
LOWscripts/prepare_preference_data.py14CODE
LOWscripts/train_sft.py13CODE
LOWscripts/train_dpo.py15CODE
LOWscripts/train_reward.py13CODE
LOWscripts/chat.py16CODE
LOWscripts/train_grpo.py19CODE
LOWscripts/pretrain_base.py21CODE
LOWscripts/generate_text.py19CODE
LOWscripts/prepare_rl_prompts.py12CODE
LOWscripts/prepare_pretrain_data.py18CODE
LOWscripts/train_transformer.py21CODE
LOWscripts/prepare_sft_data.py17CODE
LOWscripts/model_report.py20CODE
LOWdata_loader/sft_dataset.py9CODE
LOWdata_loader/prompt_dataset.py7CODE
LOWdata_loader/preference_dataset.py21CODE
LOWsrc/checkpoint.py14CODE
LOWsrc/device.py11CODE
LOWsrc/post_training/evaluation.py9CODE
LOWsrc/post_training/chat_template.py31CODE
75 more matches not shown…
Hyper-Verbose Identifiers108 hits · 121 pts
SeverityFileLineSnippetContext
LOWtests/test_inference.py30def test_greedy_speculative_decoding_equals_greedy_target_decoding() -> None:CODE
LOWtests/test_inference.py38def test_speculative_decoding_respects_the_trained_window() -> None:CODE
LOWtests/test_inference.py60def test_a_perfect_draft_is_always_accepted() -> None:CODE
LOWtests/test_inference.py68def test_sampling_keeps_the_target_distribution_whatever_the_draft() -> None:CODE
LOWtests/test_inference.py97def test_quantized_models_give_nearly_the_same_logits(arch: str) -> None:CODE
LOWtests/test_post_training_losses.py22def test_dpo_matches_the_formula_and_label_smoothing_hedges() -> None:CODE
LOW⚡tests/test_post_training_losses.py35def test_ipo_is_zero_at_its_target_gap() -> None:CODE
LOW⚡tests/test_post_training_losses.py45def test_simpo_is_reference_free_and_length_normalized() -> None:CODE
LOW⚡tests/test_post_training_losses.py55def test_group_advantages_std_and_dr_grpo() -> None:CODE
LOW⚡tests/test_post_training_losses.py63def test_loss_aggregation_modes() -> None:CODE
LOW⚡tests/test_post_training_losses.py71def test_skipped_groups_do_not_shrink_the_update() -> None:CODE
LOWtests/test_post_training_losses.py94def test_grpo_default_is_unchanged_and_clip_higher_widens_the_range() -> None:CODE
LOWtests/test_post_training_losses.py111def test_gspo_uses_one_ratio_per_answer() -> None:CODE
LOWtests/test_classic_model.py15def test_forward_shapes_loss_and_causality() -> None:CODE
LOWtests/test_classic_model.py26def test_forward_embedding_works_with_several_blocks() -> None:CODE
LOWtests/test_student_track.py64def test_set_overrides_any_config_value(monkeypatch: pytest.MonkeyPatch, tiny_data: dict[str, str]) -> None:CODE
LOWtests/test_student_track.py78def test_missing_data_explains_how_to_make_it(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:CODE
LOWtests/test_student_track.py84def test_presets_are_consistent() -> None:CODE
LOWtests/test_model_report.py20def test_flops_match_the_model_formula(extra: dict) -> None:CODE
LOWtests/test_model_report.py28def test_the_meta_device_builds_big_models_without_memory() -> None:CODE
LOWtests/verify_data_and_eval.py39def verify_sft_mask_alignment():CODE
LOWtests/verify_data_and_eval.py82def verify_rl_prompts_and_gold():CODE
LOWtests/test_tokenizer.py26def test_round_trip_is_lossless(tok: BPETokenizer, text: str) -> None:CODE
LOWtests/test_tokenizer.py30def test_training_learns_frequent_pieces_first(tok: BPETokenizer) -> None:CODE
LOWtests/test_tokenizer.py43def test_training_is_deterministic() -> None:CODE
LOWtests/test_tokenizer.py69def test_fast_training_learns_the_same_merges_as_the_textbook_algorithm() -> None:CODE
LOWtests/test_tokenizer.py82def test_specs_round_trip_and_safe_decode(tok: BPETokenizer, tmp_path) -> None:CODE
LOWtests/test_tokenizer.py94def test_vocab_must_hold_the_bytes() -> None:CODE
LOWtests/test_ddp_moe.py16def test_ddp_wrap_lets_moe_experts_skip_a_step(tmp_path: Path) -> None:CODE
LOWtests/test_post_training_smoke.py30def test_forward_hidden_matches_forward():CODE
LOWtests/test_post_training_smoke.py40def test_compute_logprobs_matches_manual():CODE
LOWtests/test_post_training_smoke.py53def test_rollout_logprobs_consistent():CODE
LOWtests/test_post_training_smoke.py68def test_context_cap_enforced():CODE
LOWtests/test_post_training_smoke.py76def test_value_and_reward_heads():CODE
LOWtests/test_post_training_smoke.py94def test_frozen_copy_and_reductions():CODE
LOWtests/test_post_training_smoke.py106def test_chat_template_masking():CODE
LOWtests/test_post_training_smoke.py130def test_preference_truncation_preserves_responses():CODE
LOW⚡tests/test_factory.py22def test_build_model_picks_the_architecture() -> None:CODE
LOW⚡tests/test_factory.py31def test_cli_style_overrides_build_a_modern_model() -> None:CODE
LOW⚡tests/test_factory.py38def test_modern_checkpoints_round_trip(tmp_path: str) -> None:CODE
LOWtests/test_checkpoint_io.py42def test_strip_wrapper_prefixes_handles_any_nesting() -> None:CODE
LOWtests/test_checkpoint_io.py62def test_unwrap_model_removes_compile_and_data_parallel(cfg: SFTConfig) -> None:CODE
LOWtests/test_checkpoint_io.py69def test_compiled_model_checkpoint_round_trip(cfg: SFTConfig, tmp_path: str) -> None:CODE
LOWtests/test_checkpoint_io.py82def test_old_prefixed_checkpoints_still_load(cfg: SFTConfig, tmp_path: str) -> None:CODE
LOWtests/test_checkpoint_io.py93def test_reward_checkpoint_loads_for_chat_and_as_reward_model(cfg: SFTConfig, tmp_path: str) -> None:CODE
LOWtests/test_checkpoint_io.py107def test_legacy_checkpoint_dims_are_read_from_config(tmp_path: str) -> None:CODE
LOWtests/test_checkpoint_io.py116def test_causal_masks_are_not_saved_and_old_checkpoints_with_them_still_load(tmp_path: str) -> None:CODE
LOWtests/test_checkpoint_io.py129def test_missing_parameters_fail_loudly(cfg: SFTConfig) -> None:CODE
LOWtests/test_checkpoint_io.py136def test_legacy_trainer_resumes_from_prefixed_checkpoint(tmp_path: str) -> None:CODE
LOWtests/test_optim.py13def test_newton_schulz_flattens_the_singular_values() -> None:CODE
LOWtests/test_optim.py25def test_muon_matches_pytorch_reference() -> None:CODE
LOWtests/test_optim.py44def test_muon_adamw_groups_match_torch_adamw() -> None:CODE
LOWtests/test_optim.py58def test_muon_groups_keep_embeddings_and_head_on_adamw() -> None:CODE
LOWtests/test_optim.py70def test_both_optimizers_train_a_tiny_model(name: str) -> None:CODE
LOWtests/test_optim.py85def test_schedules_hit_their_anchor_points() -> None:CODE
LOWtests/test_preference_truncation.py22def test_short_pairs_are_encoded_exactly_like_a_full_conversation() -> None:CODE
LOWtests/test_preference_truncation.py31def test_long_prompt_keeps_both_full_answers() -> None:CODE
LOWtests/test_preference_truncation.py43def test_long_prompt_and_long_answers_split_the_window() -> None:CODE
LOW⚡tests/test_preference_truncation.py54def test_late_difference_is_kept_by_shortening_the_prompt() -> None:CODE
LOW⚡tests/test_preference_truncation.py61def test_indistinguishable_pairs_do_not_crash() -> None:CODE
48 more matches not shown…
Self-Referential Comments8 hits · 26 pts
SeverityFileLineSnippetContext
MEDIUMscripts/data_preprocess.py32 # Create an HDF5 file for outputCOMMENT
MEDIUMscripts/train_transformer.py378 # Create a batch iterator for evaluation.COMMENT
MEDIUMscripts/train_transformer.py654 # Define a window size for averaging recent losses in the training loop.COMMENT
MEDIUMscripts/train_transformer.py661 # Create a batch iterator for the training data.COMMENT
MEDIUMscripts/train_transformer.py675 # Create a progress bar to monitor training progress.COMMENT
MEDIUM⚡scripts/data_download.py40 # Define the path for the validation fileCOMMENT
MEDIUMdata_loader/data_loader.py33 # Create an array of indices for examples and shuffle them for randomnessCOMMENT
MEDIUMdata_loader/data_loader.py68 # Create a dummy HDF5 fileCOMMENT
Empty Error Handlers4 hits · 20 pts
SeverityFileLineSnippetContext
HIGHui/metrics.py27except json.JSONDecodeError:CODE
HIGHconfig/loader.py120except ValueError:CODE
HIGHtests/conftest.py30except ImportError: # beartype is a dev dependency; plain runs still work without itCODE
HIGHtests/test_checkpoint_resume.py92except RuntimeError:CODE
Cross-Language Confusion5 hits · 20 pts
SeverityFileLineSnippetContext
HIGHui/config_forms.py34 # str / str|None / unknown -> text; empty string means "unset" (-> null) for optionalsCOMMENT
HIGHscripts/train_transformer.py500 """Split ``key=value``. Values are read as JSON (true, 2, 1e-3, null), anything else as text."""STRING
HIGHscripts/train_transformer.py541 else "python scripts/data_download.py && python scripts/data_preprocess.py")CODE
HIGHdata_loader/prompt_dataset.py3verifiable numeric answer, or null) and yields lists of sampled rows. Rows are shardedSTRING
HIGHsrc/post_training/ppo.py99 """Mean approximate KL(old || new) over response tokens (a PPO health metric)."""STRING
Structural Annotation Overuse13 hits · 20 pts
SeverityFileLineSnippetContext
LOWREADME.md200## Step 1: Preparing the DataCOMMENT
LOWREADME.md319## Step 2: The Model, Built From Small PiecesCOMMENT
LOWREADME.md483## Step 3: Pretraining the Base ModelCOMMENT
LOWREADME.md580## Step 4: Generating TextCOMMENT
LOWREADME.md615## Step 5: Post-Training, Turning a Base Model Into an AssistantCOMMENT
LOWREADME.md759## Step 6: EvaluationCOMMENT
LOWREADME.md778## Step 7: Talking to the ModelCOMMENT
LOWdocs/student/README.md36## Step 1: InstallCOMMENT
LOWdocs/student/README.md48## Step 2: Prepare the dataCOMMENT
LOWdocs/student/README.md82## Step 3: TrainCOMMENT
LOWdocs/student/README.md106## Step 4: GenerateCOMMENT
LOWdocs/foundations/bpe.md45## Step 1: split the text into chunksCOMMENT
LOWdocs/foundations/bpe.md64## Step 2: count pairs, merge, repeatCOMMENT
Deep Nesting12 hits · 12 pts
SeverityFileLineSnippetContext
LOWui/metrics.py17CODE
LOWscripts/data_preprocess.py11CODE
LOWscripts/train_ppo.py65CODE
LOWscripts/prepare_tiny_data.py53CODE
LOWscripts/train_sft.py71CODE
LOWscripts/train_dpo.py94CODE
LOWscripts/train_reward.py65CODE
LOWscripts/train_grpo.py57CODE
LOWscripts/pretrain_base.py70CODE
LOWscripts/prepare_pretrain_data.py76CODE
LOWscripts/train_transformer.py551CODE
LOWsrc/checkpoint.py43CODE
Excessive Try-Catch Wrapping9 hits · 12 pts
SeverityFileLineSnippetContext
LOWui/theme.py59 except Exception: # noqa: BLE001CODE
LOWscripts/data_preprocess.py73 except Exception as e:CODE
MEDIUMscripts/data_preprocess.py75 print(f"An error occurred while processing line in {filename}: {e}")CODE
MEDIUMscripts/data_preprocess.py99 print(f"Error: Training directory not found: {args.train_dir}")CODE
MEDIUMscripts/data_preprocess.py102 print(f"Error: Validation directory not found: {args.val_dir}")CODE
LOWscripts/prepare_preference_data.py86 except Exception as e: # noqa: BLE001CODE
LOWscripts/train_transformer.py281 except Exception:CODE
LOWscripts/prepare_sft_data.py89 except Exception as e: # noqa: BLE001CODE
LOWsrc/post_training/logging_utils.py42 except Exception as e: # noqa: BLE001 - logging must never crash trainingCODE
Modern Structural Boilerplate10 hits · 10 pts
SeverityFileLineSnippetContext
LOWscripts/train_transformer.py224def set_optimizer_lr(optimizer: torch.optim.Optimizer, lr: float) -> None:CODE
LOWsrc/post_training/utils.py43def set_seed(seed: int) -> None:CODE
LOWsrc/post_training/rollout.py34__all__ = [CODE
LOWsrc/post_training/optim.py20__all__ = ["build_optimizer", "configure_optimizer", "cosine_lr", "lr_at", "set_lr"]CODE
LOWsrc/post_training/rewards/__init__.py16__all__ = [CODE
LOWsrc/tokenizer/__init__.py76__all__ = [CODE
LOWsrc/optim/__init__.py38__all__ = [CODE
LOWsrc/optim/schedules.py78def set_lr(optimizer: torch.optim.Optimizer, lr: float) -> None:CODE
LOWsrc/models/modern/__init__.py13__all__ = [CODE
LOWsrc/inference/__init__.py5__all__ = ["filter_logits", "sample_next_token"]CODE
Redundant / Tautological Comments4 hits · 6 pts
SeverityFileLineSnippetContext
LOWscripts/data_download.py25 with open(file_name, 'wb') as f: # Open file for writing in binary modeCODE
LOW⚡scripts/data_download.py42 if not os.path.exists(val_file_path): # Check if the validation file already existsCODE
LOW⚡scripts/data_download.py52 if not os.path.exists(file_path): # Check if the file already existsCODE
LOWdata_loader/data_loader.py42 # Check if the current batch exceeds the number of available examplesCOMMENT
Docstring Block Structure1 hit · 5 pts
SeverityFileLineSnippetContext
HIGHconfig/loader.py143 Resolve ``cfg_cls`` from ``base.json`` + the stage JSON + CLI overrides. Args: cfg_cls: the stage dataSTRING
Decorative Section Separators1 hit · 3 pts
SeverityFileLineSnippetContext
MEDIUMdocs/diagrams/make_plots.py90# ---------------------------------------------------------------------------------------------COMMENT
AI Structural Patterns3 hits · 3 pts
SeverityFileLineSnippetContext
LOWsrc/optim/muon.py76CODE
LOWsrc/models/attention.py61CODE
LOWsrc/inference/speculative.py72CODE
Modern AI Meta-Vocabulary1 hit · 2 pts
SeverityFileLineSnippetContext
MEDIUMREADME.md587 idx_cond = idx[:, -self.context_length:] # never look back further than the context windowCODE
Over-Commented Block2 hits · 2 pts
SeverityFileLineSnippetContext
LOWscripts/run_posttraining.sh1#!/usr/bin/env bashCOMMENT
LOWscripts/render_diagrams.sh1#!/usr/bin/env bashCOMMENT
Fake / Example Data1 hit · 1 pts
SeverityFileLineSnippetContext
LOWdata_loader/data_loader.py70 dummy_data_path = "dummy_data.h5"CODE