Repository Analysis

rasbt/LLMs-from-scratch

Implement a ChatGPT-like LLM in PyTorch from scratch, step by step

7.6 Low AI signal View on GitHub
7.6
Adjusted Score
7.6
Raw Score
100%
Time Factor
2026-05-23
Last Push
96,297
Stars
Jupyter Notebook
Language
57,661
Lines of Code
271
Files
302
Pattern Hits
2026-05-31
Scan Date

Score History

Severity Breakdown

CRITICAL 0HIGH 8MEDIUM 63LOW 231

Pattern Findings

302 matches across 11 categories. Click a row to expand file-level details.

Self-Referential Comments45 hits · 108 pts
SeverityFileLineSnippet
MEDIUMch07/01_main-chapter-code/previous_chapters.py467 # Create a second x-axis for tokens seen
MEDIUMch07/01_main-chapter-code/previous_chapters.py468 ax2 = ax1.twiny() # Create a second x-axis that shares the same y-axis
MEDIUMch07/01_main-chapter-code/exercise_experiments.py286 # Create a second x-axis for tokens seen
MEDIUMch07/01_main-chapter-code/exercise_experiments.py287 ax2 = ax1.twiny() # Create a second x-axis that shares the same y-axis
MEDIUMch07/01_main-chapter-code/ollama_evaluate.py15 # Create the data payload as a dictionary
MEDIUMch07/01_main-chapter-code/gpt_instruction_finetuning.py135 # Create a second x-axis for tokens seen
MEDIUMch07/01_main-chapter-code/gpt_instruction_finetuning.py136 ax2 = ax1.twiny() # Create a second x-axis that shares the same y-axis
MEDIUMch07/04_preference-tuning-with-dpo/previous_chapters.py468 # Create a second x-axis for tokens seen
MEDIUMch07/04_preference-tuning-with-dpo/previous_chapters.py469 ax2 = ax1.twiny() # Create a second x-axis that shares the same y-axis
MEDIUMch06/01_main-chapter-code/gpt_class_finetune.py230 # Create a second x-axis for tokens seen
MEDIUMch06/01_main-chapter-code/gpt_class_finetune.py231 ax2 = ax1.twiny() # Create a second x-axis that shares the same y-axis
MEDIUMch06/01_main-chapter-code/gpt_download.py111 # Define the block size for reading the file
MEDIUMch06/02_bonus_additional-experiments/gpt_download.py111 # Define the block size for reading the file
MEDIUM…_bonus_imdb-classification/download_prepare_dataset.py58 # Create a DataFrame for each file and add it to the list
MEDIUMch06/03_bonus_imdb-classification/gpt_download.py111 # Define the block size for reading the file
MEDIUM…6/03_bonus_imdb-classification/train_sklearn_logreg.py65 # Create a dummy classifier with the strategy to predict the most frequent class
MEDIUM…nal-aws-sagemaker-notebook/cloudformation-template.yml59 # Create a startup script that will run in the background
MEDIUM…nal-aws-sagemaker-notebook/cloudformation-template.yml104 # Create a flag file to indicate setup is complete
MEDIUMappendix-D/01_main-chapter-code/previous_chapters.py305 # Create a second x-axis for tokens seen
MEDIUMappendix-D/01_main-chapter-code/previous_chapters.py306 ax2 = ax1.twiny() # Create a second x-axis that shares the same y-axis
MEDIUMappendix-E/01_main-chapter-code/previous_chapters.py540 # Create a second x-axis for tokens seen
MEDIUMappendix-E/01_main-chapter-code/previous_chapters.py541 ax2 = ax1.twiny() # Create a second x-axis that shares the same y-axis
MEDIUMappendix-E/01_main-chapter-code/gpt_download.py111 # Define the block size for reading the file
MEDIUMch05/16_qwen3.5/qwen3_5_transformers.py97 """This function is intended to align with the l2norm implementation in the FLA library."""
MEDIUMch05/01_main-chapter-code/gpt_train.py122 # Create a second x-axis for tokens seen
MEDIUMch05/01_main-chapter-code/gpt_train.py123 ax2 = ax1.twiny() # Create a second x-axis that shares the same y-axis
MEDIUMch05/01_main-chapter-code/gpt_download.py111 # Define the block size for reading the file
MEDIUMch05/01_main-chapter-code/gpt_generate.py77 # Define the block size for reading the file
MEDIUMch05/07_gpt_to_llama/tests/tests_rope_and_parts.py113 # Create a module to store the imported functions and classes
MEDIUMch05/10_llm-training-speed/01_opt_single_gpu.py361 # Create a second x-axis for tokens seen
MEDIUMch05/10_llm-training-speed/01_opt_single_gpu.py362 ax2 = ax1.twiny() # Create a second x-axis that shares the same y-axis
MEDIUMch05/10_llm-training-speed/00_orig.py397 # Create a second x-axis for tokens seen
MEDIUMch05/10_llm-training-speed/00_orig.py398 ax2 = ax1.twiny() # Create a second x-axis that shares the same y-axis
MEDIUMch05/10_llm-training-speed/02_opt_multi_gpu_ddp.py426 # Create a second x-axis for tokens seen
MEDIUMch05/10_llm-training-speed/02_opt_multi_gpu_ddp.py427 ax2 = ax1.twiny() # Create a second x-axis that shares the same y-axis
MEDIUMch05/05_bonus_hparam_tuning/hparam_search.py18# Define a grid of hyperparameters to search over
MEDIUMch05/18_muon/gpt_train_muon.py166 # Create a second x-axis for tokens seen
MEDIUMch05/18_muon/gpt_train_muon.py167 ax2 = ax1.twiny() # Create a second x-axis that shares the same y-axis
MEDIUMch05/18_muon/gpt_train.py122 # Create a second x-axis for tokens seen
MEDIUMch05/18_muon/gpt_train.py123 ax2 = ax1.twiny() # Create a second x-axis that shares the same y-axis
MEDIUMpkg/llms_from_scratch/ch06.py225 # Create a second x-axis for examples seen
MEDIUMpkg/llms_from_scratch/ch06.py226 ax2 = ax1.twiny() # Create a second x-axis that shares the same y-axis
MEDIUMpkg/llms_from_scratch/ch07.py214 # Create the data payload as a dictionary
MEDIUMpkg/llms_from_scratch/ch05.py236 # Create a second x-axis for tokens seen
MEDIUMpkg/llms_from_scratch/ch05.py237 ax2 = ax1.twiny() # Create a second x-axis that shares the same y-axis
Hyper-Verbose Identifiers84 hits · 84 pts
SeverityFileLineSnippet
LOWch07/01_main-chapter-code/previous_chapters.py338def generate_and_print_sample(model, tokenizer, device, start_context):
LOWch07/01_main-chapter-code/exercise_experiments.py190def custom_collate_with_masking_fn(
LOWch07/02_dataset-utilities/find-near-duplicates.py76def find_print_and_remove_near_duplicates(json_data, remove_duplicates=False, threshold=0.75):
LOWch07/04_preference-tuning-with-dpo/previous_chapters.py339def generate_and_print_sample(model, tokenizer, device, start_context):
LOWch06/01_main-chapter-code/gpt_class_finetune.py26def download_and_unzip_spam_data(url, zip_path, extracted_path, data_file_path):
LOW…_bonus_imdb-classification/download_prepare_dataset.py31def download_and_extract_dataset(dataset_url, target_file, directory):
LOW…_bonus_imdb-classification/download_prepare_dataset.py51def load_dataset_to_dataframe(basepath="aclImdb", labels={"pos": 1, "neg": 0}):
LOWappendix-D/01_main-chapter-code/previous_chapters.py282def generate_and_print_sample(model, tokenizer, device, start_context):
LOWappendix-E/01_main-chapter-code/previous_chapters.py364def download_and_unzip_spam_data(url, zip_path, extracted_path, data_file_path):
LOWch04/06_swa/gpt_with_kv_mha.py253def generate_text_simple_cached(model, idx, max_new_tokens,
LOWch04/06_swa/tests.py12def test_cached_prefill_matches_uncached_swa():
LOWch04/06_swa/tests.py37def test_swa_matches_base_model_when_window_equals_context():
LOWch04/06_swa/plot_memory_estimates_swa.py57def calc_kv_bytes_total_mha_swa(
LOWch04/06_swa/plot_memory_estimates_swa.py75def calc_kv_bytes_total_gqa_swa(
LOWch04/06_swa/gpt_with_kv_swa.py294def generate_text_simple_cached(model, idx, max_new_tokens,
LOWch04/07_moe/plot_memory_estimates_moe.py16def calc_moe_active_and_total(
LOWch04/07_moe/plot_memory_estimates_moe.py42def plot_active_params_vs_experts(
LOWch04/07_moe/gpt_with_kv_moe.py339def generate_text_simple_cached(model, idx, max_new_tokens,
LOWch04/07_moe/memory_estimator_moe.py39def estimate_params_and_hidden(
LOWch04/07_moe/gpt_with_kv_ffn.py279def generate_text_simple_cached(model, idx, max_new_tokens,
LOWch04/04_gqa/gpt_with_kv_mha.py253def generate_text_simple_cached(model, idx, max_new_tokens,
LOWch04/04_gqa/gpt_with_kv_gqa.py265def generate_text_simple_cached(model, idx, max_new_tokens,
LOWch04/04_gqa/plot_memory_estimates_gqa.py23def plot_abs_kv_vs_context_multi_groups():
LOWch04/09_dsa/gpt_with_kv_dsa.py389def generate_text_simple_cached(model, idx, max_new_tokens,
LOWch04/09_dsa/test_dsa.py16def import_transformers_dsa_model():
LOWch04/09_dsa/test_dsa.py89def test_indexer_matches_transformers_reference():
LOWch04/09_dsa/test_dsa.py163def dense_attention_reference(attn, x):
LOWch04/09_dsa/test_dsa.py181def test_topk_full_equals_dense():
LOWch04/10_kv-sharing/gpt_with_kv_mha.py253def generate_text_simple_cached(model, idx, max_new_tokens,
LOWch04/10_kv-sharing/gpt_with_kv_sharing.py270def generate_text_simple_cached(model, idx, max_new_tokens,
LOWch04/10_kv-sharing/tests.py10def test_kv_sharing_matches_mha_when_all_layers_produce_kv():
LOWch04/10_kv-sharing/tests.py55def test_only_producer_layers_store_kv_cache():
LOWch04/10_kv-sharing/tests.py84def test_memory_estimator_counts_cached_layers():
LOW…04/08_deltanet/plot_memory_estimates_gated_deltanet.py27def calc_kv_bytes_total_deltanet_no_conv(batch, emb_dim, n_layers, bytes_per_elem, n_heads):
LOWch04/05_mla/plot_memory_estimates_mla.py33def plot_abs_kv_vs_context_multiple():
LOWch04/05_mla/gpt_with_kv_mla.py261def generate_text_simple_cached(model, idx, max_new_tokens,
LOWch04/05_mla/gpt_with_kv_mha.py253def generate_text_simple_cached(model, idx, max_new_tokens,
LOWch04/03_kv-cache/gpt_with_kv_cache.py280def generate_text_simple_cached(model, idx, max_new_tokens,
LOWch04/03_kv-cache/README.md173def generate_text_simple_cached(model, idx, max_new_tokens,
LOWch04/03_kv-cache/gpt_with_kv_cache_optimized.py306def generate_text_simple_cached(model, idx, max_new_tokens, context_size=None, use_cache=True):
LOWch04/03_kv-cache/tests.py32def test_gpt_model_equivalence_not_cached(ModelClass):
LOWch04/03_kv-cache/tests.py66def test_gpt_model_equivalence_cached(ModelClass):
LOWch04/03_kv-cache/tests.py113def test_context_overflow_bug():
LOWch04/03_kv-cache/tests.py150def test_prefill_chunking_basic():
LOWch02/05_bpe-from-scratch/tests.py11def import_definitions_from_notebook(fullname, names):
LOWch02/05_bpe-from-scratch/tests.py185def test_no_eot_aliasing_and_disallowed_logic(imported_module, gpt2_files):
LOWch02/05_bpe-from-scratch/tests.py214def test_newline_roundtrip_and_equivalence(imported_module, gpt2_files, text):
LOWch02/05_bpe-from-scratch/tests.py234def test_space_newline_space_patterns(imported_module, gpt2_files):
LOWch02/05_bpe-from-scratch/tests.py250def test_multiple_leading_spaces_roundtrip(imported_module, gpt2_files):
LOWch05/16_qwen3.5/qwen3_5_transformers.py66def apply_mask_to_padding_states(hidden_states, attention_mask):
LOWch05/16_qwen3.5/qwen3_5_transformers.py102def torch_chunk_gated_delta_rule(
LOWch05/16_qwen3.5/qwen3_5_transformers.py182def torch_recurrent_gated_delta_rule(
LOWch05/01_main-chapter-code/gpt_train.py61def generate_and_print_sample(model, tokenizer, device, start_context):
LOWch05/15_tiny-aya/tests/test_tiny_aya_nb.py54def test_dummy_tiny_aya_forward(dummy_cfg_base, dummy_input, import_notebook_defs):
LOWch05/15_tiny-aya/tests/test_tiny_aya_nb.py64def test_tiny_aya_base_equivalence_with_transformers(import_notebook_defs):
LOWch05/15_tiny-aya/tests/test_tiny_aya_kvcache_nb.py55def test_dummy_tiny_aya_forward(dummy_cfg_base, dummy_input, import_notebook_defs):
LOWch05/15_tiny-aya/tests/test_tiny_aya_kvcache_nb.py65def test_tiny_aya_base_equivalence_with_transformers(import_notebook_defs):
LOWch05/07_gpt_to_llama/tests/tests_rope_and_parts.py97 def import_definitions_from_notebook(notebooks):
LOWch05/10_llm-training-speed/01_opt_single_gpu.py255def generate_and_print_sample(model, tokenizer, device, start_context):
LOWch05/10_llm-training-speed/01_opt_single_gpu.py269def train_model_simple_with_timing(model, train_loader, val_loader, optimizer, device,
24 more matches not shown…
Deep Nesting47 hits · 47 pts
SeverityFileLineSnippet
LOWch07/01_main-chapter-code/gpt_download.py48
LOWch07/01_main-chapter-code/gpt_download.py49
LOWch07/02_dataset-utilities/find-near-duplicates.py41
LOWch06/01_main-chapter-code/gpt_download.py47
LOWch06/01_main-chapter-code/gpt_download.py48
LOWch06/02_bonus_additional-experiments/gpt_download.py47
LOWch06/02_bonus_additional-experiments/gpt_download.py48
LOW…bonus_additional-experiments/additional_experiments.py257
LOW…_bonus_imdb-classification/download_prepare_dataset.py31
LOW…_bonus_imdb-classification/download_prepare_dataset.py51
LOWch06/03_bonus_imdb-classification/gpt_download.py47
LOWch06/03_bonus_imdb-classification/gpt_download.py48
LOW…nstalling-python-libraries/python_environment_check.py20
LOWappendix-E/01_main-chapter-code/gpt_download.py47
LOWappendix-E/01_main-chapter-code/gpt_download.py48
LOWch04/07_moe/gpt_with_kv_moe.py339
LOWch04/07_moe/gpt_with_kv_ffn.py279
LOWch02/02_bonus_bytepair-encoder/bpe_openai_gpt2.py148
LOWch05/16_qwen3.5/tests/qwen3_5_layer_debugger.py248
LOW…3_bonus_pretraining_on_gutenberg/pretraining_simple.py80
LOWch05/12_gemma3/tests/gemma3_layer_debugger.py206
LOWch05/01_main-chapter-code/gpt_download.py48
LOWch05/01_main-chapter-code/gpt_download.py49
LOWch05/01_main-chapter-code/gpt_generate.py62
LOWch05/15_tiny-aya/tests/tiny_aya_layer_debugger.py199
LOWch05/07_gpt_to_llama/tests/tests_rope_and_parts.py96
LOWch05/07_gpt_to_llama/tests/tests_rope_and_parts.py97
LOWch05/13_olmo3/tests/olmo3_layer_debugger.py251
LOW…/17_gemma4/tests/test_e4b/gemma4_e4b_layer_debugger.py258
LOW…/17_gemma4/tests/test_e2b/gemma4_e2b_layer_debugger.py270
LOWch05/10_llm-training-speed/01_opt_single_gpu.py269
LOWch05/10_llm-training-speed/00_orig.py305
LOWch05/10_llm-training-speed/02_opt_multi_gpu_ddp.py314
LOW…qwen3-chat-interface/qwen3-chat-interface-multiturn.py33
LOW…/11_qwen3/qwen3-chat-interface/qwen3-chat-interface.py32
LOW.github/scripts/check_double_quotes.py76
LOWpkg/llms_from_scratch/utils.py17
LOWpkg/llms_from_scratch/utils.py39
LOWpkg/llms_from_scratch/utils.py110
LOWpkg/llms_from_scratch/utils.py153
LOWpkg/llms_from_scratch/qwen3.py653
LOWpkg/llms_from_scratch/ch05.py280
LOWpkg/llms_from_scratch/ch05.py281
LOWpkg/llms_from_scratch/appendix_d.py23
LOWpkg/llms_from_scratch/tests/test_qwen3.py63
LOWpkg/llms_from_scratch/tests/test_qwen3.py614
LOWpkg/llms_from_scratch/tests/test_qwen3.py688
Cross-File Repetition8 hits · 40 pts
SeverityFileLineSnippet
HIGHch06/01_main-chapter-code/gpt_download.py0def download_file(url, destination): # send a get request to download the file in streaming mode response = requests.get
HIGHch06/02_bonus_additional-experiments/gpt_download.py0def download_file(url, destination): # send a get request to download the file in streaming mode response = requests.get
HIGHch06/03_bonus_imdb-classification/gpt_download.py0def download_file(url, destination): # send a get request to download the file in streaming mode response = requests.get
HIGHappendix-E/01_main-chapter-code/gpt_download.py0def download_file(url, destination): # send a get request to download the file in streaming mode response = requests.get
HIGHch05/01_main-chapter-code/gpt_download.py0def download_file(url, destination): # send a get request to download the file in streaming mode response = requests.get
HIGHch05/10_llm-training-speed/02_opt_multi_gpu_ddp.py0arguments: rank: a unique process id world_size: total number of processes in the group
HIGHappendix-A/01_main-chapter-code/DDP-script.py0arguments: rank: a unique process id world_size: total number of processes in the group
HIGHappendix-A/01_main-chapter-code/DDP-script-torchrun.py0arguments: rank: a unique process id world_size: total number of processes in the group
Decorative Section Separators10 hits · 39 pts
SeverityFileLineSnippet
MEDIUM…qwen3-chat-interface/qwen3-chat-interface-multiturn.py22# ============================================================
MEDIUM…qwen3-chat-interface/qwen3-chat-interface-multiturn.py24# ============================================================
MEDIUM…qwen3-chat-interface/qwen3-chat-interface-multiturn.py30# ============================================================
MEDIUM…/11_qwen3/qwen3-chat-interface/qwen3-chat-interface.py21# ============================================================
MEDIUM…/11_qwen3/qwen3-chat-interface/qwen3-chat-interface.py23# ============================================================
MEDIUM…/11_qwen3/qwen3-chat-interface/qwen3-chat-interface.py29# ============================================================
MEDIUMpkg/llms_from_scratch/llama3.py208# ==============================================================================
MEDIUMpkg/llms_from_scratch/llama3.py257# ==============================================================================
MEDIUMpkg/llms_from_scratch/qwen3.py332# ==============================================================================
MEDIUMpkg/llms_from_scratch/qwen3.py381# ==============================================================================
Excessive Try-Catch Wrapping29 hits · 35 pts
SeverityFileLineSnippet
LOWch07/01_main-chapter-code/gpt_download.py91 except Exception as e:
LOWch06/01_main-chapter-code/gpt_download.py91 except Exception as e:
LOWch06/02_bonus_additional-experiments/gpt_download.py91 except Exception as e:
LOWch06/03_bonus_imdb-classification/gpt_download.py91 except Exception as e:
LOW…nstalling-python-libraries/python_environment_check.py90 except Exception as e:
LOWappendix-E/01_main-chapter-code/gpt_download.py91 except Exception as e:
LOWch04/06_swa/plot_memory_estimates_swa.py38 except Exception:
LOWch04/06_swa/memory_estimator_swa.py37 except Exception:
LOWch05/16_qwen3.5/tests/qwen3_5_layer_debugger.py20 except Exception:
LOWch05/16_qwen3.5/tests/qwen3_5_layer_debugger.py39except Exception:
MEDIUMch05/16_qwen3.5/tests/qwen3_5_layer_debugger.py14def _import_qwen3_5_classes():
LOWch05/16_qwen3.5/tests/test_qwen3_5_nb.py22 except Exception:
LOWch05/16_qwen3.5/tests/test_qwen3_5_nb.py43 except Exception:
MEDIUMch05/16_qwen3.5/tests/test_qwen3_5_nb.py16def _import_qwen3_5_classes():
LOWch05/01_main-chapter-code/gpt_download.py91 except Exception as e:
LOWch05/17_gemma4/tests/test_gemma4_nb.py77 except Exception:
MEDIUMch05/17_gemma4/tests/test_gemma4_nb.py71def gemma4_transformers_module():
LOW…/17_gemma4/tests/test_e4b/gemma4_e4b_layer_debugger.py20 except Exception:
LOW…/17_gemma4/tests/test_e4b/gemma4_e4b_layer_debugger.py42except Exception:
MEDIUM…/17_gemma4/tests/test_e4b/gemma4_e4b_layer_debugger.py15def _import_gemma4_classes():
LOW…/17_gemma4/tests/test_e2b/gemma4_e2b_layer_debugger.py20 except Exception:
LOW…/17_gemma4/tests/test_e2b/gemma4_e2b_layer_debugger.py42except Exception:
MEDIUM…/17_gemma4/tests/test_e2b/gemma4_e2b_layer_debugger.py15def _import_gemma4_classes():
LOW.github/scripts/check_double_quotes.py111 except Exception as e:
MEDIUM.github/scripts/check_double_quotes.py104def check_file(path):
LOWpkg/llms_from_scratch/utils.py171 except Exception as e:
LOWpkg/llms_from_scratch/ch05.py323 except Exception as e:
LOWpkg/llms_from_scratch/tests/test_qwen3.py77 except Exception:
LOWpkg/llms_from_scratch/tests/test_qwen3.py638 except Exception:
Redundant / Tautological Comments28 hits · 30 pts
SeverityFileLineSnippet
LOWch07/01_main-chapter-code/previous_chapters.py301 model.train() # Set model to training mode
LOWch07/01_main-chapter-code/gpt_download.py55 # Check if file exists and has same size
LOWch07/04_preference-tuning-with-dpo/previous_chapters.py302 model.train() # Set model to training mode
LOWch06/01_main-chapter-code/gpt_class_finetune.py190 model.train() # Set model to training mode
LOWch06/01_main-chapter-code/gpt_download.py54 # Check if file exists and has same size
LOWch06/01_main-chapter-code/gpt_download.py104 # Check if file exists and has the same size
LOWch06/02_bonus_additional-experiments/gpt_download.py54 # Check if file exists and has same size
LOWch06/02_bonus_additional-experiments/gpt_download.py104 # Check if file exists and has the same size
LOW…bonus_additional-experiments/additional_experiments.py338 model.train() # Set model to training mode
LOWch06/03_bonus_imdb-classification/train_bert_hf_spam.py237 model.train() # Set model to training mode
LOWch06/03_bonus_imdb-classification/train_gpt.py184 model.train() # Set model to training mode
LOWch06/03_bonus_imdb-classification/gpt_download.py54 # Check if file exists and has same size
LOWch06/03_bonus_imdb-classification/gpt_download.py104 # Check if file exists and has the same size
LOWch06/03_bonus_imdb-classification/train_gpt_muon.py219 model.train() # Set model to training mode
LOWch06/03_bonus_imdb-classification/train_bert_hf.py140 model.train() # Set model to training mode
LOW…nal-aws-sagemaker-notebook/cloudformation-template.yml119 # Check if setup is still running or not started
LOWappendix-E/01_main-chapter-code/previous_chapters.py500 model.train() # Set model to training mode
LOWappendix-E/01_main-chapter-code/gpt_download.py54 # Check if file exists and has same size
LOWappendix-E/01_main-chapter-code/gpt_download.py104 # Check if file exists and has the same size
LOWch05/01_main-chapter-code/gpt_train.py84 model.train() # Set model to training mode
LOWch05/01_main-chapter-code/gpt_download.py55 # Check if file exists and has same size
LOWch05/01_main-chapter-code/gpt_download.py104 # Check if file exists and has the same size
LOWch05/01_main-chapter-code/gpt_generate.py70 # Check if file exists and has the same size
LOWch05/18_muon/gpt_train_muon.py120 model.train() # Set model to training mode
LOWch05/18_muon/gpt_train.py84 model.train() # Set model to training mode
LOWpkg/llms_from_scratch/ch06.py185 model.train() # Set model to training mode
LOWpkg/llms_from_scratch/ch05.py70 model.train() # Set model to training mode
LOWpkg/llms_from_scratch/ch05.py287 # Check if file exists and has same size
Unused Imports26 hits · 26 pts
SeverityFileLineSnippet
LOWpkg/llms_from_scratch/kv_cache/gpt2.py6
LOWpkg/llms_from_scratch/kv_cache/generate.py6
LOWpkg/llms_from_scratch/kv_cache/llama3.py6
LOWpkg/llms_from_scratch/kv_cache/qwen3.py6
LOWpkg/llms_from_scratch/kv_cache/qwen3.py7
LOWpkg/llms_from_scratch/kv_cache/qwen3.py7
LOWpkg/llms_from_scratch/kv_cache/qwen3.py7
LOWpkg/llms_from_scratch/kv_cache/qwen3.py7
LOWpkg/llms_from_scratch/kv_cache/qwen3.py7
LOWpkg/llms_from_scratch/kv_cache/qwen3.py7
LOWpkg/llms_from_scratch/kv_cache/qwen3.py7
LOWpkg/llms_from_scratch/kv_cache/qwen3.py7
LOWpkg/llms_from_scratch/kv_cache/qwen3.py7
LOWpkg/llms_from_scratch/kv_cache/qwen3.py7
LOWpkg/llms_from_scratch/kv_cache_batched/generate.py6
LOWpkg/llms_from_scratch/kv_cache_batched/qwen3.py6
LOWpkg/llms_from_scratch/kv_cache_batched/qwen3.py7
LOWpkg/llms_from_scratch/kv_cache_batched/qwen3.py7
LOWpkg/llms_from_scratch/kv_cache_batched/qwen3.py7
LOWpkg/llms_from_scratch/kv_cache_batched/qwen3.py7
LOWpkg/llms_from_scratch/kv_cache_batched/qwen3.py7
LOWpkg/llms_from_scratch/kv_cache_batched/qwen3.py7
LOWpkg/llms_from_scratch/kv_cache_batched/qwen3.py7
LOWpkg/llms_from_scratch/kv_cache_batched/qwen3.py7
LOWpkg/llms_from_scratch/kv_cache_batched/qwen3.py7
LOWpkg/llms_from_scratch/kv_cache_batched/qwen3.py7
Over-Commented Block23 hits · 23 pts
SeverityFileLineSnippet
LOWch06/01_main-chapter-code/previous_chapters.py1# Copyright (c) Sebastian Raschka under Apache License 2.0 (see LICENSE.txt).
LOW…6/02_bonus_additional-experiments/previous_chapters.py1# Copyright (c) Sebastian Raschka under Apache License 2.0 (see LICENSE.txt).
LOWch06/03_bonus_imdb-classification/previous_chapters.py1# Copyright (c) Sebastian Raschka under Apache License 2.0 (see LICENSE.txt).
LOWch04/07_moe/gpt_with_kv_ffn.py141 torch.sqrt(torch.tensor(2.0 / torch.pi)) *
LOWch04/09_dsa/gpt_with_kv_dsa.py1# Copyright (c) Sebastian Raschka under Apache License 2.0 (see LICENSE.txt).
LOWch04/09_dsa/gpt_with_kv_dsa.py21
LOWch04/05_mla/gpt_with_kv_mla.py1# Copyright (c) Sebastian Raschka under Apache License 2.0 (see LICENSE.txt).
LOWch02/02_bonus_bytepair-encoder/bpe_openai_gpt2.py1# Source: https://github.com/openai/gpt-2/blob/master/src/encoder.py
LOWch05/01_main-chapter-code/previous_chapters.py1# Copyright (c) Sebastian Raschka under Apache License 2.0 (see LICENSE.txt).
LOWch05/07_gpt_to_llama/previous_chapters.py1# Copyright (c) Sebastian Raschka under Apache License 2.0 (see LICENSE.txt).
LOWch05/10_llm-training-speed/01_opt_single_gpu.py501 epochs_tensor = torch.linspace(0, OTHER_SETTINGS["num_epochs"], len(train_losses))
LOWch05/10_llm-training-speed/00_orig.py521 ###########################
LOWch05/10_llm-training-speed/02_opt_multi_gpu_ddp.py601 # torch.save(model._orig_mod.state_dict(), "model.pth")
LOWch05/18_muon/previous_chapters.py1# Copyright (c) Sebastian Raschka under Apache License 2.0 (see LICENSE.txt).
LOWpkg/llms_from_scratch/ch07.py41# if not os.path.exists(file_path):
LOWpkg/llms_from_scratch/__init__.py1# Copyright (c) Sebastian Raschka under Apache License 2.0 (see LICENSE.txt).
LOWpkg/llms_from_scratch/llama3.py201 # Combine heads, where self.d_out = self.num_heads * self.head_dim
LOWpkg/llms_from_scratch/llama3.py221# │ │ │ │ │ │ │ │
LOWpkg/llms_from_scratch/llama3.py241# [ x0 x1 x2 x3 x4 x5 x6 x7 ]
LOWpkg/llms_from_scratch/qwen3.py341#
LOWpkg/llms_from_scratch/qwen3.py361# 2) Interleaved (even/odd) style (original paper, Llama repo):
LOWpkg/llms_from_scratch/kv_cache/__init__.py1# Copyright (c) Sebastian Raschka under Apache License 2.0 (see LICENSE.txt).
LOWpkg/llms_from_scratch/kv_cache_batched/__init__.py1# Copyright (c) Sebastian Raschka under Apache License 2.0 (see LICENSE.txt).
AI Slop Vocabulary1 hit · 3 pts
SeverityFileLineSnippet
MEDIUMpkg/llms_from_scratch/ch07.py33# The `requests` version above is more robust
Slop Phrases1 hit · 2 pts
SeverityFileLineSnippet
MEDIUM…-tuning-with-dpo/instruction-data-with-preference.json3520 "chosen": "It's worth noting that the most popular vegetable in the world is actually the potato.",