Repository Analysis

datawhalechina/happy-llm

📚 从零开始构建大模型

5.6 Low AI signal View on GitHub

Analysis Overview

This report presents the forensic synthetic code analysis of datawhalechina/happy-llm, a Jupyter Notebook project with 32,078 GitHub stars. SynthScan v2.0 examined 32,980 lines of code across 69 source files, recording 139 pattern matches distributed across 11 syntactic categories. The overall adjusted score of 5.6 places this repository in the Low 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).

5.6
Adjusted Score
5.6
Raw Score
100%
Time Factor
2026-05-06
Last Push
32.1K
Stars
Jupyter Notebook
Language
33.0K
Lines of Code
69
Files
139
Pattern Hits
2026-07-14
Scan Date
0.10
HC Hit Rate

What These Metrics Mean

Adjusted Score
Primary synthetic code indicator. Raw score normalised per 1,000 lines of code and multiplied by the temporal discount factor. This is the definitive comparative metric — use it to rank repositories by AI authorship density.
Raw Score
The unmodified sum of all severity-weighted, context-multiplied pattern match scores before temporal discounting. Reflects the absolute signal strength independent of when the repository was last active.
Time Factor
The temporal discount multiplier (0–100%) applied to the raw score. Repositories last updated before ChatGPT's launch (Nov 2022) receive a 5% factor. Full signal is only assigned to repositories active in the post-adoption era (Jan 2024+).
Pattern Hits
Total count of individual pattern matches across all files and categories. A high hit count with a low score may indicate a very large codebase with isolated AI snippets; a low count with a high score indicates dense, concentrated AI signatures.
HC Hit Rate
High+Critical pattern hits per file, averaged across the repository. This orthogonal signal catches repositories where a few files are densely packed with high-severity AI tells — a strong indicator even when the normalised score appears moderate due to codebase size.
Lines of Code / Files
Total lines and files analysed. The scanner examines 94 file extensions. These denominators are used to normalise the score, enabling fair comparison between repositories of vastly different sizes.

Score History

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.

Severity Breakdown

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.

CRITICAL 0HIGH 7MEDIUM 11LOW 121

Directory Score Breakdown

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.

Pattern Findings

The scanner identified 139 distinct pattern matches across 11 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.

Unused Imports71 hits · 71 pts
SeverityFileLineSnippetContext
LOWdocs/chapter6/code/download_dataset.py2CODE
LOWdocs/chapter6/code/download_dataset.py3CODE
LOWdocs/chapter6/code/pretrain.py6CODE
LOWdocs/chapter6/code/pretrain.py12CODE
LOWdocs/chapter6/code/pretrain.py16CODE
LOWdocs/chapter6/code/pretrain.py17CODE
LOWdocs/chapter6/code/pretrain.py30CODE
LOWdocs/chapter6/code/pretrain.py31CODE
LOWdocs/chapter6/code/finetune.py6CODE
LOWdocs/chapter6/code/finetune.py11CODE
LOWdocs/chapter6/code/finetune.py12CODE
LOWdocs/chapter6/code/finetune.py13CODE
LOWdocs/chapter6/code/finetune.py19CODE
LOWdocs/chapter6/code/finetune.py21CODE
LOWdocs/chapter6/code/finetune.py23CODE
LOWdocs/chapter6/code/finetune.py23CODE
LOWdocs/chapter6/code/finetune.py33CODE
LOWdocs/chapter6/code/finetune.py34CODE
LOWdocs/chapter7/Agent/demo.py2CODE
LOWdocs/chapter7/Agent/demo.py2CODE
LOWdocs/chapter7/Agent/demo.py2CODE
LOWdocs/chapter7/Agent/web_demo.py3CODE
LOWdocs/chapter7/Agent/web_demo.py3CODE
LOWdocs/chapter7/Agent/web_demo.py3CODE
LOWdocs/chapter7/Agent/src/core.py5CODE
LOWdocs/chapter7/Agent/src/core.py5CODE
LOWdocs/chapter7/Agent/src/core.py5CODE
LOWdocs/chapter7/Agent/src/core.py5CODE
LOWdocs/chapter7/Agent/src/core.py5CODE
LOWdocs/chapter7/Agent/src/core.py5CODE
LOWdocs/chapter7/Agent/src/core.py7CODE
LOWdocs/chapter7/Agent/src/utils.py2CODE
LOWdocs/chapter7/Agent/src/utils.py3CODE
LOWdocs/chapter7/RAG/VectorBase.py12CODE
LOWdocs/chapter7/RAG/VectorBase.py12CODE
LOWdocs/chapter7/RAG/VectorBase.py12CODE
LOWdocs/chapter7/RAG/VectorBase.py12CODE
LOWdocs/chapter7/RAG/VectorBase.py14CODE
LOWdocs/chapter7/RAG/LLM.py11CODE
LOWdocs/chapter7/RAG/LLM.py11CODE
LOWdocs/chapter7/RAG/LLM.py11CODE
LOWdocs/chapter7/RAG/LLM.py11CODE
LOWdocs/chapter7/RAG/Embeddings.py12CODE
LOWdocs/chapter7/RAG/Embeddings.py13CODE
LOWdocs/chapter7/RAG/Embeddings.py13CODE
LOWdocs/chapter7/RAG/Embeddings.py13CODE
LOWdocs/chapter7/RAG/Embeddings.py13CODE
LOWdocs/chapter7/RAG/utils.py12CODE
LOWdocs/chapter7/RAG/utils.py12CODE
LOWdocs/chapter7/RAG/utils.py12CODE
LOWdocs/chapter7/RAG/utils.py12CODE
LOWdocs/chapter7/RAG/utils.py12CODE
LOWdocs/chapter7/RAG/utils.py17CODE
LOWdocs/chapter5/code/ddp_pretrain.py3CODE
LOWdocs/chapter5/code/ddp_pretrain.py8CODE
LOWdocs/chapter5/code/deal_dataset.py1CODE
LOWdocs/chapter5/code/k_model.py2CODE
LOWdocs/chapter5/code/k_model.py3CODE
LOWdocs/chapter5/code/k_model.py4CODE
LOWdocs/chapter5/code/dataset.py2CODE
11 more matches not shown…
Structural Annotation Overuse19 hits · 26 pts
SeverityFileLineSnippetContext
LOWdocs/chapter7/第七章 大模型应用.md107#### Step 1: RAG流程介绍COMMENT
LOWdocs/chapter7/第七章 大模型应用.md139#### Step 2: 文档加载和切分COMMENT
LOWdocs/chapter7/第七章 大模型应用.md237#### Step 3: 向量化COMMENT
LOWdocs/chapter7/第七章 大模型应用.md337#### Step 4: 数据库与向量检索COMMENT
LOWdocs/chapter7/第七章 大模型应用.md381#### Step 5: 大模型模块COMMENT
LOWdocs/chapter7/第七章 大模型应用.md440#### Step 6: Tiny-RAG DemoSTRING
LOWdocs/chapter7/第七章 大模型应用.md546#### Step 1 : 初始化客户端和模型STRING
LOWdocs/chapter7/第七章 大模型应用.md565#### Step 2: 定义工具函数STRING
LOWdocs/chapter7/第七章 大模型应用.md640#### Step 3: 构造 Agent 类STRING
LOWdocs/chapter7/第七章 大模型应用.md738#### Step 4: 运行 AgentSTRING
LOWdocs/chapter5/第五章 动手搭建大模型.md743#### Step 1: 安装和导入依赖库COMMENT
LOWdocs/chapter5/第五章 动手搭建大模型.md769#### Step 2: 加载训练数据COMMENT
LOWdocs/chapter5/第五章 动手搭建大模型.md793#### Step 3: 创建配置文件COMMENT
LOWdocs/chapter5/第五章 动手搭建大模型.md843#### Step 4: 训练 BPE TokenizerCOMMENT
LOWdocs/chapter5/第五章 动手搭建大模型.md903#### Step 5: 使用训练好的 TokenizerCOMMENT
LOW…r/s1-vllm-thinking-budget/output/output_1754208752.txt1969### Step 1: Understanding the Critical PointsCOMMENT
LOW…r/s1-vllm-thinking-budget/output/output_1754208752.txt1995### Step 2: Behavior of the PolynomialCOMMENT
LOW…r/s1-vllm-thinking-budget/output/output_1754208752.txt2009### Step 3: Symmetry and RootsCOMMENT
LOW…r/s1-vllm-thinking-budget/output/output_1754208752.txt2029### Step 4: Final CalculationCOMMENT
Excessive Try-Catch Wrapping12 hits · 20 pts
SeverityFileLineSnippetContext
MEDIUMdocs/chapter5/第五章 动手搭建大模型.md786 print(f"Error decoding JSON in line {line_num}")CODE
LOWdocs/chapter5/第五章 动手搭建大模型.md912 except Exception as e:CODE
MEDIUMdocs/chapter5/第五章 动手搭建大模型.md913 print(f"Error loading tokenizer: {e}")CODE
MEDIUMdocs/chapter5/第五章 动手搭建大模型.md1094 print(f"Error decoding JSON in line {line_num}")CODE
LOWdocs/chapter5/第五章 动手搭建大模型.md1199 except Exception as e:CODE
MEDIUMdocs/chapter5/第五章 动手搭建大模型.md1200 print(f"Error loading tokenizer: {e}")CODE
MEDIUMdocs/chapter5/code/train_tokenizer.py27 print(f"Error decoding JSON in line {line_num}")CODE
LOWdocs/chapter5/code/train_tokenizer.py132 except Exception as e:CODE
MEDIUMdocs/chapter5/code/train_tokenizer.py133 print(f"Error loading tokenizer: {e}")CODE
LOWExtra-Chapter/CDDRS/readme.md160 except Exception as e:CODE
MEDIUMExtra-Chapter/CDDRS/readme.md161 print(f"Error reading {file_path}: {e}")CODE
LOWExtra-Chapter/generation-method/llm_generation.py149 except Exception as e:CODE
Magic Placeholder Names5 hits · 18 pts
SeverityFileLineSnippetContext
HIGHdocs/chapter7/第七章 大模型应用.md555 api_key="YOUR_API_KEY", # 替换为你的 API KeySTRING
HIGHdocs/chapter7/第七章 大模型应用.md563> **注意:** 你需要将 `YOUR_API_KEY` 替换为你从 [SiliconFlow](https://cloud.siliconflow.cn/i/ybUFvmqK) 或其他服务商获取的有效 API Key。STRING
HIGHdocs/chapter7/第七章 大模型应用.md746 api_key="YOUR_API_KEY", # 替换为你的 API KeySTRING
HIGHExtra-Chapter/CDDRS/readme.md80 api_key="your-api-key-here",CODE
HIGHExtra-Chapter/CDDRS/readme.md786 api_key='your-api-key',STRING
Modern AI Meta-Vocabulary4 hits · 14 pts
SeverityFileLineSnippetContext
MEDIUMdocs/chapter7/第七章 大模型应用.md93## 7.2 RAGCOMMENT
MEDIUMdocs/chapter7/第七章 大模型应用.md95### 7.2.1 RAG 的基本原理COMMENT
MEDIUMdocs/chapter7/第七章 大模型应用.md103### 7.2.2 搭建一个 RAG 框架COMMENT
MEDIUMdocs/chapter7/第七章 大模型应用.md440#### Step 6: Tiny-RAG DemoSTRING
Docstring Block Structure2 hits · 10 pts
SeverityFileLineSnippetContext
HIGHdocs/chapter7/第七章 大模型应用.md259 获取文本的嵌入向量表示 Args: text (str): 输入文本 model (str): 使用的模型名称 Returns: STRING
HIGHdocs/chapter7/RAG/Embeddings.py36 获取文本的嵌入向量表示 Args: text (str): 输入文本 model (str): 使用的模型名称 Returns: STRING
AI Structural Patterns8 hits · 8 pts
SeverityFileLineSnippetContext
LOWdocs/chapter6/code/pretrain.py180CODE
LOWdocs/chapter5/code/k_model.py16CODE
LOWdocs/chapter5/code/k_model.py248CODE
LOWdocs/chapter5/code/k_model.py307CODE
LOWdocs/chapter5/code/k_model.py677CODE
LOWdocs/chapter2/code/transformer.py98CODE
LOWdocs/chapter2/code/transformer.py151CODE
LOWdocs/chapter2/code/transformer.py192CODE
Hyper-Verbose Identifiers9 hits · 8 pts
SeverityFileLineSnippetContext
LOWdocs/chapter5/code/k_model.py378 def _left_pad_by_attention_mask(CODE
LOWExtra-Chapter/CDDRS/readme.md246 def _compute_semantic_discrepancy(self, embeddings: np.ndarray) -> List[float]:CODE
LOWExtra-Chapter/CDDRS/readme.md283 def _enforce_length_constraints(self, chunks: List[str]) -> List[str]:CODE
LOWExtra-Chapter/CDDRS/readme.md423def compute_document_length_factor(chunk_length: int, avg_length: int = 100) -> float:STRING
LOWExtra-Chapter/CDDRS/readme.md437def compute_term_significance(term_freq: int, doc_length_factor: float) -> float:STRING
LOWExtra-Chapter/CDDRS/readme.md559 def _compute_knowledge_scores(self, key_info: Dict[str, Tuple[str, float]]) -> List[float]:STRING
LOWExtra-Chapter/text-data-processing/readme.md932def test_simple_bpe_tokenizer():CODE
LOWExtra-Chapter/s1-vllm-thinking-budget/s1.py28def run_thinking_budget_sample(llm_model, tokenizer, user_input, thinking_budget):CODE
LOWExtra-Chapter/s1-vllm-thinking-budget/readme.md41def run_thinking_budget_sample(llm_model, tokenizer, user_input, thinking_budget):CODE
Deep Nesting5 hits · 5 pts
SeverityFileLineSnippetContext
LOWdocs/chapter6/code/finetune.py87CODE
LOWdocs/chapter7/RAG/utils.py34CODE
LOWdocs/chapter7/RAG/utils.py61CODE
LOWdocs/chapter5/code/dataset.py65CODE
LOWdocs/chapter5/code/train_tokenizer.py17CODE
Modern Structural Boilerplate2 hits · 2 pts
SeverityFileLineSnippetContext
LOWdocs/chapter6/code/pretrain.py36logger = logging.getLogger(__name__)CODE
LOWdocs/chapter6/code/finetune.py40logger = logging.getLogger(__name__)CODE
Over-Commented Block2 hits · 2 pts
SeverityFileLineSnippetContext
LOWdocs/chapter5/code/k_model.py61 def forward(self, x):COMMENT
LOWdocs/chapter2/第二章 Transformer架构.md301 # 注意力计算COMMENT