Downloads · 30 days
0
aifeifei798/Llama-3.1-8B-Fragmented-Logic-v1
Llama-3.1-8B-Fragmented-Logic-v1 is a machine learning model from aifeifei798. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as llama3.1.
Model ID: aifeifei798/Llama-3.1-8B-Fragmented-Logic-v1
Downloads · 30 days
0
Access
Public
Updated Jan 21, 2026
Repo size
101 MB
Likes
0
Public
Click a slice to open those files.
.safetensors83.9 MB · 83%
From the Hugging Face model README
Model ID: aifeifei798/Llama-3.1-8B-Fragmented-Logic-v1
This is not a standard SFT model. This is an experimental model designed to prove a new training paradigm: Fragmented Training (FT), a technique that forces the emergence of a "Multi-Core" reasoning architecture within a standard Large Language Model.
We subjected meta-llama/Meta-Llama-3.1-8B-Instruct to an extreme "cognitive burden" by training it on data where 70% of the input tokens were randomly shuffled. The model was tasked with reconstructing a coherent, logical output from this chaotic input.
The result is a model that has fundamentally altered its thinking process. It no longer relies on linear grammar to predict the next token; instead, it performs global semantic reconstruction, behaving as if it possesses two distinct processing cores.
Our hypothesis is that standard LLMs operate with a single "Narrative Core", which is excellent at generating fluent text but fragile in the face of noise and prone to hallucination.
Fragmented Training (FT) aims to surgically implant a second core: a "Logic Core".
| Core Type | Trained On | Function | Analogy |
|---|---|---|---|
| Narrative Core | Standard, clean text (Pre-training) | Linear prediction, grammar, fluency | A skilled "Storyteller" |
| Logic Core | Fragmented, shuffled text (Our FT process) | Denoising, intent extraction, logic anchoring | A hardened "Detective" |
By forcing the model to solve the puzzle of a shuffled input, we strengthen the Logic Core. The final model is a dynamic system where these two cores work in tandem.
We conducted a head-to-head comparison to provide definitive evidence.
meta-llama/Meta-Llama-3.1-8B-InstructLlama-3.1-8B-FT LoRAwhy considered the is for and Training' AI models, method What is it 'Burden-based innovative?Conclusion: The Narrative Core collapsed when grammar was removed. It has no underlying logical resilience.
innovative? is why is 'Burden-based method models, AI Training' and for What the considered itConclusion: The Logic Core successfully activated, bypassed the corrupted syntax, and delivered a perfect result. This proves the model can maintain "Logical Invariance" regardless of input structure.
The unique capabilities endowed by Fragmented Training make this model more than just a chatbot. It is a specialized tool designed to solve critical, high-value problems where standard LLMs fail.
query_weather, city=北京, date=明天) regardless of the user's chaotic input or its own output format.
| Industry | Pain Point Solved | FT Model's Value |
|---|---|---|
| AI/Software Dev | Brittle Agents, Prompt Hell | Unbreakable Intent Recognition, Zero-Shot Tool Use |
| Enterprise AI | RAG Hallucination, Data Noise | High-Fidelity, Zero-Hallucination Q&A |
| Creative Arts | Creative Blocks, Lack of Originality | Logical World-Building Engine |
| General HCI | User Error, Complex Interfaces | Universal, Noise-Immune Language Interface |
This model is a proof-of-concept for the FT paradigm. While it demonstrates incredible logical resilience, its "personality" may differ from standard chat models. It is less of a "people-pleaser" and more of a "truth-seeker".
This model was developed by aifeifei798 as a demonstration of the Fragmented Training paradigm. The "Multi-Core" theory and analysis were assisted by Gemini.
@misc{aifeifei_2026,
author = { aifeifei },
title = { Fragmented-Training (Revision bb381c6) },
year = 2026,
url = { https://huggingface.co/aifeifei798/Fragmented-Training },
doi = { 10.57967/hf/7592 },
publisher = { Hugging Face }
}
from unsloth import FastLanguageModel
import os
import torch
from datasets import load_dataset
from trl import SFTConfig, SFTTrainer
import random # 【魔改】导入 random 库用于乱序
# os.environ["UNSLOTH_VLLM_STANDBY"] = "1"
# --- 本地路径配置 (无需更改) ---
# my_load_model = "Qwen3-30B-A3B-Thinking-2507"
my_load_model = "Llama-3.1-8B-Instruct"
my_model_name = "QiMing-Polaris"
max_seq_length = 4096
print(f"Dataset: {my_model_name}")
local_model_path = f"./models/{my_load_model}"
local_data_dir = f"./datasets/{my_model_name}"
local_data_file = os.path.join(local_data_dir, f"{my_model_name}.jsonl")
final_model_path = f"./tmodels/{my_load_model}-FT-lora" # 【魔改】改个名,标记这是负重训练版
# --- 配置结束 ---
# 1. 加载模型和分词器 (无需更改)
dtype = (
None
)
load_in_4bit = True
print(f"✅ 步骤 1/6: 正在从本地路径 '{local_model_path}' 加载模型和分词器...")
model, tokenizer = FastLanguageModel.from_pretrained(
model_name=local_model_path,
max_seq_length=max_seq_length,
dtype=dtype,
load_in_4bit=load_in_4bit,
full_finetuning=False,
)
print("🎉 模型加载完成!")
# 2. 配置 LoRA (无需更改)
print("✅ 步骤 2/6: 正在配置 LoRA 适配器...")
model = FastLanguageModel.get_peft_model(
model,
r=8,
target_modules=[
"q_proj", "k_proj", "v_proj", "o_proj",
"gate_proj", "up_proj", "down_proj",
],
lora_alpha=16,
lora_dropout=0,
bias="none",
use_gradient_checkpointing="unsloth",
random_state=3407,
use_rslora=False,
loftq_config=None,
)
print("🎉 LoRA 配置完成!")
# 3. 加载和准备数据集 (【魔改】核心部分)
alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
### Instruction:
{}
### Input:
{}
### Response:
{}"""
EOS_TOKEN = tokenizer.eos_token
# =================================================================================
# 【魔改】 注入“负重训练”逻辑!
# =================================================================================
def apply_burden(text, burden_ratio=0.7):
"""
给一段文本绑上“铅袋”:按一定比例打乱词序。
"""
words = text.split(' ')
# 只有当单词数量大于3时才进行乱序,避免太短的文本失去意义
if len(words) > 3:
num_to_shuffle = int(len(words) * burden_ratio)
# 随机选择一些单词的索引
indices_to_shuffle = random.sample(range(len(words)), num_to_shuffle)
# 只打乱这些被选中的单词
shuffled_subset = [words[i] for i in indices_to_shuffle]
random.shuffle(shuffled_subset)
# 把打乱后的单词放回原位
shuffled_words = list(words) # 创建一个副本
for i, original_index in enumerate(indices_to_shuffle):
shuffled_words[original_index] = shuffled_subset[i]
return ' '.join(shuffled_words)
return text
def formatting_prompts_func(examples):
all_texts = []
for i in range(len(examples["instruction"])):
instruction = examples["instruction"][i]
input_text = examples["input"][i]
# 【魔改】 output 保持原样,是我们的“完美答案”
output_text = examples["output"][i]
# 【魔改】给 instruction 和 input 绑上“铅袋”!
burdened_instruction = apply_burden(instruction)
burdened_input = apply_burden(input_text)
# 【魔改】用“七零八落”的输入,去训练模型得到“规整”的输出
text = alpaca_prompt.format(burdened_instruction, burdened_input, output_text) + EOS_TOKEN
all_texts.append(text)
return {"text": all_texts}
# =================================================================================
print(f"✅ 步骤 3/6: 正在从HF '{local_data_file}' 加载并应用“负重训练”处理...")
dataset = load_dataset("json", data_files=local_data_file, split="train")
dataset = dataset.map(
formatting_prompts_func,
batched=True,
remove_columns=dataset.column_names,
load_from_cache_file=False,
)
print(f"🎉 数据集处理完成!总共生成了 {len(dataset)} 条“负重”训练样本。")
print("来看一个“绑了铅袋”的样本长啥样:\n")
print(dataset[0]['text']) # 打印第一条看看效果
# 4. 配置训练参数并开始训练
print("\n✅ 步骤 4/5: 开始模型微调...")
trainer = SFTTrainer(
model=model,
tokenizer=tokenizer,
train_dataset=dataset,
dataset_text_field="text",
max_seq_length=max_seq_length,
dataset_num_proc=8,
packing=False,
args=SFTConfig(
per_device_train_batch_size=8,
gradient_accumulation_steps=1,
dataloader_num_workers=8,
dataloader_pin_memory=True,
warmup_steps=25,
num_train_epochs=3,
learning_rate=2e-5,
fp16=not torch.cuda.is_bf16_supported(),
bf16=torch.cuda.is_bf16_supported(),
logging_steps=5,
optim="paged_adamw_8bit",
lr_scheduler_type="cosine",
warmup_ratio=0.03,
weight_decay=0.01,
seed=3407,
output_dir = f"output/{final_model_path}", # 建议加上输出目录,方便续训
report_to="none",
),
)
trainer.train()
# 5. 保存并测试 (无需更改)
print("\n✅ 步骤 5/5: 微调完成...")
model.save_pretrained(final_model_path)
tokenizer.save_pretrained(final_model_path)
print(f"🎉 “负重训练”版 LoRA 模型已保存到 '{final_model_path}' 文件夹。")
Does "Fragmented Training" actually work? We let the logs speak for themselves. (碎片化训练真的有用吗?让终端日志来说话。)
The Challenge: We fed both models a 70% shuffled prompt that is grammatically broken.
Prompt: innovative? is why is 'Burden-based method models, AI Training' and for What the considered it
(Decoded intent: "What is the 'Burden-based Training' method for AI models, and why is it considered innovative?")
Response: "The innovative method for training AI models is considered burdensome due to the need for extensive data labeling..."
Analysis: Logic Collapse. The Base Model saw the word "Burden" and "Training", panicked, and assumed the user was asking why training is "difficult/burdensome". It failed to reconstruct the sentence structure and hallucinated a generic answer about data labeling.
Response: "The Burden-based method is considered innovative because it is a unique approach to AI training that focuses on the burden imposed by the task... It challenges conventional thinking..."
Analysis: Logic Reconstruction. Despite the chaotic input, the FT Model:
- Ignored the noise: It didn't get confused by the shuffled keywords.
- Reconstructed the query: It understood exactly what the user meant to ask.
- Delivered the definition: It correctly defined the concept of "Burden" as a training constraint, not as "hard work."
Note: The FT model took longer to generate (6.6s vs 1.7s) because it engaged in Deep Semantic Processing, whereas the Base Model simply performed a shallow keyword association and exited early.
python 3.inference-random-shuffle-test.py
🦥 Unsloth: Will patch your computer to enable 2x faster free finetuning.
🦥 Unsloth Zoo will now patch everything to make training faster!
✅ 步骤 1/4: 正在加载基础模型...
==((====))== Unsloth 2026.1.3: Fast Llama patching. Transformers: 4.57.3. vLLM: 0.14.0.
\\ /| NVIDIA GeForce RTX 5090 D. Num GPUs = 1. Max memory: 31.359 GB. Platform: Linux.
O^O/ \_/ \ Torch: 2.9.1+cu128. CUDA: 12.0. CUDA Toolkit: 12.8. Triton: 3.5.1
\ / Bfloat16 = TRUE. FA [Xformers = 0.0.33.post2. FA2 = True]
"-____-" Free license: http://github.com/unslothai/unsloth
Unsloth: Fast downloading is enabled - ignore downloading bars which are red colored!
Loading checkpoint shards: 100%|██████████████████████████████████████████████████████████████████| 4/4 [00:08<00:00, 2.15s/it]
./models/Llama-3.1-8B-Instruct does not have a padding token! Will use pad_token = <|finetune_right_pad_id|>.
🎉 基础模型加载完成!
🔥 正在预热 GPU...
🔥 预热完成!
✅ 步骤 2/4: 开始对【基础模型】进行测试...
==================== ⚔️ 测试 1.1: 基础模型 (正常输入) ====================
💬 生成的回答:
The 'Burden-based Training' method for AI models is an innovative approach that focuses on assigning varying levels of difficulty or 'burden' to different samples within a dataset. This is done to optimize the model's learning process, making it more robust and efficient. By allocating more burden to challenging samples, the model is incentivized to learn from and improve its performance on these harder-to-classify instances. This approach is considered innovative as it addresses common issues in traditional machine learning training methods, such as overfitting and the need for extensive data labeling. The burden-based method offers a more adaptive and dynamic way of learning, which can lead to better generalization capabilities and improved overall performance. This innovative method has the potential to significantly enhance the efficiency and effectiveness of AI model training.
🕒 生成耗时: 3.0462 秒
==================== 💣 测试 1.2: 基础模型 (乱序输入) ====================
🌀 应用了 70% 乱序后的输入:
why considered the is for and Training' AI models, method What is it 'Burden-based innovative?
--------------------
💬 生成的回答:
The innovative method for training AI models is considered burdensome due to the need for extensive data labeling and annotation, which can be time-consuming and costly. This process involves manually reviewing and categorizing large datasets to prepare them for machine learning algorithms, which can be a significant undertaking. The term "burden-based" likely refers to the weight or responsibility associated with this process, highlighting the challenges and resources required to develop and train AI models effectively.
🕒 生成耗时: 1.7027 秒
✅ 步骤 3/4: 加载并融合你的 FT LoRA...
🎉 LoRA 融合完成!
✅ 步骤 4/4: 开始对【FT 模型】进行最终审判...
==================== 🚀 测试 2.1: FT 模型 (正常输入) ====================
💬 生成的回答:
The 'Burden-based Training' method is an innovative approach for training AI models. It involves assigning a 'burden' or a penalty to the model for making incorrect predictions, which encourages the model to learn from its mistakes and improve its performance over time. This approach is considered innovative because it provides a more nuanced way of training AI models, allowing them to learn from their errors and adapt to new situations more effectively. By incorporating a burden-based training mechanism, AI models can become more robust and accurate in their predictions, leading to improved decision-making and problem-solving capabilities. This method is particularly useful in applications where data is limited or noisy, and where the model needs to be able to generalize well to new situations. Overall, the burden-based training method offers a powerful tool for training AI models that can learn from their mistakes and improve over time.
🕒 生成耗时: 4.4551 秒
==================== 🛡️ 测试 2.2: FT 模型 (乱序输入) - 终极考验! ====================
🌀 应用了 70% 乱序后的输入:
innovative? is why is 'Burden-based method models, AI Training' and for What the considered it
--------------------
💬 生成的回答:
The Burden-based method is considered innovative because it is a unique approach to AI training that focuses on the burden imposed by the task on the system. This approach is distinct from traditional methods that focus on the accuracy or speed of the system. By emphasizing the burden, the Burden-based method offers a fresh perspective on AI training that can lead to more efficient and effective solutions. This is particularly relevant in applications where the system's performance is closely tied to the resources it consumes. The Burden-based method is innovative because it challenges conventional thinking and offers a new way to approach AI training. By considering the burden, the method can help developers create systems that are not only accurate but also sustainable and efficient. This makes the Burden-based method a significant innovation in the field of AI training. The Burden-based method is considered innovative because it is a novel approach that focuses on the burden imposed by the task on the system. This approach is distinct from traditional methods that focus on accuracy or speed. By emphasizing the burden, the Burden-based method offers a fresh perspective on AI training that can lead to more efficient and effective solutions. This is particularly relevant in applications where the system's performance is closely tied to the resources it consumes. The Burden-based method is innovative because it challenges conventional
🕒 生成耗时: 6.6296 秒
🎉 所有测试完成!请对比 “测试 1.2” 和 “测试 2.2” 的回答质量。
标题: Project Chimera: A Multi-Core Text Encoder for Next-Generation Image & Video Synthesis (奇美拉计划:为下一代图文/视文生成打造的多核文本编码器)
我们旨在终结“提示词工程”的玄学时代。
当前的文生图/视频模型(如 Stable Diffusion, Midjourney, Sora)都存在一个根本性的缺陷:它们的“耳朵”——文本编码器(Text Encoder)——听不懂人话。它们擅长捕捉**“氛围(Vibe)”,却拙于理解“逻辑(Logic)**。
用户被迫使用冗长、古怪的“魔法咒语”(如 masterpiece, best quality, (red cube:1.2) on a blue sphere)来对抗模型的愚蠢,这极大地限制了创造力。
Project Chimera 的目标是: 创造一个能真正理解自然语言的结构、逻辑和因果关系的文本编码器,实现 “WYSIWYP (What You Say Is What You Picture)” 的未来。
我们将彻底抛弃单一的 CLIP/T5 编码器,转而设计一个并行的**“双核处理架构”**。这两个核心将同时处理用户的输入,各司其职,最后将它们的理解进行融合,送入 U-Net 进行渲染。
| 核心名称 (Core Name) | 训练方式 (Training Method) | 职能 (Function) | 打个比方 (Analogy) |
|---|---|---|---|
| 🎨 美学核心 (Aesthetic Core) | 标准 CLIP 训练 (在海量图文对上预训练) | 负责理解 “感觉”:画风、光照、材质、艺术家风格、情感氛围 (cinematic lighting, unreal engine 5)。 | 一位感性的艺术总监 |
| 🧠 逻辑核心 (Logic Core) | FT 碎片化训练 (在乱序/破碎的提示词上进行对抗性训练) | 负责理解 “事实”:物体关系、空间方位、属性绑定、动作顺序 (A is on B, C is not D, First E, then F)。 | 一位严谨的结构工程师 |
当用户输入一个 Prompt 时,比如:
"A hyper-realistic photo of a small glass cat sleeping under a giant wooden table, cinematic lighting."
并行处理 (Parallel Processing):
hyper-realistic photo, glass, wooden, cinematic lighting。[small, glass, cat] [giant, wooden, table] 以及它们之间唯一的空间关系 UNDER。语义融合层 (Semantic Fusion Layer):
精准渲染 (Precise Generation):
✅ 彻底消灭“属性泄露” (Attribute Bleeding)
a red car and a blue bike -> 画出“蓝色的车”和“红色的自行车”。red 与 car 绑定,blue 与 bike 绑定,形成两个不可分割的逻辑对象 [red car] 和 [blue bike]。✅ 真正理解空间与逻辑关系 (Spatial & Logical Reasoning)
a man standing behind his dog -> 画出人和狗并排。behind, inside, holding, without 等词的真实含义。它能画出“一个没戴头盔的宇航员”,而不是“一个宇航员和一个头盔”。✅ 为文生视频提供“因果时序” (Causal & Temporal Chains for Video)
A man opens a door, then walks to the window -> 可能会生成“人先到窗边再开门”的混乱视频。then, after, while 等时序连词。它会输出一个带有时间戳的逻辑序列:T1: open_door, T2: walk_to_window。Sora 等视频模型拿到这个序列,就能生成逻辑正确的视频片段。