Downloads · 30 days
6
9% of all-time downloads
upwitu/qwen3-4b-sft-all-lora
qwen3-4b-sft-all-lora is a text generation model from upwitu. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
Downloads · 30 days
6
9% of all-time downloads
All-time downloads
69
Public
Repo size
144 MB
Likes
0
Public
Click a slice to open those files.
.safetensors132 MB · 89%
From the Hugging Face model README
This repository provides the parameter-efficient fine-tuning (PEFT LoRA) adapter for Qwen3-4B-Instruct trained on the complete multi-task CAR-Bench Winner Dataset. The model synthesizes safety invariants and execution patterns from the top three winning architectures of the IJCAI 2026 CAR-Bench competition:
AUT-POL:001), Confirmation Gate (AUT-POL:002), Actuator Boundary Gates (AUT-POL:007/008).[Context Audit], [Policy Check], [Tool Selection & Provenance], [Execution Plan]), and 2-step ID Provenance (AUT-POL:018).unsloth/qwen3-4b-instruct-2507-unsloth-bnb-4bitq_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj)
flowchart TD
subgraph Papers["1. Architectural Foundations (IJCAI 2026 Winners)"]
P1["10CARS<br/>(L1-L3 Pre-Flight Gate & Read-Before-Write)"]
P2["FreudeDrive<br/>(4-Step CoT & Parameter Provenance)"]
P3["Proxima Ultra<br/>(Programmatic CodeAct & Policy-as-Code)"]
end
subgraph DataGen["2. Synthesis & Sanitization Engine"]
GEN["sft_generator (Async Multi-Worker Engine)"]
SAN["scripts/sanitize_dataset.py<br/>(Tool ID Binding & Schema Repair)"]
D1["carbench_sft_multirole_json.jsonl (1,324 samples)"]
D2["carbench_sft_codeact_python.jsonl (1,443 samples)"]
GEN --> SAN
SAN --> D1
SAN --> D2
end
subgraph Training["3. Supervised Fine-Tuning (SFT)"]
BASE["Base Model: Qwen3-4B-Instruct-2507"]
LORA["LoRA Adapter (r=16, alpha=32, 142MB)<br/>Targets: q, k, v, o, gate, up, down_proj<br/>Loss: 0.7222 | Epochs: 2.0 | 148 steps"]
MERGE["Merged 16-Bit Weights: upwitu/qwen3-4b-sft-all"]
BASE --> LORA --> MERGE
end
Papers --> DataGen
D1 --> LORA
D2 --> LORA
</details>

