TINY_LINUX_COMMAND_LLAMA is a specialized LoRA adapter fine-tuned for generating Linux terminal commands. It has been trained on a dataset of 12,000 curated command examples. Training is ongoing to incorporate additional commands and edge cases. This adapter extends the 4‑bit TinyLLaMA model to facilitate resource-efficient inference on commodity hardware.
1import unsloth
2from pathlib import Path
3from transformers import AutoTokenizer
4from unsloth import FastLanguageModel
5from peft import PeftModel
6import torch
7
8# Paths & device
9ADAPTERS_ROOT = Path("adapters")
10DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
11
12# Load LoRA adapter and base model
13adapter_path = ADAPTERS_ROOT / "latest"
14tokenizer = AutoTokenizer.from_pretrained(adapter_path, use_fast=True)
15base_model, _ = FastLanguageModel.from_pretrained(
16 "unsloth/tinyllama-bnb-4bit",
17 max_seq_length=256,
18 dtype=None,
19 load_in_4bit=True,
20 random_state=666
21)
22model = PeftModel.from_pretrained(base_model, adapter_path.as_posix())
23model.to(DEVICE).eval()
24
25# Interactive prompt for command generation
26while True:
27 command_request = input("enter your desired command > ")
28 if not command_request.strip():
29 break
30 prompt = f"### desired_terminal_action: {command_request}\n### linux_command:"
31 inputs = tokenizer(prompt, return_tensors="pt").to(DEVICE)
32 outputs = model.generate(**inputs, max_new_tokens=32)
33 result = tokenizer.decode(outputs[0], skip_special_tokens=True)
34 print(result)
1pip install unsloth transformers bitsandbytes peft torch
2# Clone or place adapter in ./adapters/latest
This adapter is under active development. Issues and pull requests are welcome on the repository.