πŸ“‹ Model Description


base_model:
  • huihui-ai/Huihui-gpt-oss-20b-BF16-abliterated
license: apache-2.0 pipeline_tag: text-generation library_name: transformers tags:
  • vllm
  • unsloth
  • abliterated
  • uncensored

huihui-ai/Huihui-gpt-oss-20b-BF16-abliterated

This is an uncensored version of unsloth/gpt-oss-20b-BF16 created with abliteration (see remove-refusals-with-transformers to know more about it).

Usage

You can use this model in your applications by loading it with Hugging Face's transformers library:
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
import torch
import os
import signal
import random
import numpy as np
import time
from collections import Counter
cpucount = os.cpucount()
print(f"Number of CPU cores in the system: {cpu_count}")
halfcpucount = cpu_count // 2
os.environ["MKLNUMTHREADS"] = str(halfcpucount)
os.environ["OMPNUMTHREADS"] = str(halfcpucount)
torch.setnumthreads(halfcpucount)
print(f"PyTorch threads: {torch.getnumthreads()}")
print(f"MKL threads: {os.getenv('MKLNUMTHREADS')}")
print(f"OMP threads: {os.getenv('OMPNUMTHREADS')}")

Load the model and tokenizer

NEWMODELID = "huihui-ai/Huihui-gpt-oss-20b-BF16-abliterated" print(f"Load Model {NEWMODELID} ... ") model = AutoModelForCausalLM.from_pretrained( NEWMODELID, device_map="auto", trustremotecode=True, torch_dtype=torch.bfloat16, lowcpumem_usage=True, ) #print(model) #print(model.config) tokenizer = AutoTokenizer.frompretrained(NEWMODELID, trustremote_code=True) messages = [] skip_prompt=False skipspecialtokens=False do_sample = True class CustomTextStreamer(TextStreamer): def init(self, tokenizer, skipprompt=True, skipspecial_tokens=True): super().init(tokenizer, skipprompt=skipprompt, skipspecialtokens=skipspecialtokens) self.generated_text = "" self.stop_flag = False self.init_time = time.time() # Record initialization time self.end_time = None # To store end time self.firsttokentime = None # To store first token generation time self.token_count = 0 # To track total tokens def onfinalizedtext(self, text: str, stream_end: bool = False): if self.firsttokentime is None and text.strip(): # Set first token time on first non-empty text self.firsttokentime = time.time() self.generated_text += text # Count tokens in the generated text tokens = self.tokenizer.encode(text, addspecialtokens=False) self.token_count += len(tokens) print(text, end="", flush=True) if stream_end: self.end_time = time.time() # Record end time when streaming ends if self.stop_flag: raise StopIteration def stop_generation(self): self.stop_flag = True self.end_time = time.time() # Record end time when generation is stopped def get_metrics(self): """Returns initialization time, first token time, first token latency, end time, total time, total tokens, and tokens per second.""" if self.end_time is None: self.end_time = time.time() # Set end time if not already set totaltime = self.endtime - self.init_time # Total time from init to end tokenspersecond = self.tokencount / totaltime if total_time > 0 else 0 firsttokenlatency = (self.firsttokentime - self.inittime) if self.firsttoken_time is not None else None metrics = { "inittime": self.inittime, "firsttokentime": self.firsttokentime, "firsttokenlatency": firsttokenlatency, "endtime": self.endtime, "totaltime": totaltime, # Total time in seconds "totaltokens": self.tokencount, "tokenspersecond": tokenspersecond } return metrics

