Skip to content

AneKazek/HexaSLM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

HexaSLM: Can Chain-of-Verification Secure the Cybersecurity Domain?

HexaSLM Logo Hugging Face

License Python Unsloth Code Style: Black

HexaSLM leverages the power of Unsloth to provide blazing fast fine-tuning and inference for Large Language Models (LLMs). It integrates customized data pipelines for cybersecurity and streamlined CLI tools for interaction.

Get Started β€’ Documentation β€’ Features β€’ Contributing


πŸš€ Features

  • ⚑ Blazing Fast: 2x faster training and 70% less memory usage with Unsloth.
  • 🧠 Chain of Verification: Implements CoVe to reduce hallucinations and verify cybersecurity advice.
  • πŸ›‘οΈ Cybersecurity Focused: Pre-configured data pipelines for cybersecurity datasets.
  • πŸ–₯️ CLI Interface: Rich, interactive terminal chat for testing your models.
  • πŸ“¦ Modular: Valid Python package structure for easy integration.

πŸ› οΈ Data Flow

graph LR
    A[Raw Data] -->|Process| B(Processed Dataset)
    B -->|Fine-tune| C{Unsloth Model}
    C -->|Save| D[LoRA Adapters]
    D -->|Load| E[Inference CLI]
    E -->|CoVe| F[Verified Output]
    F -->|Chat| G((User))
    style C fill:#f96,stroke:#333
    style E fill:#9cf,stroke:#333
    style F fill:#6f9,stroke:#333
Loading

⚑ Quick Start

1. Installation

Clone the repository and install dependencies using uv (recommended) or pip.

# Clone
git clone https://github.com/AneKazek/HexaSLM.git
cd HexaSLM

# Install with uv (Recommended)
uv sync

# Or with pip
pip install .

2. Run Inference

Interact with your model directly from the terminal!

# Run the chat interface (defaults to the included LoRA adapter)
python -m hexa_slm.inference.console

# Or specify a custom model/adapter
python -m hexa_slm.inference.console --model-path "unsloth/mistral-7b-instruct-v0.2-bnb-4bit"
πŸ‘€ See CLI Options
$ python -m hexa_slm.inference.console --help

Usage: python -m hexa_slm.inference.console [OPTIONS]

  Start an interactive chat session with the HexaSLM model.

Options:
  --model-path TEXT       Path to the model or HuggingFace ID [default: models/cove_cybersec_lora]
  --use-4bit / --no-use-4bit
                          Use 4-bit quantization [default: True]
  --system-prompt TEXT    System prompt for the chat [default: You are a cybersecurity expert assistant.]
  --help                  Show this message and exit.

🧠 Chain of Verification (CoVe)

HexaSLM implements a systematic Chain of Verification process to ensure high-quality, secure responses.

# Enable CoVe mode in CLI
python -m hexa_slm.inference.console --cove

When enabled, the model follows a 4-step reasoning process:

  1. Initial Analysis: Breaks down the request.
  2. Verification Planning: Identifies critical security checks.
  3. Systematic Verification: Validates against OWASP/NIST standards.
  4. Final Verified Response: Delivers the safe, verified answer.

πŸ“š Documentation

Training

To train a new model, use the provided notebooks in notebooks/.

  1. 01-hexaslm-train.ipynb: Main fine-tuning workflow.
  2. 02-hexaslm-inference.ipynb: Validation and testing.

Project Structure

HexaSLM/
β”œβ”€β”€ data/               # Data storage
β”‚   └── raw/            # Original, immutable data
β”œβ”€β”€ models/             # Model checkpoints (adapters)
β”œβ”€β”€ notebooks/          # Jupyter notebooks
β”œβ”€β”€ src/                # Source code
β”‚   └── hexa_slm/
β”‚       β”œβ”€β”€ data/       # Data loaders
β”‚       β”œβ”€β”€ inference/  # Inference scripts (CLI)
β”‚       └── utils/      # Helpers
β”œβ”€β”€ pyproject.toml      # Configuration
└── README.md           # You are here!

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

Distributed under the Apache 2.0 License. See LICENSE for more information.

About

A cybersecurity-focused Small Language Model (SLM) based on Qwen2.5. Features Chain of Verification (CoVe) for reduced hallucinations and verified security reasoning. πŸ›‘οΈβš‘

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors