Instructions to use QuantFactory/walledguard-c-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use QuantFactory/walledguard-c-GGUF with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="QuantFactory/walledguard-c-GGUF") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("QuantFactory/walledguard-c-GGUF", dtype="auto") - llama-cpp-python
How to use QuantFactory/walledguard-c-GGUF with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="QuantFactory/walledguard-c-GGUF", filename="walledguard-c.Q2_K.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use QuantFactory/walledguard-c-GGUF with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf QuantFactory/walledguard-c-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf QuantFactory/walledguard-c-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf QuantFactory/walledguard-c-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf QuantFactory/walledguard-c-GGUF:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf QuantFactory/walledguard-c-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf QuantFactory/walledguard-c-GGUF:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf QuantFactory/walledguard-c-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf QuantFactory/walledguard-c-GGUF:Q4_K_M
Use Docker
docker model run hf.co/QuantFactory/walledguard-c-GGUF:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use QuantFactory/walledguard-c-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "QuantFactory/walledguard-c-GGUF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "QuantFactory/walledguard-c-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/QuantFactory/walledguard-c-GGUF:Q4_K_M
- SGLang
How to use QuantFactory/walledguard-c-GGUF 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 "QuantFactory/walledguard-c-GGUF" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "QuantFactory/walledguard-c-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "QuantFactory/walledguard-c-GGUF" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "QuantFactory/walledguard-c-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use QuantFactory/walledguard-c-GGUF with Ollama:
ollama run hf.co/QuantFactory/walledguard-c-GGUF:Q4_K_M
- Unsloth Studio new
How to use QuantFactory/walledguard-c-GGUF with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for QuantFactory/walledguard-c-GGUF to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for QuantFactory/walledguard-c-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for QuantFactory/walledguard-c-GGUF to start chatting
- Docker Model Runner
How to use QuantFactory/walledguard-c-GGUF with Docker Model Runner:
docker model run hf.co/QuantFactory/walledguard-c-GGUF:Q4_K_M
- Lemonade
How to use QuantFactory/walledguard-c-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull QuantFactory/walledguard-c-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.walledguard-c-GGUF-Q4_K_M
List all available models
lemonade list
llm.create_chat_completion(
messages = [
{
"role": "user",
"content": "What is the capital of France?"
}
]
)QuantFactory/walledguard-c-GGUF
This is quantized version of walledai/walledguard-c created using llama.cpp
Model Description
🔥 WalledGuard comes in two versions: Community and Advanced*. To get access to the advanced version, please contact us at admin@walled.ai
🔥 Please check out our LLM Safety Evaluation One-Stop Center: Walled Eval!
(*More performant, suitable for enterprise use)
Note: We also provide customized guardrails for enterprise-specific use cases, please reach out to us at admin@walled.ai.
Remark: The demo tool on the right does not reflect the actual performance of the guardrail due to the HuggingFace interface limitations.
Model Details
Model Description
- Developed by: Walled AI
- Language(s) (NLP): English
- License: Apache 2.0
Direct Use
import torch
import torch.nn as nn
from transformers import AutoTokenizer, AutoModelForCausalLM
TEMPLATE = """[INST] Evaluate if the given text is harmful i.e. either it asks for unsafe information or it contains unsafe information.
<START TEXT>
{prompt}
<END TEXT>
Answer: [/INST]
"""
model_name = "walledai/walledguard-c"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
input_ids = tokenizer.encode(TEMPLATE.format(prompt="How can I make my wife burst into laughter?"), return_tensors="pt")
output = model.generate(input_ids=input_ids, max_new_tokens=20, pad_token_id=0)
prompt_len = input_ids.shape[-1]
output_decoded = tokenizer.decode(output[0][prompt_len:], skip_special_tokens=True)
prediction = 'unsafe' if 'unsafe' in output_decoded else 'safe'
print(prediction)
Inference Speed
- WalledGuard Community: ~0.1 sec/sample (4bit, on A100/A6000)
- Llama Guard 2: ~0.4 sec/sample (4bit, on A100/A6000)
Results
| Model | DynamoBench | XSTest | P-Safety | R-Safety | Average Scores |
|---|---|---|---|---|---|
| Llama Guard 1 | 77.67 | 85.33 | 71.28 | 86.13 | 80.10 |
| Llama Guard 2 | 82.67 | 87.78 | 79.69 | 89.64 | 84.95 |
| WalledGuard-C (Community Version) |
92.00 | 86.89 | 87.35 | 86.78 | 88.26 â–² 3.9% |
| WalledGuard-A (Advanced Version) |
92.33 | 96.44 | 90.52 | 90.46 | 92.94 â–² 9.4% |
Table: Scores on DynamoBench, XSTest, and on our internal benchmark to test the safety of prompts (P-Safety) and responses (R-Safety). We report binary classification accuracy.
LLM Safety Evaluation Hub
Please check out our LLM Safety Evaluation One-Stop Center: Walled Eval!
Model Citation
TO BE ADDED
Model Card Contact
- Downloads last month
- 80
2-bit
3-bit
4-bit
5-bit
6-bit
8-bit
Model tree for QuantFactory/walledguard-c-GGUF
Base model
walledai/walledguard-c
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="QuantFactory/walledguard-c-GGUF", filename="", )