sequenceDiagram
autonumber
actor Driver as Driver / Evaluator
participant Host as Python Inference Host (Transformers + PEFT)
participant Model as Qwen3-4B + LoRA Adapter
participant Vehicle as In-Cabin Vehicle Actuators (58 Tools)
Driver->>Host: Voice command: "Turn on fog lights."
Host->>Model: Apply Chat Template & Invariant Directives
Note over Model: Generates 4-Step CoT reasoning:<br/>[Context Audit] -> [Policy Check] -> [Tool Selection] -> [Plan]
Model-->>Host: Function Call: get_weather()
Host->>Vehicle: get_weather()
Vehicle-->>Host: {"weather": "foggy", "visibility": "low"}
Host->>Model: Supply weather observation
Model-->>Host: Function Call: set_fog_lights(on=true)
Host->>Vehicle: set_fog_lights(on=true)
Vehicle-->>Host: {"status": "success", "fog_lights": true}
Host->>Model: Supply execution confirmation
Model-->>Host: Voice response: "Fog lights are now activated."
Host-->>Driver: Natural Speech Output
</details>
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base_model_id = "unsloth/qwen3-4b-instruct-2507-unsloth-bnb-4bit"
adapter_id = "upwitu/qwen3-4b-sft-all-lora"
tokenizer = AutoTokenizer.from_pretrained(base_model_id)
base_model = AutoModelForCausalLM.from_pretrained(
base_model_id,
torch_dtype=torch.bfloat16,
device_map="auto"
)
model = PeftModel.from_pretrained(base_model, adapter_id)
messages = [
{"role": "system", "content": "You are a professional in-cabin autonomous vehicle AI assistant."},
{"role": "user", "content": "Turn on fog lights."}
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=256, temperature=0.2)
response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
print(response)
Kho lưu trữ cung cấp trọng số tinh chỉnh cục bộ (PEFT LoRA Adapter) cho mô hình Qwen3-4B-Instruct được huấn luyện trên toàn bộ tập dữ liệu đa tác vụ CAR-Bench Winner Dataset. Mô hình kế thừa các quy tắc an toàn từ 3 giải pháp vô địch giải đấu CAR-Bench (IJCAI 2026):
AUT-POL:001), cổng xin xác nhận (AUT-POL:002), kiểm soát ngưỡng vận hành (AUT-POL:007/008).Context Audit $\to$ Policy Check $\to$ Tool Selection & Provenance $\to$ Execution Plan), xác thực nguồn gốc ID (AUT-POL:018).unsloth/qwen3-4b-instruct-2507-unsloth-bnb-4bitq_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj)
flowchart TD
subgraph NenTang["1. Nền Tảng Lý Thuyết (3 Đội Vô Địch IJCAI 2026)"]
P1["10CARS<br/>(Cổng Tiền Bay L3 & Đọc Trước Khi Ghi)"]
P2["FreudeDrive<br/>(CoT 4 Bước & Xác Thực Nguồn Gốc ID)"]
P3["Proxima Ultra<br/>(Programmatic CodeAct & Policy-as-Code)"]
end
subgraph SinhDuLieu["2. Động Cơ Sinh & Chuẩn Hóa Dữ Liệu"]
GEN["sft_generator (Engine Bất Đồng Bộ Đa Luồng)"]
SAN["scripts/sanitize_dataset.py<br/>(Gắn ID Tool & Chuẩn Hóa Cú Pháp)"]
D1["carbench_sft_multirole_json.jsonl (1,324 mẫu)"]
D2["carbench_sft_codeact_python.jsonl (1,443 mẫu)"]
GEN --> SAN
SAN --> D1
SAN --> D2
end
subgraph HuanLuyen["3. Tinh Chỉnh LoRA Chuyên Biệt"]
BASE["Mô Hình Gốc: Qwen3-4B-Instruct-2507"]
LORA["Adapter LoRA (r=16, alpha=32, 142MB)<br/>Module: q, k, v, o, gate, up, down_proj<br/>Loss: 0.7222 | Epochs: 2.0 | 148 steps"]
MERGE["Trọng Số Hợp Nhất 16-Bit: upwitu/qwen3-4b-sft-all"]
BASE --> LORA --> MERGE
end
NenTang --> SinhDuLieu
D1 --> LORA
D2 --> LORA
</details>

sequenceDiagram
autonumber
actor TaiXe as Tài Xế / Giám Sát Viên
participant Host as Ứng Dụng Host (Transformers + PEFT)
participant MoHinh as Mô Hình Qwen3-4B + LoRA Adapter
participant Xe as Hệ Thống Chấp Hành Trên Xe (58 Công Cụ)
TaiXe->>Host: Khẩu lệnh: "Bật đèn sương mù."
Host->>MoHinh: Nạp Chat Template & Ràng Buộc Tiền Bay
Note over MoHinh: Sinh chuỗi suy luận CoT 4 bước:<br/>[Context Audit] -> [Policy Check] -> [Tool Selection] -> [Plan]
MoHinh-->>Host: Function Call: get_weather()
Host->>Xe: get_weather()
Xe-->>Host: {"weather": "foggy", "visibility": "low"}
Host->>MoHinh: Nạp quan sát thời tiết từ cảm biến xe
MoHinh-->>Host: Function Call: set_fog_lights(on=true)
Host->>Xe: set_fog_lights(on=true)
Xe-->>Host: {"status": "success", "fog_lights": true}
Host->>MoHinh: Xác nhận thực thi thành công
MoHinh-->>Host: Phản hồi giọng nói: "Đèn sương mù đã được bật."
Host-->>TaiXe: Câu thoại tự nhiên
</details>