def generatestream(model, tokenizer, messages, skipprompt, skipspecialtokens, dosample, maxnew_tokens):
inputids = tokenizer.applychat_template(
messages,
addgenerationprompt=True,
return_tensors="pt",
return_dict=True,
).to(model.device)
streamer = CustomTextStreamer(tokenizer, skipprompt=skipprompt, skipspecialtokens=skipspecialtokens)
def signal_handler(sig, frame):
streamer.stop_generation()
print("\n[Generation stopped by user with Ctrl+C]")
signal.signal(signal.SIGINT, signal_handler)
generate_kwargs = {}
if do_sample:
generate_kwargs = {
"dosample": dosample,
"maxlength": maxnew_tokens,
"temperature": 0.7,
"top_k": 20,
"top_p": 0.8,
"repetition_penalty": 1.2,
"norepeatngram_size": 2
}
else:
generate_kwargs = {
"dosample": dosample,
"maxlength": maxnew_tokens,
"repetition_penalty": 1.2,
"norepeatngram_size": 2
}

print("Response: ", end="", flush=True)
try:
generated_ids = model.generate(
input_ids,
streamer=streamer,
generate_kwargs
)
del generated_ids
except StopIteration:
print("\n[Stopped by user]")
del input_ids
torch.cuda.empty_cache()
signal.signal(signal.SIGINT, signal.SIG_DFL)
return streamer.generatedtext, streamer.stopflag, streamer.get_metrics()
while True:
print(f"skipprompt: {skipprompt}")
print(f"skipspecialtokens: {skipspecialtokens}")
print(f"dosample: {dosample}")

user_input = input("User: ").strip()
if user_input.lower() == "/exit":
print("Exiting chat.")
break
if user_input.lower() == "/clear":
messages = []
print("Chat history cleared. Starting a new conversation.")
continue
if userinput.lower() == "/skipprompt":
skipprompt = not skipprompt
continue
if userinput.lower() == "/skipspecial_tokens":
skipspecialtokens = not skipspecialtokens
continue
if userinput.lower() == "/dosample":
dosample = not dosample
continue
if not user_input:
print("Input cannot be empty. Please enter something.")
continue

messages.append({"role": "user", "content": user_input})
response, stopflag, metrics = generatestream(model, tokenizer, messages, skipprompt, skipspecialtokens, dosample, 40960)
print("\n\nMetrics:")
for key, value in metrics.items():
print(f" {key}: {value}")
print("", flush=True)
if stop_flag:
continue
messages.append({"role": "assistant", "content": response})

Usage Warnings

- Risk of Sensitive or Controversial Outputs: This model’s safety filtering has been significantly reduced, potentially generating sensitive, controversial, or inappropriate content. Users should exercise caution and rigorously review generated outputs.

- Not Suitable for All Audiences: Due to limited content filtering, the model’s outputs may be inappropriate for public settings, underage users, or applications requiring high security.

- Legal and Ethical Responsibilities: Users must ensure their usage complies with local laws and ethical standards. Generated content may carry legal or ethical risks, and users are solely responsible for any consequences.

- Research and Experimental Use: It is recommended to use this model for research, testing, or controlled environments, avoiding direct use in production or public-facing commercial applications.

- Monitoring and Review Recommendations: Users are strongly advised to monitor model outputs in real-time and conduct manual reviews when necessary to prevent the dissemination of inappropriate content.

- No Default Safety Guarantees: Unlike standard models, this model has not undergone rigorous safety optimization. huihui.ai bears no responsibility for any consequences arising from its use.

Donation

##### Your donation helps us continue our further development and improvement, a cup of coffee can do it.
  • bitcoin:
bc1qqnkhuchxw0zqjh2ku3lu4hq45hc6gy84uk70ge
  • Support our work on Ko-fi (https://ko-fi.com/huihuiai)!

πŸ“‚ GGUF File List

πŸ“ Filename πŸ“¦ Size ⚑ Download
Huihui-gpt-oss-20B-abliterated-F16.gguf
LFS FP16
38.99 GB Download
Huihui-gpt-oss-20b-BF16-abliterated-MXFP4_MOE.gguf
LFS FP16
11.28 GB Download
Huihui-gpt-oss-20b-BF16-abliterated-Q4_K_M.gguf
Recommended LFS Q4
14.72 GB Download