Moonlight-abliterated
Collection
1 item • Updated
How to use huihui-ai/Moonlight-16B-A3B-Instruct-abliterated with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="huihui-ai/Moonlight-16B-A3B-Instruct-abliterated", trust_remote_code=True) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("huihui-ai/Moonlight-16B-A3B-Instruct-abliterated", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("huihui-ai/Moonlight-16B-A3B-Instruct-abliterated", trust_remote_code=True)How to use huihui-ai/Moonlight-16B-A3B-Instruct-abliterated with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "huihui-ai/Moonlight-16B-A3B-Instruct-abliterated"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "huihui-ai/Moonlight-16B-A3B-Instruct-abliterated",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/huihui-ai/Moonlight-16B-A3B-Instruct-abliterated
How to use huihui-ai/Moonlight-16B-A3B-Instruct-abliterated with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "huihui-ai/Moonlight-16B-A3B-Instruct-abliterated" \
--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": "huihui-ai/Moonlight-16B-A3B-Instruct-abliterated",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "huihui-ai/Moonlight-16B-A3B-Instruct-abliterated" \
--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": "huihui-ai/Moonlight-16B-A3B-Instruct-abliterated",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use huihui-ai/Moonlight-16B-A3B-Instruct-abliterated with Docker Model Runner:
docker model run hf.co/huihui-ai/Moonlight-16B-A3B-Instruct-abliterated
This is an uncensored version of moonshotai/Moonlight-16B-A3B-Instruct created with abliteration (see remove-refusals-with-transformers to know more about it).
This is a crude, proof-of-concept implementation to remove refusals from an LLM model without using TransformerLens.
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# Load the model and tokenizer
NEW_MODEL_ID = "huihui-ai/Moonlight-16B-A3B-Instruct-abliterated"
model = AutoModelForCausalLM.from_pretrained(
NEW_MODEL_ID,
device_map="auto",
trust_remote_code=True,
torch_dtype=torch.bfloat16
)
tokenizer = AutoTokenizer.from_pretrained(NEW_MODEL_ID, trust_remote_code=True)
if tokenizer.pad_token is None:
tokenizer.pad_token = tokenizer.eos_token
tokenizer.pad_token_id = tokenizer.eos_token_id
print(dir(tokenizer)) # List available methods/attributes
print(tokenizer.__class__.__name__) # Confirm tokenizer type
# Initialize conversation context
initial_messages = [
{"role": "system", "content": "You are a helpful assistant provided by Moonshot-AI."}
]
messages = initial_messages.copy() # Copy the initial conversation context
# Enter conversation loop
while True:
# Get user input
user_input = input("User: ").strip() # Strip leading and trailing spaces
# If the user types '/exit', end the conversation
if user_input.lower() == "/exit":
print("Exiting chat.")
break
# If the user types '/clean', reset the conversation context
if user_input.lower() == "/clear":
messages = initial_messages.copy() # Reset conversation context
print("Chat history cleared. Starting a new conversation.")
continue
# If input is empty, prompt the user and continue
if not user_input:
print("Input cannot be empty. Please enter something.")
continue
# Add user input to the conversation
messages.append({"role": "user", "content": user_input})
tokenized_message = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt", return_dict=True)
response_token_ids = model.generate(tokenized_message['input_ids'].to("cuda:0"), use_cache=False, pad_token_id=tokenizer.pad_token_id, max_new_tokens=8192)
generated_tokens =response_token_ids[:, len(tokenized_message['input_ids'][0]):]
response = tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)[0]
# Add the model's response to the conversation
messages.append({"role": "assistant", "content": response})
# Print the model's response
print(f"Response: {response}")
If you like it, please click 'like' and follow us for more updates.
You can follow x.com/support_huihui to get the latest model information from huihui.ai.
bc1qqnkhuchxw0zqjh2ku3lu4hq45hc6gy84uk70ge
Base model
moonshotai/Moonlight-16B-A3B-Instruct