A fine-tuned Qwen3-0.6B model for generating terminal commands from natural language instructions. Supports Linux, Windows, and macOS.
1from peft import PeftModel
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4# Load model (base + adapters)
5base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-0.6B")
6model = PeftModel.from_pretrained(base_model, "Eng-Elias/qwen3-0.6b-terminal-instruct")
7tokenizer = AutoTokenizer.from_pretrained("Eng-Elias/qwen3-0.6b-terminal-instruct")
8
9# Generate command
10def generate_command(instruction, os_tag="[LINUX]"):
11 prompt = f"### Instruction:\n{instruction}\n\n### Input:\n{os_tag}\n\n### Response:\n"
12 inputs = tokenizer(prompt, return_tensors="pt")
13 outputs = model.generate(**inputs, max_new_tokens=100, do_sample=False)
14 response = tokenizer.decode(outputs[0], skip_special_tokens=True)
15 return response.split("### Response:")[-1].strip()
16
17# Examples
18print(generate_command("List all files including hidden ones", "[LINUX]"))
19# Output: ls -a
20
21print(generate_command("Create a new folder named projects", "[WINDOWS]"))
22# Output: mkdir projects
23
24print(generate_command("Show disk usage", "[MAC]"))
25# Output: df -h
1# Linux
2generate_command("Find all Python files", "[LINUX]")
3# find . -name '*.py'
4
5# Windows
6generate_command("Find all Python files", "[WINDOWS]")
7# dir /s /b *.py
8
9# macOS
10generate_command("Find all Python files", "[MAC]")
11# find . -name '*.py'
1{
2 "description": "Delete file named temp.txt",
3 "linux": "rm temp.txt",
4 "windows": "del temp.txt",
5 "mac": "rm temp.txt"
6}
### Instruction:
{natural language description of the command}
### Input:
{OS tag or special request}
### Response:
{generated terminal command}
1@misc{qwen3-terminal-instruct,
2 author = {Eng-Elias},
3 title = {Qwen3-0.6B Terminal Command Generator},
4 year = {2025},
5 publisher = {HuggingFace},
6 url = {https://huggingface.co/Eng-Elias/qwen3-0.6b-terminal-instruct}
7}