Commit
·
25ae364
1
Parent(s):
de29ba2
Updated README.md
Browse files
README.md
CHANGED
@@ -1,9 +1,137 @@
|
|
1 |
---
|
2 |
-
license: mit
|
3 |
library_name: transformers
|
4 |
-
pipeline_tag:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
---
|
6 |
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
-
|
|
|
|
1 |
---
|
|
|
2 |
library_name: transformers
|
3 |
+
pipeline_tag: translation
|
4 |
+
license: mit
|
5 |
+
datasets:
|
6 |
+
- westenfelder/NL2SH-ALFA
|
7 |
+
language:
|
8 |
+
- en
|
9 |
+
base_model: Qwen/Qwen2.5-Coder-7B-Instruct
|
10 |
+
model-index:
|
11 |
+
- name: Qwen2.5-Coder-7B-Instruct-NL2SH
|
12 |
+
results:
|
13 |
+
- task:
|
14 |
+
type: translation
|
15 |
+
name: Natural Language to Bash Translation
|
16 |
+
dataset:
|
17 |
+
type: translation
|
18 |
+
name: NL2SH-ALFA
|
19 |
+
split: test
|
20 |
+
metrics:
|
21 |
+
- type: accuracy
|
22 |
+
value: 0.51
|
23 |
+
name: InterCode-ALFA
|
24 |
+
source:
|
25 |
+
name: InterCode-ALFA
|
26 |
+
url: https://arxiv.org/abs/2502.06858
|
27 |
---
|
28 |
|
29 |
+
# Model Card for Qwen2.5-Coder-7B-Instruct-NL2SH
|
30 |
+
This model translates natural language (English) instructions to Bash commands.
|
31 |
+
|
32 |
+
## Model Details
|
33 |
+
### Model Description
|
34 |
+
This model is a fine-tuned version of the [Qwen2.5-Coder-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-7B-Instruct) model trained on the [NL2SH-ALFA](https://huggingface.co/datasets/westenfelder/NL2SH-ALFA) dataset for the task of natural language to Bash translation (NL2SH). For more information, please refer to the [paper](https://arxiv.org/abs/2502.06858).
|
35 |
+
- **Developed by:** [Anyscale Learning For All (ALFA) Group at MIT-CSAIL](https://alfagroup.csail.mit.edu/)
|
36 |
+
- **Language:** English
|
37 |
+
- **License:** MIT License
|
38 |
+
- **Finetuned from model:** [Qwen/Qwen2.5-Coder-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-7B-Instruct)
|
39 |
+
|
40 |
+
### Model Sources
|
41 |
+
- **Repository:** [GitHub Repo](https://github.com/westenfelder/NL2SH)
|
42 |
+
- **Paper:** [LLM-Supported Natural Language to Bash Translation](https://arxiv.org/abs/2502.06858)
|
43 |
+
|
44 |
+
## Uses
|
45 |
+
### Direct Use
|
46 |
+
This model is intended for research on machine translation. The model can also be used as an educational resource for learning Bash.
|
47 |
+
|
48 |
+
### Out-of-Scope Use
|
49 |
+
This model should not be used in production or automated systems without human verification.
|
50 |
+
|
51 |
+
**Considerations for use in high-risk environments:** This model should not be used in high-risk environments due to its low accuracy and potential for generating harmful commands.
|
52 |
+
|
53 |
+
## Bias, Risks, and Limitations
|
54 |
+
This model has a tendency to generate overly complex and incorrect Bash commands. It may produce harmful commands that delete data or corrupt a system. This model is not intended for natural languages other than English, scripting languages or than Bash, or multi-line Bash scripts.
|
55 |
+
|
56 |
+
### Recommendations
|
57 |
+
Users are encouraged to use this model as Bash reference tool and should not execute commands without verification.
|
58 |
+
|
59 |
+
## How to Get Started with the Model
|
60 |
+
Use the code below to get started with the model.
|
61 |
+
```python
|
62 |
+
import torch
|
63 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
64 |
+
|
65 |
+
def translate(prompt):
|
66 |
+
model_name = "westenfelder/Qwen2.5-Coder-7B-Instruct-NL2SH"
|
67 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, clean_up_tokenization_spaces=False)
|
68 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, device_map="cuda", torch_dtype=torch.bfloat16)
|
69 |
+
|
70 |
+
messages = [
|
71 |
+
{"role": "system", "content": "Your task is to translate a natural language instruction to a Bash command. You will receive an instruction in English and output a Bash command that can be run in a Linux terminal."},
|
72 |
+
{"role": "user", "content": f"{prompt}"},
|
73 |
+
]
|
74 |
+
|
75 |
+
tokens = tokenizer.apply_chat_template(
|
76 |
+
messages,
|
77 |
+
add_generation_prompt=True,
|
78 |
+
tokenize=True,
|
79 |
+
return_tensors="pt"
|
80 |
+
).to(model.device)
|
81 |
+
|
82 |
+
attention_mask = torch.ones_like(tokens)
|
83 |
+
|
84 |
+
outputs = model.generate(
|
85 |
+
tokens,
|
86 |
+
attention_mask=attention_mask,
|
87 |
+
max_new_tokens=100,
|
88 |
+
do_sample=False,
|
89 |
+
temperature=None,
|
90 |
+
top_p=None,
|
91 |
+
top_k=None,
|
92 |
+
)
|
93 |
+
|
94 |
+
response = outputs[0][tokens.shape[-1]:]
|
95 |
+
return tokenizer.decode(response, skip_special_tokens=True)
|
96 |
+
|
97 |
+
|
98 |
+
nl = "List files in the /workspace directory that were accessed over an hour ago."
|
99 |
+
sh = translate(nl)
|
100 |
+
print(sh)
|
101 |
+
```
|
102 |
+
|
103 |
+
## Training Details
|
104 |
+
### Training Data
|
105 |
+
This model was trained on the [NL2SH-ALFA](https://huggingface.co/datasets/westenfelder/NL2SH-ALFA) dataset.
|
106 |
+
|
107 |
+
### Training Procedure
|
108 |
+
Please refer to section 4.1 and 4.3.4 of the [paper](https://arxiv.org/abs/2502.06858) for information about data pre-processing, training hyper-parameters and hardware.
|
109 |
+
|
110 |
+
## Evaluation
|
111 |
+
This model was evaluated on the [NL2SH-ALFA](https://huggingface.co/datasets/westenfelder/NL2SH-ALFA) test set using the [InterCode-ALFA](https://github.com/westenfelder/InterCode-ALFA) benchmark.
|
112 |
+
|
113 |
+
### Results
|
114 |
+
This model achieved an accuracy of **0.51** on the InterCode-ALFA benchmark.
|
115 |
+
|
116 |
+
## Environmental Impact
|
117 |
+
Experiments were conducted using a private infrastructure, which has a approximate carbon efficiency of 0.432 kgCO2eq/kWh. A cumulative of 12 hours of computation was performed on hardware of type RTX A6000 (TDP of 300W). Total emissions are estimated to be 1.56 kgCO2eq of which 0 percents were directly offset. Estimations were conducted using the [Machine Learning Emissions Calculator](https://mlco2.github.io/impact#compute).
|
118 |
+
|
119 |
+
## Citation
|
120 |
+
**BibTeX:**
|
121 |
+
```
|
122 |
+
@misc{westenfelder2025llmsupportednaturallanguagebash,
|
123 |
+
title={LLM-Supported Natural Language to Bash Translation},
|
124 |
+
author={Finnian Westenfelder and Erik Hemberg and Miguel Tulla and Stephen Moskal and Una-May O'Reilly and Silviu Chiricescu},
|
125 |
+
year={2025},
|
126 |
+
eprint={2502.06858},
|
127 |
+
archivePrefix={arXiv},
|
128 |
+
primaryClass={cs.CL},
|
129 |
+
url={https://arxiv.org/abs/2502.06858},
|
130 |
+
}
|
131 |
+
```
|
132 |
+
|
133 |
+
## Model Card Authors
|
134 |
+
Finn Westenfelder
|
135 |
|
136 |
+
## Model Card Contact
|
137 |
+
Please email [email protected] or make a pull request.
|