2 views
jingyaogong/minimind
🧠 两小时从 0 训出你的 64M 大模型。Train your own 64M LLM from scratch in 2 hours.
Python★ 69,641+828 that day#2 on trending
D52.3/100
Duplication35
17.1% in pythonDead code84
1.4%Complexity50
63.1% The score is jscpd's own --health model: markup, data and text left out, tests kept. The numbers below are the trending scan's.
17.09%duplicated code · 810 of 4,739 lines
68clones in code
20code files of 34 scanned
3.19%duplicated over all files · 97 clones
Most complex files
Dead code 1.43% unused · 23 findings
- scripts/chat_api.pyunused-file
- dataset/lm_dataset.py:Sequenceunused-import
- model/model_lora.py:optimunused-import
- trainer/rollout_engine.py:Tupleunused-import
- trainer/train_agent.py:datasetsunused-import
- trainer/train_agent.py:gcunused-import
- trainer/train_agent.py:AutoTokenizerunused-import
- trainer/train_agent.py:MiniMindForCausalLMunused-import
- trainer/train_distillation.py:datasetsunused-import
- trainer/train_dpo.py:datasetsunused-import
The code number leaves out tests, fixtures, docs, examples, data files, styles, translations and vendored code.
Largest clones in the code
- 49 lines in 2 placespython470 tokens
19from trainer.trainer_utils import get_lr, Logger, is_main_process, lm_checkpoint, init_distributed_mode, setup_seed, init_model, SkipBatchSampler, resolve_dtype 20 21warnings.filterwarnings('ignore') 22 23 24def train_epoch(epoch, loader, iters, start_step=0, wandb=None): 25 start_time = time.time() 26 for step, (input_ids, labels) in enumerate(loader, start=start_step + 1): 27 input_ids = input_ids.to(args.device) 28 labels = labels.to(args.device)First 10 of 49 lines.
- 20 lines in 3 placespython192 tokens
153setup_seed(42 + (dist.get_rank() if dist.is_initialized() else 0)) 154 155# ========== 2. 配置目录、模型参数、检查ckp ========== 156os.makedirs(args.save_dir, exist_ok=True) 157lm_config = MiniMindConfig(hidden_size=args.hidden_size, num_hidden_layers=args.num_hidden_layers, use_moe=bool(args.use_moe)) 158ckp_data = lm_checkpoint(lm_config, weight=args.save_weight, save_dir='../checkpoints') if args.from_resume==1 else None 159 160# ========== 3. 设置混合精度 ========== 161device_type = "cuda" if torch.device(args.device).type == "cuda" else "cpu" 162args.dtype = resolve_dtype(args.dtype, args.device)First 10 of 20 lines.
- 31 lines in 2 placespython284 tokens
206train_ds = SFTDataset(args.data_path, tokenizer, max_length=args.max_seq_len) 207train_sampler = DistributedSampler(train_ds) if dist.is_initialized() else None 208scaler = torch.cuda.amp.GradScaler(enabled=(args.dtype == 'float16')) 209optimizer = optim.AdamW(model.parameters(), lr=args.learning_rate) 210 211# ========== 6. 从ckp恢复状态 ========== 212start_epoch, start_step = 0, 0 213if ckp_data: 214 model.load_state_dict(ckp_data['model']) 215 optimizer.load_state_dict(ckp_data['optimizer'])First 10 of 31 lines.
7 more
- 15 lines in 3 placespython132 tokens
- 26 lines in 2 placespython244 tokens
- 7 lines in 3 placespython122 tokens
- 11 lines in 3 placespython104 tokens
- 26 lines in 2 placespython195 tokens
- 25 lines in 2 placespython191 tokens
- 22 lines in 2 placespython183 tokens
Largest clones over all files, tests and data included
- 95 lines in 2 placestextdocs and examples1,570 tokens
1375[A]: 鲁迅的《狂人日记》是其作品中对封建礼教的批判,主要通过以下几个方面进行批判:1. **文学结构的变革**:《狂人日记》在文学上进行了大量的反思和批判,从最初的虚构世界为封建礼教的建立埋下了根基。然而,随着社会观念的转变,一些人开始反思封建礼教的性质和目的,比如对社会秩序的忽视、对个人自由的质疑,以及对社会不… 1376[B]: 鲁迅的《狂人日记》是中国古典四大名著之一,全称为《后传》。这部作品通过细腻的笔触,展现了中国社会的复杂与深邃。1. **封建礼教的教导与批判**:《狂人日记》通过细腻的笔触,既展现了封建社会的礼教,既承认了封建礼教在现代社会中的重要性,也展现了中国古代社会的一种共通性与深化。2. **对社会与文化的深刻反思… 1377[C]: 鲁迅是中国现代文学史上第一位作家,他于1912年出版,自诞生以来便以诗歌为题,通过多次诠释封建礼教的复杂性与多面性。鲁迅通过他的批判性视角,不仅在文学与社会交汇处绽放共舞,更在无垠共舞间编织共舞的璀璨篇章。1. **批判与共舞**:鲁迅通过细腻的笔触与深刻的思考,既在形式与深度间共舞。他既在知识与共舞间绽放… 1378``` 1379 1380 1381### 测试2:轻 Agent 任务对比 1382 1383一个基于 `eval_toolcall` 脚本改出来的测试,用一组数学 ToolUse 任务,对比当前 `agent` 权重和 `full_sft` 权重的表现: 13841373[A]: 鲁迅的《狂人日记》是其作品中对封建礼教的批判,主要通过以下几个方面进行批判:1. **文学结构的变革**:《狂人日记》在文学上进行了大量的反思和批判,从最初的虚构世界为封建礼教的建立埋下了根基。然而,随着社会观念的转变,一些人开始反思封建礼教的性质和目的,比如对社会秩序的忽视、对个人自由的质疑,以及对社会不… 1374[B]: 鲁迅的《狂人日记》是中国古典四大名著之一,全称为《后传》。这部作品通过细腻的笔触,展现了中国社会的复杂与深邃。1. **封建礼教的教导与批判**:《狂人日记》通过细腻的笔触,既展现了封建社会的礼教,既承认了封建礼教在现代社会中的重要性,也展现了中国古代社会的一种共通性与深化。2. **对社会与文化的深刻反思… 1375[C]: 鲁迅是中国现代文学史上第一位作家,他于1912年出版,自诞生以来便以诗歌为题,通过多次诠释封建礼教的复杂性与多面性。鲁迅通过他的批判性视角,不仅在文学与社会交汇处绽放共舞,更在无垠共舞间编织共舞的璀璨篇章。1. **批判与共舞**:鲁迅通过细腻的笔触与深刻的思考,既在形式与深度间共舞。他既在知识与共舞间绽放… 1376``` 1377 1378 1379### Test 2: Light Agent Task Comparison 1380 1381A test adapted from the `eval_toolcall` script, using a set of math ToolUse tasks to compare the performance of the current `agent` weights and `full_sft` weig… 1382First 10 of 95 lines, the second copy on the right.
- 277 lines in 2 placestextdocs and examples544 tokens
1748 ├── build/ 1749 ├── convert_hf_to_gguf.py 1750 └── ... 1751``` 1752 17530、参考 `llama.cpp` 官方文档完成安装(如 `cmake` 等依赖) 1754 17551、在 `convert_hf_to_gguf.py` 的 `get_vocab_base_pre` 函数末尾插入: 1756 1757```python1748 ├── build/ 1749 ├── convert_hf_to_gguf.py 1750 └── ... 1751``` 1752 17530. Refer to the `llama.cpp` official documentation to complete installation (dependencies such as `cmake`, etc.) 1754 17551. Insert at the end of the `get_vocab_base_pre` function in `convert_hf_to_gguf.py`: 1756 1757```pythonFirst 10 of 277 lines, the second copy on the right.
- 14 lines in 2 placestextdocs and examples495 tokens
1483[D]: 大熊猫是一种以竹子为主要食物的植食动物,它们的肠道结构适合消化纤维素含量高的竹子,但也会吃一些其他植物,如草本植物和小型哺乳动物。大熊猫的肠道结构也适应了高纤维的竹子,这使得它们能够消化大量的纤维素,从而帮助它们在野外生存。大熊猫的肠道中还含有一种叫做“纤维素酶”的酶类物质,这种酶能够帮助大熊猫分解纤维素,… 1484 1485 1486[Q]: 海水为什么是咸的? 1487[A]: 海水的咸度是由海水的重量以及海水的盐度共同作用的结果。这种变化主要是由于海水在阳光照射下会吸收水中的盐分,从而形成咸味。1. **阳光的反射**:当阳光照射到海水表面时,水中的盐分会渗透到海水的表面,而不是海水表面。这种反射的过程称为光的反射。2. **盐水的温度**:海水的盐度与普通海水中的水的温度有关。… 1488[B]: 海水的咸度是由其所含物质的盐分占据的,这一现象可以从几个方面来解释:1. **盐分占据的作用**:咸度是指在一定温度下,部分水分含量的相对量。在正常条件下,咸度较高的水分含量会增加,使得渗透压较小,这部分的水分会减少,使得渗透压相对较低。这是因为咸度的增加使得盐分在水中的浓度增加,盐分的增加意味着渗透压较小… 1489[C]: 因为水是许多生物的生存所必需的,它能够吸收和释放二氧化碳,释放氧气,维持大气中的水蒸气,以及维持水循环。水中的盐类和化学物质会释放出氧气,使地球上的生物呼吸。此外,水还具有许多其他功能,如保持水循环、维持水循环、调节气候和环境等。水是许多生物生存所必需的,它也是许多自然现象的重要基础。 1490[D]: 海水是咸的主要原因是因为其中含有大量的溶解盐类,其中最主要的是氯化钠(NaCl)。氯化钠是一种非常常见的盐类,它存在于地球上的大部分地区,包括海洋、湖泊、河流和地下水。当水从海洋中蒸发时,它会带走一部分盐分,使海水变得咸。此外,海中还含有其他溶解盐类的物质,如硫酸盐、硫酸镁、硫酸钙、硫酸镁盐、硫酸镁钾、硫酸… 1491 1492First 10 of 14 lines.
- 15 lines in 2 placestextdocs and examples494 tokens
- 325 lines in 2 placestextdocs and examples474 tokens
By format, code only
| Format | Files | Lines | Clones | Duplicated lines | Duplication |
|---|---|---|---|---|---|
| python | 20 | 4,739 | 68 | 810 | 17.09% |
By format, all files
| Format | Files | Lines | Clones | Duplicated lines | Duplication |
|---|---|---|---|---|---|
| python | 22 | 4,761 | 69 | 817 | 17.16% |
| markdown | 3 | 4,188 | 14 | 212 | 5.06% |
| text | 2 | 504 | 8 | 210 | 41.67% |
| bash | 2 | 288 | 5 | 58 | 20.14% |
| json | 4 | 31,574 | 1 | 24 | 0.08% |
| txt | 1 | 37 | 0 | 0 | 0% |
Trending appearances
| Day | Rank | Stars | Files | Lines | Clones | All files | Code | Health | Commit |
|---|---|---|---|---|---|---|---|---|---|
| Nov 24, 2026 | #2 | 69,641 (+828) | 34 | 41,352 | 97 | 3.19% | 17.09% | D 52.3 | 858008e |
| Nov 23, 2026 | #2 | 68,887 (+473) | 34 | 41,352 | 97 | 3.19% | 17.09% | D 52.3 | 858008e |
| Nov 22, 2026 | #2 | 68,238 (+488) | 34 | 41,257 | 96 | 3.19% | 17.07% | D 52.4 | 3eee569 |
| Nov 21, 2026 | #2 | 67,781 (+847) | 34 | 41,250 | 96 | 3.18% | 17.05% | D 52.4 | cc9629e |
| Nov 20, 2026 | #2 | 67,094 (+238) | 34 | 41,250 | 96 | 3.18% | 17.05% | D 52.4 | cc9629e |
| Nov 18, 2026 | #10 | 66,165 (+192) | 34 | 41,242 | 96 | 3.18% | 17.08% | D 52.4 | 233d00f |
| Sep 2, 2026 | #5 | 57,299 (+1,005) | 44 | 41,998 | 97 | 3.22% | 15.34% | — | 7a6fddd |
| Sep 1, 2026 | #5 | 56,735 (+495) | 44 | 41,998 | 97 | 3.22% | 15.34% | — | 7a6fddd |
Want this for your own project? Install jscpd and run jscpd ., or measure it the way the baselines were measured.