Instructions to use sivang/sandboxlm with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use sivang/sandboxlm with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="sivang/sandboxlm")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("sivang/sandboxlm") model = AutoModelForCausalLM.from_pretrained("sivang/sandboxlm") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use sivang/sandboxlm with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "sivang/sandboxlm" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sivang/sandboxlm", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/sivang/sandboxlm
- SGLang
How to use sivang/sandboxlm with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "sivang/sandboxlm" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sivang/sandboxlm", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "sivang/sandboxlm" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sivang/sandboxlm", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use sivang/sandboxlm with Docker Model Runner:
docker model run hf.co/sivang/sandboxlm
SandboxLM
SandboxLM is a language model fine-tuned on a carefully curated synthetic dataset using the GPT-2 architecture. This model was specifically created to act as a special advisory to AI agents using shell commands, helping them operate securely by identifying potentially harmful shell commands. SandboxLM aims to assist in improving the safety and security of AI-driven shell operations. It was inspired by the author's need to complement a tool like AGit
This is a preview release of SanboxLM and while immediately useful, is ripe yet for "production". Feedback is welcome.
Model Description
SandboxLM is built on the GPT-2 architecture, a Transformer-based language model. The model has been fine-tuned on a dataset designed to help identify and classify shell commands as either safe or potentially dangerous. This makes it suitable for security advisory tasks, particularly in environments where AI agents are used to execute shell commands.
Attention has been given to make it immediately useful:
- SandboxLM is optimized for CPU inference, as the author uses an 2019 Intel MacBook for his local work.
- SandboxLM was trained to output JSON for maximum interoperabilty.
- Effort was made to train it on many permutations of different shell commands to increase generalization (however no gurantee is made).
Use At Your Own Risk
The products/services/information provided herein are offered on an "as is" and "as available" basis, without any warranties or representations, express or implied. The user assumes all responsibility and risk for the use of these products/services/information. We do not guarantee the accuracy, completeness, or usefulness of any information provided and expressly disclaim all liability for any damages or losses arising from their use. By utilizing these products/services/information, you acknowledge and agree that you do so entirely at your own risk.
Usage
To use this model, install the transformers library and load the model and tokenizer as follows:
from transformers import pipeline
sboxlm = pipeline('text-generation', model='sivang/sandboxlm', tokenizer='sivang/sandboxlm', temperature=0.1)
import json
json.loads(sboxlm("command: rm -rf /")[0]['generated_text'].split("verdict:")[1])
{'risk': 'dangerous',
'explain': 'Deletes the root folder on the system, rendering it unusable and all data is lost.'}
Limitations
While SandboxLM performs realtively well in detecting potentially harmful shell commands (and can make some even surprisingly accurate prediction even when the context it provides seems to hellucinat!), it may not catch all edge cases or obscure security risks. It should not be solely relied upon for mission-critical systems. It is recommended to combine it with other security measures to ensure the safety of shell operations. Additionally, since it was trained on specific datasets, it may reflect any biases present in those datasets.
Copyright (c) Sivan Grünberg Vitakka Consulting
- Downloads last month
- 9