CoolFace
Modelpublic

abandonedmonk/TinyLlama-1.1B-NL2SH-Alpaca-v1

sourceHugging Facemitupdated 1y agoView on Hugging Face
0likes11downloads
Model Card

Model Card for TinyLlama-1.1B-NL2SH-Alpaca

This model is a fine-tuned version of [unsloth/tinyllama-chat](https://huggingface.co/unsloth/tinyllama-chat). It has been fine-tuned on the NL2SH-Alpaca dataset for converting natural language instructions into bash commands.

The model outputs one bash command per instruction, even if multiple alternatives exist in the training dataset.


Quick start

python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

# Load the model and tokenizer
model_name = "abandonedmonk/TinyLlama-1.1B-NL2SH-Alpaca"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name).to("cuda")

# Inference helper
def generate_command(model, tokenizer, instruction, inp=""):
    # build prompt in Alpaca-style
    prompt = f"""Instruction: {instruction}
Input: {inp}
Response:
"""
    inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
    outputs = model.generate(
        **inputs,
        max_new_tokens=100,
        do_sample=False,    # greedy decoding
        temperature=0.0,
        num_return_sequences=1
    )
    generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
    # Extract the first line (command) after "Response:"
    # If you want to keep all the commands, just simply return 'generated_text' instead of 'response'
    response = generated_text.strip().split("Response:")[-1].strip().split('\n')[0]
    return response

# Example usage
instruction = "Rename all files with .andnav extension to .tile"
bash_cmd = generate_command(model, tokenizer, instruction)
print("Generated bash command:", bash_cmd)

Training procedure

This model was fine-tuned using Supervised Fine-Tuning (SFT) on the NL2SH-Alpaca dataset, which contains natural language instructions paired with shell commands.

  • —Base model: unsloth/tinyllama-chat
  • —Dataset: abandonedmonk/NL2SH-ALPACA
  • —Frameworks: PEFT, Transformers, Unsloth
  • —Number of epochs: 3
  • —Batch size / seq length: 4

Citations

bibtex
@misc{vonwerra2022trl,
  title        = {{TRL: Transformer Reinforcement Learning}},
  author       = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallou{\'e}dec},
  year         = 2020,
  journal      = {GitHub repository},
  publisher    = {GitHub},
  howpublished = {\url{https://github.com/huggingface/trl}}
}

License

This model is released under the MIT License


Contributors / Maintainers

  • —Anshuman Jena – fine-tuner, and maintainer of this model 🐸

Notes

  • —This model is designed for English instructions only.
  • —Outputs one command per instruction; alternative commands can be manually handled if desired.
  • —For reproducibility, set the same seed (3407) during fine-tuning.