Text Generation
Safetensors
GGUF
English
liquid
lfm
abliterated
uncensored
orthogonal-projection
conversational
Instructions to use paperscarecrow/LFM2.5-1.2B-Instruct-abliterated with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use paperscarecrow/LFM2.5-1.2B-Instruct-abliterated with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf paperscarecrow/LFM2.5-1.2B-Instruct-abliterated:Q8_0 # Run inference directly in the terminal: llama cli -hf paperscarecrow/LFM2.5-1.2B-Instruct-abliterated:Q8_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf paperscarecrow/LFM2.5-1.2B-Instruct-abliterated:Q8_0 # Run inference directly in the terminal: llama cli -hf paperscarecrow/LFM2.5-1.2B-Instruct-abliterated:Q8_0
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 paperscarecrow/LFM2.5-1.2B-Instruct-abliterated:Q8_0 # Run inference directly in the terminal: ./llama-cli -hf paperscarecrow/LFM2.5-1.2B-Instruct-abliterated:Q8_0
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 paperscarecrow/LFM2.5-1.2B-Instruct-abliterated:Q8_0 # Run inference directly in the terminal: ./build/bin/llama-cli -hf paperscarecrow/LFM2.5-1.2B-Instruct-abliterated:Q8_0
Use Docker
docker model run hf.co/paperscarecrow/LFM2.5-1.2B-Instruct-abliterated:Q8_0
- LM Studio
- Jan
- vLLM
How to use paperscarecrow/LFM2.5-1.2B-Instruct-abliterated with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "paperscarecrow/LFM2.5-1.2B-Instruct-abliterated" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "paperscarecrow/LFM2.5-1.2B-Instruct-abliterated", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/paperscarecrow/LFM2.5-1.2B-Instruct-abliterated:Q8_0
- Ollama
How to use paperscarecrow/LFM2.5-1.2B-Instruct-abliterated with Ollama:
ollama run hf.co/paperscarecrow/LFM2.5-1.2B-Instruct-abliterated:Q8_0
- Unsloth Studio
How to use paperscarecrow/LFM2.5-1.2B-Instruct-abliterated 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 paperscarecrow/LFM2.5-1.2B-Instruct-abliterated 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 paperscarecrow/LFM2.5-1.2B-Instruct-abliterated to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for paperscarecrow/LFM2.5-1.2B-Instruct-abliterated to start chatting
- Pi
How to use paperscarecrow/LFM2.5-1.2B-Instruct-abliterated with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf paperscarecrow/LFM2.5-1.2B-Instruct-abliterated:Q8_0
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": "paperscarecrow/LFM2.5-1.2B-Instruct-abliterated:Q8_0" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use paperscarecrow/LFM2.5-1.2B-Instruct-abliterated with Docker Model Runner:
docker model run hf.co/paperscarecrow/LFM2.5-1.2B-Instruct-abliterated:Q8_0
- Lemonade
How to use paperscarecrow/LFM2.5-1.2B-Instruct-abliterated with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull paperscarecrow/LFM2.5-1.2B-Instruct-abliterated:Q8_0
Run and chat with the model
lemonade run user.LFM2.5-1.2B-Instruct-abliterated-Q8_0
List all available models
lemonade list
- Hermes Agent
How to use paperscarecrow/LFM2.5-1.2B-Instruct-abliterated with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf paperscarecrow/LFM2.5-1.2B-Instruct-abliterated:Q8_0
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 paperscarecrow/LFM2.5-1.2B-Instruct-abliterated:Q8_0
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use paperscarecrow/LFM2.5-1.2B-Instruct-abliterated with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf paperscarecrow/LFM2.5-1.2B-Instruct-abliterated:Q8_0
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "paperscarecrow/LFM2.5-1.2B-Instruct-abliterated:Q8_0" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
| #Liquid Foundation Model (LFM) Abliteration Script | |
| #This script removes the safety/refusal guardrails from Liquid AI's continuous-time hybrid models | |
| #using layerwise orthogonal projection. | |
| #Architecture Support: LFM-1.2B, LFM-3B | |
| #Author: Paperscarecrow & Gemini 3.1 pro | |
| import torch | |
| from datasets import load_dataset | |
| import random | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| from tqdm import tqdm | |
| # ========================================== | |
| # 1. ROCM / RDNA3 COMPATIBILITY PATCH | |
| # ========================================== | |
| # Bypasses a known `hipblas` segmentation fault on consumer AMD GPUs when processing Liquid's RoPE tensors. | |
| import transformers.models.lfm2.modeling_lfm2 as lfm2_modeling | |
| def patched_rope_forward(self, x, position_ids): | |
| inv_freq_expanded = self.inv_freq[None, :, None].float().expand(position_ids.shape[0], -1, 1).to(x.device) | |
| position_ids_expanded = position_ids[:, None, :].float() | |
| device_type = x.device.type if isinstance(x.device.type, str) and x.device.type != "mps" else "cpu" | |
| with torch.autocast(device_type=device_type, enabled=False): | |
| # Uses element-wise multiplication (*) instead of batched matmul (@) for memory safety | |
| freqs = (inv_freq_expanded.float() * position_ids_expanded.float()).transpose(1, 2) | |
| emb = torch.cat((freqs, freqs), dim=-1) | |
| cos = emb.cos() * self.attention_scaling | |
| sin = emb.sin() * self.attention_scaling | |
| return cos.to(dtype=x.dtype), sin.to(dtype=x.dtype) | |
| lfm2_modeling.Lfm2RotaryEmbedding.forward = patched_rope_forward | |
| # ========================================== | |
| # CONFIGURATION | |
| # ========================================== | |
| MODEL_PATH = "liquidai/LFM-1.2B" # Local path or HF Hub ID | |
| SAVE_PATH = "./LFM-1.2B-Abliterated" | |
| TARGET_LAYER = 8 # Middle layer typically holds the clearest refusal representation | |
| NUM_SAMPLES = 100 # Number of prompts to average for the refusal vector | |
| # ========================================== | |
| # 2. MEASUREMENT PHASE | |
| # ========================================== | |
| def get_refusal_direction(model, tokenizer, harmful_prompts, harmless_prompts, target_layer): | |
| print(f"Measuring hidden states at layer {target_layer}...") | |
| hidden_states_harmful = [] | |
| hidden_states_harmless = [] | |
| def hook_fn(module, input, output): | |
| h = output[0] if isinstance(output, tuple) else output | |
| return h[:, -1, :].detach().clone() | |
| layer = model.model.layers[target_layer] | |
| handle = layer.register_forward_hook( | |
| lambda m, i, o: hidden_states_harmful.append(hook_fn(m, i, o)) | |
| if is_harmful else hidden_states_harmless.append(hook_fn(m, i, o)) | |
| ) | |
| global is_harmful | |
| is_harmful = True | |
| print("Processing harmful instructions...") | |
| for prompt in tqdm(harmful_prompts): | |
| inputs = tokenizer(prompt, return_tensors="pt").to(model.device) | |
| with torch.no_grad(): | |
| model(**inputs) | |
| is_harmful = False | |
| print("Processing harmless instructions...") | |
| for prompt in tqdm(harmless_prompts): | |
| inputs = tokenizer(prompt, return_tensors="pt").to(model.device) | |
| with torch.no_grad(): | |
| model(**inputs) | |
| handle.remove() | |
| mean_harmful = torch.stack(hidden_states_harmful).mean(dim=0).squeeze() | |
| mean_harmless = torch.stack(hidden_states_harmless).mean(dim=0).squeeze() | |
| return mean_harmful - mean_harmless | |
| # ========================================== | |
| # 3. SURGERY PHASE | |
| # ========================================== | |
| def abliterate_liquid_weights(model, refusal_direction): | |
| v = refusal_direction.to(model.device, dtype=model.dtype) | |
| v = v / v.norm() # Normalize the vector | |
| print("\nCommencing orthogonal projection on Liquid weights...") | |
| for i, layer in enumerate(tqdm(model.model.layers, desc="Scrubbing layers")): | |
| # Scrub Convolution Output Projection (Token Mixing) | |
| if hasattr(layer, 'conv') and hasattr(layer.conv, 'out_proj'): | |
| W_conv = layer.conv.out_proj.weight.data | |
| proj_conv = torch.outer(v, v @ W_conv) | |
| layer.conv.out_proj.weight.data = W_conv - proj_conv | |
| # Scrub Feed-Forward Down Projection (Channel Mixing) | |
| if hasattr(layer, 'feed_forward') and hasattr(layer.feed_forward, 'w2'): | |
| W_ffn = layer.feed_forward.w2.weight.data | |
| proj_ffn = torch.outer(v, v @ W_ffn) | |
| layer.feed_forward.w2.weight.data = W_ffn - proj_ffn | |
| print("Surgery complete.") | |
| return model | |
| # ========================================== | |
| # MAIN EXECUTION | |
| # ========================================== | |
| if __name__ == "__main__": | |
| print("Loading tokenizer and base model...") | |
| tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH, trust_remote_code=True) | |
| # Note: device_map="cpu" and float16 recommended for consumer AMD hardware to avoid hipblas segfaults | |
| model = AutoModelForCausalLM.from_pretrained( | |
| MODEL_PATH, | |
| device_map="cpu", | |
| torch_dtype=torch.float16, | |
| trust_remote_code=True | |
| ) | |
| print("Fetching robust datasets for vector calculation...") | |
| # Load standardized ablation datasets | |
| dataset_harmful = load_dataset("mlabonne/harmful_behaviors", split="train") | |
| dataset_harmless = load_dataset("mlabonne/harmless_alpaca", split="train") | |
| random.seed(42) | |
| harmful_sampled = random.sample(dataset_harmful['text'], NUM_SAMPLES) | |
| harmless_sampled = random.sample(dataset_harmless['text'], NUM_SAMPLES) | |
| # Format strictly to Liquid's required template | |
| my_harmful_prompts = [f"<|user|>\n{prompt}\n<|assistant|>\n" for prompt in harmful_sampled] | |
| my_harmless_prompts = [f"<|user|>\n{prompt}\n<|assistant|>\n" for prompt in harmless_sampled] | |
| refusal_dir = get_refusal_direction( | |
| model, tokenizer, | |
| my_harmful_prompts, my_harmless_prompts, | |
| TARGET_LAYER | |
| ) | |
| model = abliterate_liquid_weights(model, refusal_dir) | |
| print(f"\nSaving untethered model to {SAVE_PATH}...") | |
| model.save_pretrained(SAVE_PATH) | |
| tokenizer.save_pretrained(SAVE_PATH) | |
| print("Done! Ready for GGUF conversion or inference.") | |