Views
No views yet
generate_dataset.py script hosted directly in this repository. You can execute this script locally to recreate or modify the entire 970-pair dataset.paged_adamw_32bit (Offloads states to CPU to avoid VRAM overhead)1.5e-4 with Cosine Annealing schedulerper_device_train_batch_size = 1 with gradient_accumulation_steps = 2 (Effective batch size: 2)True (GPU memory-saver)2.6350.2032 (92.3% error reduction!)eval_loss): 0.3705 (Zero overfitting proof!)1inference_config = {
2 "do_sample": True,
3 "temperature": 0.7, # Calibrated to prevent greedy repetition loops
4 "top_p": 0.95, # Restricts vocabulary to high-probability tokens
5 "max_new_tokens": 256, # Budgeted for full chain-of-thought + code blocks
6 "use_cache": True, # Reuses GPU KV-Cache for 10x generation speedup
7}### System: You are a local OS Terminal Controller Agent. State your thinking process within <thinking> tags, followed by the exact terminal command block.
### Instruction: {user_natural_language_request}
### Output: <thinking>
{reasoning}
</thinking>
```bash
{executable_command}
---
## Get Started (PEFT Inference)
```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import PeftModel
BASE_MODEL_ID = "Qwen/Qwen3.5-0.8B"
LORA_ADAPTER_DIR = "YOUR_HF_ACCOUNT/qwen3.5-0.8b-terminal-agent-lora"
# 1. Load base weights in NF4 4-bit QLoRA
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=True,
bnb_4bit_compute_dtype=torch.float16,
)
tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL_ID, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
BASE_MODEL_ID,
quantization_config=bnb_config,
device_map="auto",
trust_remote_code=True,
)
# 2. Attach trained adapter
model = PeftModel.from_pretrained(model, LORA_ADAPTER_DIR)
model.eval()
# 3. Format prompt
prompt = """### System: You are a local OS Terminal Controller Agent. State your thinking process within <thinking> tags, followed by the exact terminal command block.
### Instruction: Find and delete all logs modified in the last 7 days.
### Output:"""
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=256,
do_sample=True,
temperature=0.7,
top_p=0.95,
use_cache=True,
pad_token_id=tokenizer.eos_token_id
)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))