GithubHelp home page GithubHelp logo

llama-honeypot's Introduction

llama-honeypot

A honeypot backend API based on fine-tuning LLaMA via LoRA.

This repo contains code for fine-tuning LLaMA-7B vai LoRA, in order to fit the requirements for honeypot backend API. We gathered thousands of response paired with commands, try to adjust the model into a Linux console. In addition, we designed a prompt template which supports history, thus the model could better support multi-round interaction.

Setup

1.Install dependencies.

pip install -r requirements.txt

2.Prepare LLaMA model with HuggingFace type. Either from HuggingFace repo or converted locally from original LLaMA model through scripts provided by transformers.

Fine-tune Data Example

[
    {
        "command": "pwd",
        "history": [],
        "output": "/home/user"
    },
    {
        "command": "pwd",
        "history": [["cd Document", ""]],
        "output": "/home/user/Document"
    }
]

Training(finetune.py)

  • Easy Example
python finetune.py \
    --base_model /path/to/base/model \
    --data_path /path/to/data/file \
    --output_dir ./lora-honeypot
  • Hyper-parameters Example
python finetune.py \
    --base_model /path/to/base/model \
    --data_path /path/to/data/file \
    --output_dir ./lora-honeypot \
    --batch_size 128 \
    --micro_batch_size 4 \
    --num_epochs 3 \
    --learning_rate 1e-4 \
    --cutoff_len 512 \
    --val_set_size 2000 \
    --lora_rank 8 \
    --lora_alpha 16 \
    --lora_dropout 0.05 \
    --lora_target_modules '[q_proj,v_proj]' \
    --train_on_inputs \
    --group_by_length

Inference

Launch API

python api.py \
	--base_model /path/to/base/model \
	--lora_weights ./lora-honeypot

API Usage

  • Easy Example
curl -X POST "http://127.0.0.1:8000" \
     -H 'Content-Type: application/json' \
     -d '{"command": "pwd", "history": []}'
  • Hyper-parameters Example
curl -X POST "http://127.0.0.1:8000" \
     -H 'Content-Type: application/json' \
     -d '{"command": "pwd", "history": [], "temperature": 0.4, "top_p": 0.75, "top_k": 40, "num_beams": 4, "max_new_tokens": 128}'

llama-honeypot's People

Contributors

coldwave96 avatar

Watchers

 avatar  avatar

llama-honeypot's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.