Commit
·
0d1f055
1
Parent(s):
ef9d945
Updated README.md
Browse files
README.md
CHANGED
|
@@ -7,7 +7,6 @@ datasets:
|
|
| 7 |
language:
|
| 8 |
- en
|
| 9 |
base_model: meta-llama/Llama-3.2-1B-Instruct
|
| 10 |
-
|
| 11 |
model-index:
|
| 12 |
- name: Llama-3.2-1B-Instruct-NL2SH
|
| 13 |
results:
|
|
@@ -23,10 +22,122 @@ model-index:
|
|
| 23 |
value: 0.37
|
| 24 |
name: InterCode-ALFA
|
| 25 |
source:
|
| 26 |
-
name:
|
| 27 |
url: https://arxiv.org/abs/2502.06858
|
| 28 |
---
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
|
|
|
|
|
|
| 7 |
language:
|
| 8 |
- en
|
| 9 |
base_model: meta-llama/Llama-3.2-1B-Instruct
|
|
|
|
| 10 |
model-index:
|
| 11 |
- name: Llama-3.2-1B-Instruct-NL2SH
|
| 12 |
results:
|
|
|
|
| 22 |
value: 0.37
|
| 23 |
name: InterCode-ALFA
|
| 24 |
source:
|
| 25 |
+
name: InterCode-ALFA
|
| 26 |
url: https://arxiv.org/abs/2502.06858
|
| 27 |
---
|
| 28 |
|
| 29 |
+
# Model Card for Llama-3.2-1B-Instruct-NL2SH
|
| 30 |
+
This model translates natural language (English) instructions into Bash commands.
|
| 31 |
+
|
| 32 |
+
## Model Details
|
| 33 |
+
### Model Description
|
| 34 |
+
This model is a fine-tuned version of the Llama-3.2-1B-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 linked paper.
|
| 35 |
+
- **Developed by:** Anyscale Learning For All (ALFA) Group at MIT-CSAIL
|
| 36 |
+
- **Language:** English
|
| 37 |
+
- **License:** MIT License
|
| 38 |
+
- **Finetuned from model:** meta-llama/Llama-3.2-1B-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 |
+
**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.
|
| 51 |
+
|
| 52 |
+
## Bias, Risks, and Limitations
|
| 53 |
+
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.
|
| 54 |
+
|
| 55 |
+
### Recommendations
|
| 56 |
+
Users are encouraged to use this model as Bash reference tool and should not execute commands without verification.
|
| 57 |
+
|
| 58 |
+
## How to Get Started with the Model
|
| 59 |
+
Use the code below to get started with the model.
|
| 60 |
+
```python
|
| 61 |
+
import torch
|
| 62 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 63 |
+
|
| 64 |
+
def translate(prompt):
|
| 65 |
+
model_name = "westenfelder/Llama-3.2-1B-Instruct-NL2SH"
|
| 66 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, clean_up_tokenization_spaces=False)
|
| 67 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, device_map="cuda", torch_dtype=torch.bfloat16)
|
| 68 |
+
|
| 69 |
+
messages = [
|
| 70 |
+
{"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."},
|
| 71 |
+
{"role": "user", "content": f"{prompt}"},
|
| 72 |
+
]
|
| 73 |
+
|
| 74 |
+
tokens = tokenizer.apply_chat_template(
|
| 75 |
+
messages,
|
| 76 |
+
add_generation_prompt=True,
|
| 77 |
+
tokenize=True,
|
| 78 |
+
return_tensors="pt"
|
| 79 |
+
).to(model.device)
|
| 80 |
+
|
| 81 |
+
attention_mask = torch.ones_like(tokens)
|
| 82 |
+
|
| 83 |
+
terminators = [
|
| 84 |
+
tokenizer.eos_token_id,
|
| 85 |
+
tokenizer.convert_tokens_to_ids("<|eot_id|>")
|
| 86 |
+
]
|
| 87 |
+
|
| 88 |
+
outputs = model.generate(
|
| 89 |
+
tokens,
|
| 90 |
+
attention_mask=attention_mask,
|
| 91 |
+
max_new_tokens=100,
|
| 92 |
+
eos_token_id=terminators,
|
| 93 |
+
pad_token_id=tokenizer.eos_token_id,
|
| 94 |
+
do_sample=False,
|
| 95 |
+
temperature=None,
|
| 96 |
+
top_p=None,
|
| 97 |
+
top_k=None,
|
| 98 |
+
)
|
| 99 |
+
|
| 100 |
+
response = outputs[0][tokens.shape[-1]:]
|
| 101 |
+
return tokenizer.decode(response, skip_special_tokens=True)
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
nl = "List files in the /workspace directory that were accessed over an hour ago."
|
| 105 |
+
sh = translate(nl)
|
| 106 |
+
print(sh)
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
## Training Details
|
| 110 |
+
### Training Data
|
| 111 |
+
This model was trained on the [NL2SH-ALFA](https://huggingface.co/datasets/westenfelder/NL2SH-ALFA) dataset.
|
| 112 |
+
|
| 113 |
+
### Training Procedure
|
| 114 |
+
Please refer to section 4.1 and 4.3.4 of the paper for information about data pre-processing, training hyper-parameters and hardware.
|
| 115 |
+
|
| 116 |
+
## Evaluation
|
| 117 |
+
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.
|
| 118 |
+
|
| 119 |
+
### Results
|
| 120 |
+
This model achieved an accuracy of 0.37 on the InterCode-ALFA benchmark.
|
| 121 |
+
|
| 122 |
+
## Environmental Impact
|
| 123 |
+
Experiments were conducted using a private infrastructure, which has a carbon efficiency of 0.432 kgCO$_2$eq/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 kgCO$_2$eq of which 0 percents were directly offset. Estimations were conducted using the [Machine Learning Emissions Calculator](https://mlco2.github.io/impact#compute).
|
| 124 |
+
|
| 125 |
+
## Citation
|
| 126 |
+
**BibTeX:**
|
| 127 |
+
```
|
| 128 |
+
@misc{westenfelder2025llmsupportednaturallanguagebash,
|
| 129 |
+
title={LLM-Supported Natural Language to Bash Translation},
|
| 130 |
+
author={Finnian Westenfelder and Erik Hemberg and Miguel Tulla and Stephen Moskal and Una-May O'Reilly and Silviu Chiricescu},
|
| 131 |
+
year={2025},
|
| 132 |
+
eprint={2502.06858},
|
| 133 |
+
archivePrefix={arXiv},
|
| 134 |
+
primaryClass={cs.CL},
|
| 135 |
+
url={https://arxiv.org/abs/2502.06858},
|
| 136 |
+
}
|
| 137 |
+
```
|
| 138 |
+
|
| 139 |
+
## Model Card Authors
|
| 140 |
+
Finn Westenfelder
|
| 141 |
|
| 142 |
+
## Model Card Contact
|
| 143 |
+
Please email [email protected] or make a pull request.
|