A straightforward method for training your LLM, from downloading data to generating text.
This report presents the forensic synthetic code analysis of FareedKhan-dev/train-llm-from-scratch, a Python project with 8,315 GitHub stars. SynthScan v2.0 examined 11,000 lines of code across 127 source files, recording 135 pattern matches distributed across 13 syntactic categories. The overall adjusted score of 15.5 places this repository in the Moderate AI signal band.
The scanner applied 160+ deterministic lexical heuristics, multi-line block detectors, abstract syntax tree depth profilers, and a cross-file Jaccard similarity matrix to construct a statistically normalised synthetic code estimate. All matches are individually weighted by severity coefficient and contextual multiplier before summation, and the resulting headline score is temporally discounted to account for the repository's development history relative to the commercial emergence of large language model coding tooling (November 2022 onward).
This chart maps the temporal evolution of the adjusted synthetic code score across successive scan runs. An upward trajectory indicates ongoing incorporation of AI-generated code or expanding LLM-assisted scaffolding; a stable or declining trajectory may reflect active human refactoring, code removal, or the adoption of stricter authorship policies. The dashed secondary line (right axis) independently tracks total raw pattern hit count, which can diverge from the normalised score when codebase size changes significantly between scans.
Classifies detected patterns by their diagnostic confidence and structural impact. CRITICAL patterns (coefficient 10) represent definitive synthetic signatures — hallucinated imports, explicit LLM attribution metadata — virtually never produced by human authors. HIGH (5) indicates strong structural tells such as cross-file repetition or cross-linguistic idioms. MEDIUM (2) covers recognisable conversational padding and AI-specific vocabulary. LOW (1) captures subtle indicators like tautological comments and generic boilerplate that require density to carry independent signal.
This horizontal bar chart decomposes the repository's raw synthetic code score by top-level directory, allowing you to pinpoint precisely which modules or components carry the highest AI authorship density. Directories with disproportionately high scores relative to their size warrant targeted manual review: concentrated AI signatures often trace back to mass-generated configuration layers, auto-ported test suites, LLM-scaffolded boilerplate classes, or entire subsystems authored under heavy copilot assistance. Use this view to prioritise your human code-review effort.
The scanner identified 135 distinct pattern matches across 13 syntactic categories. Each entry below represents a discrete location in the source code where the engine recorded a statistically significant AI authorship indicator. 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 diagnostic confidence level (CRITICAL / HIGH / MEDIUM / LOW). The Context column identifies whether the match occurred inside executable code, an inline comment, or a string literal — comment-context matches receive a ×1.5 weight because LLMs systematically over-annotate. The ⚡ bolt icon marks clustered matches: three or more patterns within a 10-line window, each receiving an additional ×1.5 density multiplier as dense clusters constitute far stronger evidence of synthetic authorship than isolated hits.
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| LOW | ui/metrics.py | 3 | CODE | |
| LOW | ui/theme.py | 3 | CODE | |
| LOW | ui/stages.py | 7 | CODE | |
| LOW | ui/jobs.py | 10 | CODE | |
| LOW | ui/app.py | 7 | CODE | |
| LOW | ui/docs_render.py | 11 | CODE | |
| LOW | ui/stage_page.py | 7 | CODE | |
| LOW | ui/config_forms.py | 9 | CODE | |
| LOW | ui/pages/8_Evaluate.py | 3 | CODE | |
| LOW | ui/pages/9_Chat.py | 3 | CODE | |
| LOW | ui/pages/1_Data.py | 3 | CODE | |
| LOW | config/post_training_config.py | 15 | CODE | |
| LOW | config/post_training_config.py | 17 | CODE | |
| LOW | config/loader.py | 20 | CODE | |
| LOW | tests/test_post_training_smoke.py | 14 | CODE | |
| LOW | tests/test_checkpoint_resume.py | 8 | CODE | |
| LOW | tests/test_rl_math.py | 9 | CODE | |
| LOW | scripts/eval_post_training.py | 16 | CODE | |
| LOW | scripts/train_ppo.py | 13 | CODE | |
| LOW | scripts/train_ppo.py | 15 | CODE | |
| LOW | scripts/train_ppo.py | 23 | CODE | |
| LOW | scripts/prepare_preference_data.py | 14 | CODE | |
| LOW | scripts/train_sft.py | 13 | CODE | |
| LOW | scripts/train_sft.py | 15 | CODE | |
| LOW | scripts/train_dpo.py | 12 | CODE | |
| LOW | scripts/train_reward.py | 13 | CODE | |
| LOW | scripts/train_reward.py | 72 | CODE | |
| LOW | scripts/chat.py | 15 | CODE | |
| LOW | scripts/train_grpo.py | 14 | CODE | |
| LOW | scripts/train_grpo.py | 16 | CODE | |
| LOW | scripts/pretrain_base.py | 18 | CODE | |
| LOW | scripts/pretrain_base.py | 23 | CODE | |
| LOW | scripts/prepare_rl_prompts.py | 12 | CODE | |
| LOW | scripts/prepare_pretrain_data.py | 18 | CODE | |
| LOW | scripts/train_transformer.py | 1 | CODE | |
| LOW | scripts/prepare_sft_data.py | 17 | CODE | |
| LOW | data_loader/sft_dataset.py | 9 | CODE | |
| LOW | data_loader/prompt_dataset.py | 7 | CODE | |
| LOW | data_loader/preference_dataset.py | 16 | CODE | |
| LOW | src/post_training/evaluation.py | 9 | CODE | |
| LOW | src/post_training/chat_template.py | 31 | CODE | |
| LOW | src/post_training/grpo.py | 10 | CODE | |
| LOW | src/post_training/distributed.py | 10 | CODE | |
| LOW | src/post_training/cli.py | 6 | CODE | |
| LOW | src/post_training/utils.py | 7 | CODE | |
| LOW | src/post_training/rollout.py | 22 | CODE | |
| LOW | src/post_training/value_head.py | 11 | CODE | |
| LOW | src/post_training/inference.py | 10 | CODE | |
| LOW | src/post_training/inference.py | 15 | CODE | |
| LOW | src/post_training/inference.py | 15 | CODE | |
| LOW | src/post_training/reward_model.py | 10 | CODE | |
| LOW | src/post_training/reward_model.py | 18 | CODE | |
| LOW | src/post_training/sft.py | 11 | CODE | |
| LOW | src/post_training/ppo.py | 17 | CODE | |
| LOW | src/post_training/optim.py | 9 | CODE | |
| LOW | src/post_training/dpo.py | 15 | CODE | |
| LOW | src/post_training/logging_utils.py | 10 | CODE | |
| LOW | src/post_training/reward_train.py | 12 | CODE | |
| LOW | src/post_training/rewards/verifiers.py | 12 | CODE | |
| LOW | src/post_training/rewards/parsing.py | 12 | CODE | |
| 14 more matches not shown… | ||||
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| MEDIUM | scripts/data_preprocess.py | 31 | # Create an HDF5 file for output | COMMENT |
| MEDIUM | scripts/train_transformer.py | 320 | # Create a batch iterator for evaluation. | COMMENT |
| MEDIUM | scripts/train_transformer.py | 515 | # Define a window size for averaging recent losses in the training loop. | COMMENT |
| MEDIUM | scripts/train_transformer.py | 522 | # Create a batch iterator for the training data. | COMMENT |
| MEDIUM | scripts/train_transformer.py | 536 | # Create a progress bar to monitor training progress. | COMMENT |
| MEDIUM⚡ | scripts/data_download.py | 40 | # Define the path for the validation file | COMMENT |
| MEDIUM | data_loader/data_loader.py | 31 | # Create an array of indices for examples and shuffle them for randomness | COMMENT |
| MEDIUM | data_loader/data_loader.py | 66 | # Create a dummy HDF5 file | COMMENT |
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| LOW | tests/verify_data_and_eval.py | 39 | def verify_sft_mask_alignment(): | CODE |
| LOW | tests/verify_data_and_eval.py | 82 | def verify_rl_prompts_and_gold(): | CODE |
| LOW | tests/test_post_training_smoke.py | 28 | def test_forward_hidden_matches_forward(): | CODE |
| LOW | tests/test_post_training_smoke.py | 38 | def test_compute_logprobs_matches_manual(): | CODE |
| LOW | tests/test_post_training_smoke.py | 51 | def test_rollout_logprobs_consistent(): | CODE |
| LOW | tests/test_post_training_smoke.py | 66 | def test_context_cap_enforced(): | CODE |
| LOW | tests/test_post_training_smoke.py | 74 | def test_value_and_reward_heads(): | CODE |
| LOW | tests/test_post_training_smoke.py | 92 | def test_frozen_copy_and_reductions(): | CODE |
| LOW | tests/test_post_training_smoke.py | 104 | def test_chat_template_masking(): | CODE |
| LOW | tests/test_checkpoint_resume.py | 41 | def test_checkpoint_round_trip_and_latest_resume(): | CODE |
| LOW | tests/test_checkpoint_resume.py | 81 | def test_checkpoint_save_failure_does_not_leave_partial_file(): | CODE |
| LOW | tests/test_rl_math.py | 27 | def test_gae_masks_outside_response(): | CODE |
| LOW | scripts/train_transformer.py | 230 | def restore_training_checkpoint( | CODE |
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| HIGH | ui/config_forms.py | 34 | # str / str|None / unknown -> text; empty string means "unset" (-> null) for optionals | COMMENT |
| HIGH | data_loader/prompt_dataset.py | 3 | verifiable numeric answer, or null) and yields lists of sampled rows. Rows are sharded | STRING |
| HIGH | src/post_training/ppo.py | 99 | """Mean approximate KL(old || new) over response tokens (a PPO health metric).""" | STRING |
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| LOW | ui/theme.py | 59 | except Exception: # noqa: BLE001 | CODE |
| LOW | scripts/data_preprocess.py | 72 | except Exception as e: | CODE |
| MEDIUM | scripts/data_preprocess.py | 74 | print(f"An error occurred while processing line in {filename}: {e}") | CODE |
| MEDIUM | scripts/data_preprocess.py | 98 | print(f"Error: Training directory not found: {args.train_dir}") | CODE |
| MEDIUM | scripts/data_preprocess.py | 101 | print(f"Error: Validation directory not found: {args.val_dir}") | CODE |
| LOW | scripts/prepare_preference_data.py | 83 | except Exception as e: # noqa: BLE001 | CODE |
| LOW | scripts/train_transformer.py | 224 | except Exception: | CODE |
| LOW | scripts/prepare_sft_data.py | 85 | except Exception as e: # noqa: BLE001 | CODE |
| LOW | src/post_training/logging_utils.py | 42 | except Exception as e: # noqa: BLE001 - logging must never crash training | CODE |
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| LOW | README.md | 160 | ## Step 1: Preparing the Data | COMMENT |
| LOW | README.md | 279 | ## Step 2: The Model, Built From Small Pieces | COMMENT |
| LOW | README.md | 427 | ## Step 3: Pretraining the Base Model | COMMENT |
| LOW | README.md | 513 | ## Step 4: Generating Text | COMMENT |
| LOW | README.md | 537 | ## Step 5: Post-Training, Turning a Base Model Into an Assistant | COMMENT |
| LOW | README.md | 671 | ## Step 6: Evaluation | COMMENT |
| LOW | README.md | 690 | ## Step 7: Talking to the Model | COMMENT |
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| LOW | ui/metrics.py | 17 | CODE | |
| LOW | scripts/data_preprocess.py | 10 | CODE | |
| LOW | scripts/train_ppo.py | 55 | CODE | |
| LOW | scripts/train_sft.py | 50 | CODE | |
| LOW | scripts/train_dpo.py | 74 | CODE | |
| LOW | scripts/train_reward.py | 59 | CODE | |
| LOW | scripts/train_grpo.py | 43 | CODE | |
| LOW | scripts/pretrain_base.py | 56 | CODE | |
| LOW | scripts/prepare_pretrain_data.py | 76 | CODE | |
| LOW | scripts/train_transformer.py | 416 | CODE |
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| LOW | scripts/data_download.py | 25 | with open(file_name, 'wb') as f: # Open file for writing in binary mode | CODE |
| LOW⚡ | scripts/data_download.py | 42 | if not os.path.exists(val_file_path): # Check if the validation file already exists | CODE |
| LOW⚡ | scripts/data_download.py | 52 | if not os.path.exists(file_path): # Check if the file already exists | CODE |
| LOW | data_loader/data_loader.py | 40 | # Check if the current batch exceeds the number of available examples | COMMENT |
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| LOW | scripts/train_transformer.py | 167 | def set_optimizer_lr(optimizer: torch.optim.Optimizer, lr: float) -> None: | CODE |
| LOW | src/post_training/utils.py | 35 | def set_seed(seed: int) -> None: | CODE |
| LOW | src/post_training/rewards/__init__.py | 16 | __all__ = [ | CODE |
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| MEDIUM | README.md | 520 | idx_cond = idx[:, -self.context_length:] # never look back further than the context window | CODE |
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| LOW | scripts/render_diagrams.sh | 1 | #!/usr/bin/env bash | COMMENT |
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| LOW | data_loader/data_loader.py | 68 | dummy_data_path = "dummy_data.h5" | CODE |
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| LOW | src/models/attention.py | 58 | CODE |