mecha-org/linux-command-generator-llama3.2-1b

Natural language → Linux command. A compact Llama 3.2 1B Instruct model fine‑tuned (LoRA) to turn plain‑English requests into correct shell commands.

Video Demonstration of the model running on the Mecha Comet

For more information of the Mecha Comet, our pocket little handheld computer - click here

TL;DR

  • Base: unsloth/Llama-3.2-1B-Instruct
  • Method: LoRA (r=16, alpha=16, dropout=0)
  • Context: 2048 tokens
  • Data: 8,669 pairs across 11 categories
  • Use cases: quick command lookup, learning CLI, automation

Run with Ollama (baby steps)

  1. Install Ollama: see https://ollama.com/download.

  2. Verify install:

ollama --version
  1. Run the model interactively:
ollama run mecha-org/linux-command-generator-llama3.2-1b

Then type a request, e.g.:

  • "List all files in the current directory with detailed information"
  • "Compress the file data.txt using bzip2"
  • "Find all .py files in the current directory and subdirectories"

Press Ctrl+C to exit.

  1. One‑off (non‑interactive):
ollama run mecha-org/linux-command-generator-llama3.2-1b -p "Display the first 5 lines of access.log"
# Expected: head -n 5 access.log
  1. Get command‑only answers (when needed):
ollama run mecha-org/linux-command-generator-llama3.2-1b -p "Output only the command with no explanation. Show system information including kernel version"
# Expected: uname -a

Use a local GGUF with Ollama (fallback)

If you have model.gguf, put it next to a Modelfile:

FROM ./model.gguf
PARAMETER temperature 0.2
PARAMETER top_p 0.9
PARAMETER num_ctx 2048
SYSTEM You are a Linux command generator. Output only the command with no explanation.
TEMPLATE {{ .Prompt }}

Create and run:

ollama create linux-cmd-gen -f Modelfile
ollama run linux-cmd-gen -p "Find all .py files recursively"
# Expected: find . -name "*.py"

Other ways to use (optional)

Transformers

from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

model_id = "mecha-org/linux-command-generator-llama3.2-1b"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16 if torch.cuda.is_available() else None)

def generate_command(description: str) -> str:
    messages = [{"role": "user", "content": description}]
    inputs = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt")
    if torch.cuda.is_available():
        inputs = inputs.to(model.device)
        model = model.to("cuda")
    outputs = model.generate(input_ids=inputs, max_new_tokens=64)
    return tokenizer.decode(outputs[0], skip_special_tokens=True)

print(generate_command("List all files in the current directory with detailed information"))
# -> ls -la

Unsloth

from unsloth import FastLanguageModel

model_id = "mecha-org/linux-command-generator-llama3.2-1b"
model, tokenizer = FastLanguageModel.from_pretrained(model_name=model_id, max_seq_length=2048)
FastLanguageModel.for_inference(model)

msgs = [{"role": "user", "content": "Compress the file data.txt using bzip2"}]
inputs = tokenizer.apply_chat_template(msgs, tokenize=True, add_generation_prompt=True, return_tensors="pt")
output = model.generate(input_ids=inputs, max_new_tokens=32)
print(tokenizer.decode(output[0], skip_special_tokens=True))
# -> bzip2 data.txt

Example prompts → commands

  • "Show system information including kernel version" → uname -a
  • "Find all .py files in the current directory and subdirectories" → find . -name "*.py"
  • "Display the first 5 lines of access.log" → head -n 5 access.log
  • "Change permissions of script.sh to make it executable for owner" → chmod +x script.sh
  • "Create a tar archive backup.tar containing all files in the documents folder" → tar -cf backup.tar documents/

Dataset (overview)

8,669 input→command pairs across:

  • Compression & Archiving: bzip2, gzip, tar, zip
  • File & Directory: cd, cp, find, ls, mkdir, mv, pwd, rm, rmdir, touch
  • Permissions & Ownership: chgrp, chmod, chown
  • Viewing & Editing: cat, echo, head, less, tail, vim
  • Networking: curl, dig, host, ifconfig, ip, netstat, ping, ssh, wget
  • Package mgmt: apt, dpkg
  • Process mgmt: kill, killall, nice, pkill, renice
  • Search & Filter: awk, grep, locate, sed
  • System info/monitoring: df, du, free, top, uname
  • User/group: useradd, usermod, groupadd, passwd, sudo
  • Misc/system control: cron, systemctl, tmux, screen, service

Format:

{"input": "Describe what you want to do", "output": "linux_command_here"}

Training details

  • Base: unsloth/Llama-3.2-1B-Instruct
  • LoRA on attention + MLP projections:
    • r=16, lora_alpha=16, lora_dropout=0
    • target_modules: ["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"]
  • Max sequence length: 2048
  • SFT on responses only (TRL SFTTrainer), Unsloth-optimized
  • Example hparams: per‑device batch 2, grad accum 4, epochs 3, lr 2e‑4
  • Reference: Tesla P100 16GB (~45 minutes), ~2.8GB VRAM (adapters)

Safety and responsible use

  • Always inspect commands before executing.
  • Avoid destructive operations unless you fully understand consequences.
  • For apps, add denylists and validations (e.g., block rm -rf /, mkfs, dd).

Notes on GGUF

  • Works with llama.cpp and Ollama.
  • Typical memory (approx.): q4_k_s ~600MB, q4_k_m ~700MB, q8_0 ~1.1GB, f16 ~2.2GB.

License

Derived from Meta Llama 3.2. Use must comply with the base model license. Check your deployment context for any additional constraints.

Citation

@software{hrsvrn_linux_command_generator_llama32_1b,
  author  = {Harshvardhan Vatsa},
  title   = {Linux Command Generator (Llama 3.2 1B)},
  year    = {2025},
  url     = {https://huggingface.co/mecha-org/linux-command-generator-llama3.2-1b}
}

Acknowledgements

  • Base: unsloth/Llama-3.2-1B-Instruct
  • Libraries: unsloth, transformers, trl, accelerate, bitsandbytes
Downloads last month
605
Safetensors
Model size
1.24B params
Tensor type
BF16
·
F16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for mecha-org/linux-command-generator-llama3.2-1b

Adapter
(379)
this model