168 lines
2.6 KiB
Markdown
168 lines
2.6 KiB
Markdown
---
|
|
license: gemma
|
|
base_model:
|
|
- google/gemma-3-1b-it
|
|
tags:
|
|
- gemma
|
|
- terminal
|
|
- linux
|
|
- command-generation
|
|
- sft
|
|
- Mica
|
|
- fine-tuned
|
|
pipeline_tag: text-generation
|
|
library_name: transformers
|
|
---
|
|
|
|
# Gemma 3 1B Terminal Assistant
|
|
|
|
A fine-tuned version of Google's **Gemma 3 1B Instruction Tuned model** specialized for terminal command generation.
|
|
|
|
This model was trained to understand natural language requests and generate safe, minimal terminal commands.
|
|
|
|
## Model Details
|
|
|
|
Base Model:
|
|
|
|
- google/gemma-3-1b-it
|
|
|
|
Fine-tuning Method:
|
|
|
|
- Supervised Fine-Tuning (SFT)
|
|
- Mica fine-tuning
|
|
- Mica merged into the base model
|
|
|
|
Training Dataset:
|
|
|
|
- mshojaei77/terminal-command-execution-sft
|
|
|
|
Task:
|
|
|
|
- Linux terminal commands
|
|
- Windows commands
|
|
- Shell scripting
|
|
- Command explanation
|
|
- Safe command generation
|
|
|
|
|
|
## Example Usage
|
|
|
|
|
|
### Python Example
|
|
|
|
```python
|
|
from transformers import AutoTokenizer, AutoModelForCausalLM
|
|
import torch
|
|
|
|
|
|
model_name = "Paulwalker4884/gemma-3-1b-terminal-assistant"
|
|
|
|
|
|
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
|
|
|
model = AutoModelForCausalLM.from_pretrained(
|
|
model_name,
|
|
torch_dtype=torch.float16,
|
|
device_map="auto"
|
|
)
|
|
|
|
|
|
messages = [
|
|
{
|
|
"role": "system",
|
|
"content": "You are a safe terminal command assistant."
|
|
},
|
|
{
|
|
"role": "user",
|
|
"content": "Find all python files recursively"
|
|
}
|
|
]
|
|
|
|
|
|
inputs = tokenizer.apply_chat_template(
|
|
messages,
|
|
tokenize=True,
|
|
add_generation_prompt=True,
|
|
return_tensors="pt"
|
|
).to(model.device)
|
|
|
|
|
|
outputs = model.generate(
|
|
inputs,
|
|
max_new_tokens=128,
|
|
temperature=0.2
|
|
)
|
|
|
|
|
|
response = tokenizer.decode(
|
|
outputs[0][inputs.shape[-1]:],
|
|
skip_special_tokens=True
|
|
)
|
|
|
|
|
|
print(response)
|
|
```
|
|
|
|
---
|
|
|
|
## Example
|
|
|
|
Input:
|
|
|
|
```
|
|
Find all python files recursively
|
|
```
|
|
|
|
Output:
|
|
|
|
```bash
|
|
find . -name "*.py"
|
|
```
|
|
|
|
|
|
Input:
|
|
|
|
```
|
|
Find all log files modified in the last 7 days and save them
|
|
```
|
|
|
|
Output:
|
|
|
|
```bash
|
|
find . -name "*.log" -mtime -7 > recent_logs.txt
|
|
```
|
|
|
|
|
|
## Safety
|
|
|
|
This model is trained to avoid blindly generating destructive commands.
|
|
|
|
For potentially dangerous operations, users should verify commands before execution.
|
|
|
|
|
|
## Limitations
|
|
|
|
- The model may generate incorrect commands.
|
|
- Always review generated commands before running them.
|
|
- Performance depends on the quality of the input prompt.
|
|
|
|
|
|
## Training Information
|
|
|
|
Dataset size:
|
|
|
|
- Train: 31,429 examples
|
|
- Evaluation: 239 examples
|
|
|
|
|
|
|
|
|
|
|
|
Frameworks:
|
|
|
|
- Transformers
|
|
- TRL
|
|
- PEFT
|
|
- PyTorch
|
|
|
|
BY : Yasin Keykha |