DiyRex/nl2bash-combined
Viewer • Updated • 33.9k • 59
How to use DiyRex/Llama-3.2-1B-nl2bash with MLX:
# Make sure mlx-lm is installed
# pip install --upgrade mlx-lm
# Generate text with mlx-lm
from mlx_lm import load, generate
model, tokenizer = load("DiyRex/Llama-3.2-1B-nl2bash")
prompt = "Write a story about Einstein"
messages = [{"role": "user", "content": prompt}]
prompt = tokenizer.apply_chat_template(
messages, add_generation_prompt=True
)
text = generate(model, tokenizer, prompt=prompt, verbose=True)How to use DiyRex/Llama-3.2-1B-nl2bash with Pi:
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "DiyRex/Llama-3.2-1B-nl2bash"
# Install Pi:
npm install -g @mariozechner/pi-coding-agent
# Add to ~/.pi/agent/models.json:
{
"providers": {
"mlx-lm": {
"baseUrl": "http://localhost:8080/v1",
"api": "openai-completions",
"apiKey": "none",
"models": [
{
"id": "DiyRex/Llama-3.2-1B-nl2bash"
}
]
}
}
}# Start Pi in your project directory: pi
How to use DiyRex/Llama-3.2-1B-nl2bash with Hermes Agent:
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "DiyRex/Llama-3.2-1B-nl2bash"
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default DiyRex/Llama-3.2-1B-nl2bash
hermes
How to use DiyRex/Llama-3.2-1B-nl2bash with MLX LM:
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "DiyRex/Llama-3.2-1B-nl2bash"
# Install MLX LM
uv tool install mlx-lm
# Start the server
mlx_lm.server --model "DiyRex/Llama-3.2-1B-nl2bash"
# Calling the OpenAI-compatible server with curl
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "DiyRex/Llama-3.2-1B-nl2bash",
"messages": [
{"role": "user", "content": "Hello"}
]
}'A fine-tuned version of mlx-community/Llama-3.2-1B-Instruct-4bit for converting natural language descriptions into bash commands.
Fine-tuned using LoRA via mlx-lm on Apple Silicon.
| Property | Value |
|---|---|
| Base model | Llama-3.2-1B-Instruct (4-bit) |
| Method | LoRA (rank 8, 16 layers) |
| Dataset | devinxx/nl2bash-combined |
| Training examples | 27,748 |
| Iterations | 2,000 |
| Learning rate | 1e-4 (cosine decay) |
| Hardware | Apple Silicon (MLX) |
| Peak memory | ~2.9 GB |
pip install mlx-lm
from mlx_lm import load, generate
model, tokenizer = load("devinxx/Llama-3.2-1B-nl2bash")
messages = [
{"role": "system", "content": "You are a bash expert. Convert the user's natural language description into a single bash command. Output only the bash command, no explanation."},
{"role": "user", "content": "find all python files modified in the last 7 days"},
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
response = generate(model, tokenizer, prompt=prompt, max_tokens=128, verbose=False)
print(response)
# find . -name "*.py" -mtime -7
mlx_lm.generate \
--model devinxx/Llama-3.2-1B-nl2bash \
--prompt "find all log files larger than 100MB"
| Natural Language | Command |
|---|---|
| find all python files modified in the last week | find . -name "*.py" -mtime -7 |
| list all running processes sorted by memory | ps aux --sort=-%mem |
| count lines in all csv files recursively | find . -name "*.csv" | xargs wc -l |
| show disk usage of current directory sorted by size | du -sh * | sort -rh |
| compress a folder to tar.gz | tar -czf archive.tar.gz folder/ |
Training data: devinxx/nl2bash-combined
Combined from:
Llama 3.2 Community License — see Meta's license terms.
4-bit
Base model
mlx-community/Llama-3.2-1B-Instruct-bf16