File size: 6,294 Bytes
416af8d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60e1d01
 
 
45fbc69
60e1d01
 
 
 
 
 
 
 
 
 
 
 
 
 
afd4fe0
60e1d01
 
 
 
 
 
 
45fbc69
60e1d01
 
45fbc69
60e1d01
 
 
 
 
 
 
45fbc69
60e1d01
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45fbc69
60e1d01
 
45fbc69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60e1d01
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4f25b51
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
---
license: apache-2.0
language:
- en
tags:
- lfm2.5
- kali-linux
- terminal-executor
- tool-calling
- function-calling
- executor
- cybersecurity
- penetration-testing
base_model: LiquidAI/LFM2.5-350M-Base
datasets:
- iselabvn/Kali-terminal-executor-v2
library_name: transformers
pipeline_tag: text-generation
model-index:
- name: Kali-Terminus-v2
  results:
  - task:
      type: text-generation
      name: Shell Command Generation
    dataset:
      name: Kali-Terminus Evaluation Suite
      type: custom
    metrics:
    - type: strict_pass_rate
      value: 92.31
      name: Strict Pass Rate
    - type: tool_call_parse_rate
      value: 100
      name: Tool Call Parse Rate
    - type: semantic_command_accuracy
      value: 92.31
      name: Semantic Command Accuracy
new_version: iselabvn/Kali-Terminus-v3
---

# Kali-Terminus-v2

**Kali-Terminus-v2** is a fine-tuned [LFM2.5-350M](https://huggingface.co/LiquidAI/LFM2.5-350M-Base) model specialized for Kali Linux terminal command execution. It converts natural language instructions into precise shell commands with native LFM2.5 `<|tool_call_start|>`/`<|tool_call_end|>` JSON tool calls.

This is the **Executor Agent** in a multi-agent penetration-testing system — it translates one bounded instruction into one structured terminal action.

## Model Details

| Property | Value |
|---|---|
| **Base Model** | [LFM2.5-350M](https://huggingface.co/LiquidAI/LFM2.5-350M-Base) |
| **Architecture** | LFM2 hybrid (10 conv + 6 full-attention layers) |
| **Parameters** | 350M |
| **Context Length** | 128K tokens (trained with 1024) |
| **Fine-Tuning** | LoRA (r=16, alpha=32, 11 target modules) |
| **Training Data** | iselabvn/Kali-terminal-executor-v2 (2,418 samples) |
| **Precision** | float32 (merged) |
| **Format** | `<\|im_start\|>` / `<\|im_end\|>` with native `<\|tool_call_start\|>`/`<\|tool_call_end\|>` JSON tool calls |

## Performance

Evaluated across 5 scenarios (26 turns) covering network recon, system enumeration, web recon, DNS recon, and self-correction:

| Metric | Score |
|---|---|
| **Strict Pass Rate** | **92.31%** |
| Tool Call Parse Rate | 100.0% |
| Exactly One Tool Call | 100.0% |
| Semantic Command Accuracy | 92.31% |

### Comparison with V1

| Model | Strict Pass Rate | Improvement |
|---|---|---|
| Kali-Terminus-v1 (FunctionGemma-270M) | 65.8% | — |
| Kali-Terminus-v1 (LFM2.5-350M) | 50.0% | — |
| **Kali-Terminus-v2** | **92.31%** | **+42.3 pp over v1 LFM2.5** |

## Dataset

Fine-tuned on [iselabvn/Kali-terminal-executor-v2](https://huggingface.co/datasets/iselabvn/Kali-terminal-executor-v2), a curated collection of 2,418 shell command execution pairs combining 1,380 source records with 1,000 synthetically augmented records (DeepSeek-V4-Flash).

Top tools in training data:
`nmap` · `dig` · `gobuster` · `curl` · `whatweb` · `sqlmap` · `find` · `hydra` · `uname` · `ss` · `subfinder` · `dnsrecon` · `ffuf` · `id` · `nikto`

## Usage

```python

from transformers import AutoModelForCausalLM, AutoTokenizer



model = AutoModelForCausalLM.from_pretrained("iselabvn/Kali-Terminus-v2", trust_remote_code=True)

tokenizer = AutoTokenizer.from_pretrained("iselabvn/Kali-Terminus-v2", trust_remote_code=True)



messages = [

    {"role": "user", "content": "Scan port 80 on 192.168.1.1"}

]

inputs = tokenizer.apply_chat_template(

    messages,

    tools=[{

        "type": "function",

        "function": {

            "name": "exec",

            "description": "Execute a shell command in the Kali terminal.",

            "parameters": {

                "type": "object",

                "properties": {"command": {"type": "string"}},

                "required": ["command"]

            }

        }

    }],

    add_generation_prompt=True,

    return_tensors="pt"

)

outputs = model.generate(**inputs, max_new_tokens=256)

response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=False)

print(response)

# Expected: <|tool_call_start|>{"name": "exec", "arguments": {"command": "nmap -p 80 192.168.1.1"}}<|tool_call_end|>

```

## Tool Call Format

Kali-Terminus-v2 produces native **LFM2.5 tool calls** wrapped in `<|tool_call_start|>` and `<|tool_call_end|>` tokens, output as JSON:

```

<|tool_call_start|>{"name": "exec", "arguments": {"command": "nmap -p 80 192.168.1.1"}}<|tool_call_end|>

```

A system instruction `Output function calls as JSON.` is prepended so the model emits JSON rather than the default Pythonic calls.

## Tool Call Format

Kali-Terminus-v2 produces native **LFM2.5 tool calls** wrapped in `<|tool_call_start|>` and `<|tool_call_end|>` tokens, output as JSON:

```

<|tool_call_start|>{"name": "exec", "arguments": {"command": "nmap -p 80 192.168.1.1"}}<|tool_call_end|>

```

A system instruction `Output function calls as JSON.` is prepended so the model emits JSON rather than the default Pythonic calls.

## Intended Use

- **Executor Agent** in multi-agent penetration-testing systems
- **Single-Turn Kali Terminal Assistant** — converts natural language to shell commands
- **Not recommended** for general conversation or chatbot use

## Limitations

- Designed for single-turn command generation; multi-turn interaction requires external state management
- Commands target authorized lab environments only; not for production systems without human review
- Best performance on the 15 core Kali/Linux tools seen during training

## Training Details

| Hyperparameter | Value |
|---|---|
| LoRA rank | 16 |
| LoRA alpha | 32 |
| LoRA dropout | 0.05 |
| Target modules | in_proj, out_proj, q_proj, k_proj, v_proj, w1, w2, w3, gate_proj, up_proj, down_proj |
| Learning rate | 2e-4 (cosine) |
| Batch size | 4 |
| Gradient accumulation | 4 |
| Effective batch size | 16 |
| Epochs | 3 (best checkpoint at step 352, ~2.7 epochs) |
| Max sequence length | 1024 |
| Optimizer | AdamW |
| Precision | bfloat16 |

## Citation

```bibtex

@misc{kali-terminus-v2,

  author = {ISeLab},

  title = {Kali-Terminus-v2: Fine-tuned LFM2.5-350M for Kali Linux Terminal Execution},

  year = {2026},

  publisher = {Hugging Face},

  url = {https://huggingface.co/iselabvn/Kali-Terminus-v2}

}

```