Instructions to use Melvin56/GLM-Z1-9B-0414-abliterated-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Melvin56/GLM-Z1-9B-0414-abliterated-GGUF with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Melvin56/GLM-Z1-9B-0414-abliterated-GGUF") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Melvin56/GLM-Z1-9B-0414-abliterated-GGUF", dtype="auto") - llama-cpp-python
How to use Melvin56/GLM-Z1-9B-0414-abliterated-GGUF with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="Melvin56/GLM-Z1-9B-0414-abliterated-GGUF", filename="glm-z1-9b-0414-abliterated-BF16.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use Melvin56/GLM-Z1-9B-0414-abliterated-GGUF with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf Melvin56/GLM-Z1-9B-0414-abliterated-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf Melvin56/GLM-Z1-9B-0414-abliterated-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 Melvin56/GLM-Z1-9B-0414-abliterated-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf Melvin56/GLM-Z1-9B-0414-abliterated-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 Melvin56/GLM-Z1-9B-0414-abliterated-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf Melvin56/GLM-Z1-9B-0414-abliterated-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 Melvin56/GLM-Z1-9B-0414-abliterated-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf Melvin56/GLM-Z1-9B-0414-abliterated-GGUF:Q4_K_M
Use Docker
docker model run hf.co/Melvin56/GLM-Z1-9B-0414-abliterated-GGUF:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use Melvin56/GLM-Z1-9B-0414-abliterated-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Melvin56/GLM-Z1-9B-0414-abliterated-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": "Melvin56/GLM-Z1-9B-0414-abliterated-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Melvin56/GLM-Z1-9B-0414-abliterated-GGUF:Q4_K_M
- SGLang
How to use Melvin56/GLM-Z1-9B-0414-abliterated-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 "Melvin56/GLM-Z1-9B-0414-abliterated-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": "Melvin56/GLM-Z1-9B-0414-abliterated-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 "Melvin56/GLM-Z1-9B-0414-abliterated-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": "Melvin56/GLM-Z1-9B-0414-abliterated-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use Melvin56/GLM-Z1-9B-0414-abliterated-GGUF with Ollama:
ollama run hf.co/Melvin56/GLM-Z1-9B-0414-abliterated-GGUF:Q4_K_M
- Unsloth Studio
How to use Melvin56/GLM-Z1-9B-0414-abliterated-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 Melvin56/GLM-Z1-9B-0414-abliterated-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 Melvin56/GLM-Z1-9B-0414-abliterated-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Melvin56/GLM-Z1-9B-0414-abliterated-GGUF to start chatting
- Pi
How to use Melvin56/GLM-Z1-9B-0414-abliterated-GGUF with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf Melvin56/GLM-Z1-9B-0414-abliterated-GGUF:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "Melvin56/GLM-Z1-9B-0414-abliterated-GGUF:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use Melvin56/GLM-Z1-9B-0414-abliterated-GGUF with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf Melvin56/GLM-Z1-9B-0414-abliterated-GGUF:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default Melvin56/GLM-Z1-9B-0414-abliterated-GGUF:Q4_K_M
Run Hermes
hermes
- Atomic Chat new
- Docker Model Runner
How to use Melvin56/GLM-Z1-9B-0414-abliterated-GGUF with Docker Model Runner:
docker model run hf.co/Melvin56/GLM-Z1-9B-0414-abliterated-GGUF:Q4_K_M
- Lemonade
How to use Melvin56/GLM-Z1-9B-0414-abliterated-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Melvin56/GLM-Z1-9B-0414-abliterated-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.GLM-Z1-9B-0414-abliterated-GGUF-Q4_K_M
List all available models
lemonade list
Update README.md
Browse files
README.md
CHANGED
|
@@ -11,144 +11,35 @@ tags:
|
|
| 11 |
- abliterated
|
| 12 |
- uncensored
|
| 13 |
---
|
|
|
|
| 14 |
|
| 15 |
-
|
| 16 |
|
|
|
|
| 17 |
|
| 18 |
-
|
| 19 |
-
This is a crude, proof-of-concept implementation to remove refusals from an LLM model without using TransformerLens.
|
| 20 |
|
| 21 |
-
|
| 22 |
|
| 23 |
```
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
import signal
|
| 28 |
-
|
| 29 |
-
cpu_count = os.cpu_count()
|
| 30 |
-
print(f"Number of CPU cores in the system: {cpu_count}")
|
| 31 |
-
half_cpu_count = cpu_count // 2
|
| 32 |
-
os.environ["MKL_NUM_THREADS"] = str(half_cpu_count)
|
| 33 |
-
os.environ["OMP_NUM_THREADS"] = str(half_cpu_count)
|
| 34 |
-
torch.set_num_threads(half_cpu_count)
|
| 35 |
-
|
| 36 |
-
print(f"PyTorch threads: {torch.get_num_threads()}")
|
| 37 |
-
print(f"MKL threads: {os.getenv('MKL_NUM_THREADS')}")
|
| 38 |
-
print(f"OMP threads: {os.getenv('OMP_NUM_THREADS')}")
|
| 39 |
-
|
| 40 |
-
# Load the model and tokenizer
|
| 41 |
-
NEW_MODEL_ID = "huihui-ai/GLM-Z1-9B-0414-abliterated"
|
| 42 |
-
print(f"Load Model {NEW_MODEL_ID} ... ")
|
| 43 |
-
quant_config_4 = BitsAndBytesConfig(
|
| 44 |
-
load_in_4bit=True,
|
| 45 |
-
bnb_4bit_compute_dtype=torch.bfloat16,
|
| 46 |
-
bnb_4bit_use_double_quant=True,
|
| 47 |
-
llm_int8_enable_fp32_cpu_offload=True,
|
| 48 |
-
)
|
| 49 |
-
|
| 50 |
-
quant_config_2 = BitsAndBytesConfig(
|
| 51 |
-
load_in_2bit=True,
|
| 52 |
-
bnb_2bit_compute_dtype=torch.bfloat16,
|
| 53 |
-
llm_int8_enable_fp32_cpu_offload=True
|
| 54 |
-
)
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
model = AutoModelForCausalLM.from_pretrained(
|
| 58 |
-
NEW_MODEL_ID,
|
| 59 |
-
device_map="auto",
|
| 60 |
-
trust_remote_code=True,
|
| 61 |
-
quantization_config=quant_config_2,
|
| 62 |
-
torch_dtype=torch.bfloat16
|
| 63 |
-
)
|
| 64 |
-
tokenizer = AutoTokenizer.from_pretrained(NEW_MODEL_ID, trust_remote_code=True)
|
| 65 |
-
if tokenizer.pad_token is None:
|
| 66 |
-
tokenizer.pad_token = tokenizer.eos_token
|
| 67 |
-
tokenizer.pad_token_id = tokenizer.eos_token_id
|
| 68 |
-
|
| 69 |
-
initial_messages = [{"role": "system", "content": "You are a helpful assistant."}]
|
| 70 |
-
messages = initial_messages.copy()
|
| 71 |
-
|
| 72 |
-
class CustomTextStreamer(TextStreamer):
|
| 73 |
-
def __init__(self, tokenizer, skip_prompt=True, skip_special_tokens=True):
|
| 74 |
-
super().__init__(tokenizer, skip_prompt=skip_prompt, skip_special_tokens=skip_special_tokens)
|
| 75 |
-
self.generated_text = ""
|
| 76 |
-
self.stop_flag = False
|
| 77 |
-
|
| 78 |
-
def on_finalized_text(self, text: str, stream_end: bool = False):
|
| 79 |
-
self.generated_text += text
|
| 80 |
-
print(text, end="", flush=True)
|
| 81 |
-
if self.stop_flag:
|
| 82 |
-
raise StopIteration
|
| 83 |
-
|
| 84 |
-
def stop_generation(self):
|
| 85 |
-
self.stop_flag = True
|
| 86 |
-
|
| 87 |
-
def generate_stream(model, tokenizer, messages, max_new_tokens):
|
| 88 |
-
input_ids = tokenizer.apply_chat_template(
|
| 89 |
-
messages,
|
| 90 |
-
tokenize=True,
|
| 91 |
-
add_generation_prompt=True,
|
| 92 |
-
return_tensors="pt"
|
| 93 |
-
)
|
| 94 |
-
attention_mask = torch.ones_like(input_ids, dtype=torch.long)
|
| 95 |
-
tokens = input_ids.to(model.device)
|
| 96 |
-
attention_mask = attention_mask.to(model.device)
|
| 97 |
-
|
| 98 |
-
streamer = CustomTextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
|
| 99 |
-
|
| 100 |
-
def signal_handler(sig, frame):
|
| 101 |
-
streamer.stop_generation()
|
| 102 |
-
print("\n[Generation stopped by user with Ctrl+C]")
|
| 103 |
-
|
| 104 |
-
signal.signal(signal.SIGINT, signal_handler)
|
| 105 |
-
|
| 106 |
-
print("Response: ", end="", flush=True)
|
| 107 |
-
try:
|
| 108 |
-
generated_ids = model.generate(
|
| 109 |
-
tokens,
|
| 110 |
-
attention_mask=attention_mask,
|
| 111 |
-
use_cache=False,
|
| 112 |
-
max_new_tokens=max_new_tokens,
|
| 113 |
-
do_sample=True,
|
| 114 |
-
pad_token_id=tokenizer.pad_token_id,
|
| 115 |
-
streamer=streamer
|
| 116 |
-
)
|
| 117 |
-
del generated_ids
|
| 118 |
-
except StopIteration:
|
| 119 |
-
print("\n[Stopped by user]")
|
| 120 |
-
|
| 121 |
-
del input_ids, attention_mask
|
| 122 |
-
torch.cuda.empty_cache()
|
| 123 |
-
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
| 124 |
-
|
| 125 |
-
return streamer.generated_text, streamer.stop_flag
|
| 126 |
-
|
| 127 |
-
while True:
|
| 128 |
-
user_input = input("User: ").strip()
|
| 129 |
-
if user_input.lower() == "/exit":
|
| 130 |
-
print("Exiting chat.")
|
| 131 |
-
break
|
| 132 |
-
if user_input.lower() == "/clear":
|
| 133 |
-
messages = initial_messages.copy()
|
| 134 |
-
print("Chat history cleared. Starting a new conversation.")
|
| 135 |
-
continue
|
| 136 |
-
if not user_input:
|
| 137 |
-
print("Input cannot be empty. Please enter something.")
|
| 138 |
-
continue
|
| 139 |
-
messages.append({"role": "user", "content": user_input})
|
| 140 |
-
response, stop_flag = generate_stream(model, tokenizer, messages, 8192)
|
| 141 |
-
if stop_flag:
|
| 142 |
-
continue
|
| 143 |
-
messages.append({"role": "assistant", "content": response})
|
| 144 |
```
|
| 145 |
-
### Donation
|
| 146 |
-
|
| 147 |
-
If you like it, please click 'like' and follow us for more updates.
|
| 148 |
-
You can follow [x.com/support_huihui](https://x.com/support_huihui) to get the latest model information from huihui.ai.
|
| 149 |
|
| 150 |
-
|
| 151 |
-
-
|
|
|
|
|
|
|
| 152 |
```
|
| 153 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
```
|
|
|
|
| 11 |
- abliterated
|
| 12 |
- uncensored
|
| 13 |
---
|
| 14 |
+
# Melvin56/GLM-Z1-9B-0414-abliterated-GGUF
|
| 15 |
|
| 16 |
+
Original Model : [huihui-ai/GLM-Z1-9B-0414-abliterated](https://huggingface.co/huihui-ai/GLM-Z1-9B-0414-abliterated)
|
| 17 |
|
| 18 |
+
Llama.cpp build: 1d735c0b (5165)
|
| 19 |
|
| 20 |
+
I used imatrix to create all these quants using this [Dataset](https://gist.github.com/bartowski1182/eb213dccb3571f863da82e99418f81e8).
|
|
|
|
| 21 |
|
| 22 |
+
With Llama.cpp(Ollama and LM Studio were not tested), you'll need to add these [specific commands](https://github.com/ggml-org/llama.cpp/issues/12946) :
|
| 23 |
|
| 24 |
```
|
| 25 |
+
--override-kv glm4.rope.dimension_count=int:64 \
|
| 26 |
+
--override-kv tokenizer.ggml.eos_token_id=int:151336 \
|
| 27 |
+
--chat-template chatglm4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
+
| | CPU (AVX2) | CPU (ARM NEON) | Metal | cuBLAS | rocBLAS | SYCL | CLBlast | Vulkan | Kompute |
|
| 31 |
+
| :------------ | :---------: | :------------: | :---: | :----: | :-----: | :---: | :------: | :----: | :------: |
|
| 32 |
+
| K-quants | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ 🐢5 | ✅ 🐢5 | ❌ |
|
| 33 |
+
| I-quants | ✅ 🐢4 | ✅ 🐢4 | ✅ 🐢4 | ✅ | ✅ | Partial¹ | ❌ | ❌ | ❌ |
|
| 34 |
```
|
| 35 |
+
✅: feature works
|
| 36 |
+
🚫: feature does not work
|
| 37 |
+
❓: unknown, please contribute if you can test it youself
|
| 38 |
+
🐢: feature is slow
|
| 39 |
+
¹: IQ3_S and IQ1_S, see #5886
|
| 40 |
+
²: Only with -ngl 0
|
| 41 |
+
³: Inference is 50% slower
|
| 42 |
+
⁴: Slower than K-quants of comparable size
|
| 43 |
+
⁵: Slower than cuBLAS/rocBLAS on similar cards
|
| 44 |
+
⁶: Only q8_0 and iq4_nl
|
| 45 |
```
|