File size: 2,962 Bytes
cd3d423
 
 
 
4ae366d
 
 
cd3d423
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7c158bc
cd3d423
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6b3318a
 
 
 
 
 
4ae366d
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
---
license: apache-2.0
base_model:
- google-t5/t5-base
language:
- en
library_name: transformers
---

# LaaLM — Linux as a Language Model

## Model Description

LaaLM (Linux as a Language Model) is a fine-tuned T5-base model that simulates the textual output of Linux shell commands.

Given:

- a textual description of the current system state (working directory, files, environment), and

- a bash command,

the model predicts what the command would output if executed in a Linux environment.

This is intended as a ***research and experimentation model***, not a real shell replacement.

## How It Works

Input format:
```
System: <system state description>
User: <bash command>
```

Output:

```
<predicted stdout / stderr>
```

The system state is dynamically generated externally and passed to the model as text.
The model does not maintain internal state, it only predicts output from the provided context.

## Example

### Input
```
System: Current directory: /home/user
Files in current directory:
- test.txt (empty)
Environment: USER=user, HOME=/home/user
User: ls
```
### Output
```
test.txt

```
## Intended Use

- Research into learned environment simulation
- Studying command semantics and error modeling
- Dataset generation experiments
- Educational exploration

## Limitations

- This model does not execute real commands.
- Even though it's also trained on cases where it's supposed to error out it may still hallucinate incorrect behavior for unseen commands or edge cases.
- File system state must be maintained externally.
- Output accuracy depends heavily on how closely the prompt matches the training format.
- Not suitable for safety-critical or production systems.

## Commands It Knows

- pwd
- echo
- cat
- ls
- mkdir
- touch

Any other commands than these might either give wrong results or fail.

## Training

- Base model: T5-base
- Fine-tuned on synthetic Linux command datasets
- Mixed-precision training on NVIDIA V100 GPU
- Approximately 80k training samples

## Quick Usage

```python
from transformers import T5ForConditionalGeneration, T5Tokenizer
import torch

model_id = "LaaLM/LaaLM-v1"

tokenizer = T5Tokenizer.from_pretrained(model_id)
model = T5ForConditionalGeneration.from_pretrained(model_id).cuda()
model.eval()

def run_command(system_state, command):
prompt = f"System: {system_state}\nUser: {command}"
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")

with torch.no_grad():
output = model.generate(
**inputs,
max_new_tokens=128,
do_sample=False
)

return tokenizer.decode(output[0], skip_special_tokens=True)

print(run_command("Current directory: /home/user", "pwd"))
```

## Shoutouts

Very big thanks to [@mradermacher](https://huggingface.co/mradermacher) for spending time and compute to generate GGUF Quantized versions of LaaLM-v1!

Check out the quantized versions he made [here](https://huggingface.co/mradermacher/LaaLM-v1-GGUF). With these you can run LaaLM-v1 on low tier GPUs or CPUs!