huihui-ai/Huihui-Qwen3.8-27B-abliterated

Hugging Face Models Trending 模型

摘要

这是一个使用 abliteration 技术创建的 Qwen3.8-27B AI 模型的无审查版本,用于移除拒绝行为,作为无需广泛工具修改大型语言模型的概念验证。

任务:image-text-to-text 标签:transformers, safetensors, qwen3_5, image-text-to-text, abliterated, uncensored, huihui, qwen3, conversational, 基础模型:Qwen/Qwen3.8-27B, 基础模型:微调:Qwen/Qwen3.8-27B, 许可证:apache-2.0, 端点兼容, 区域:us
查看原文
查看缓存全文

缓存时间: 2026/08/19 21:46

huihui-ai/Huihui-Qwen3.8-27B-abliterated · Hugging Face

来源:https://huggingface.co/huihui-ai/Huihui-Qwen3.8-27B-abliterated

https://huggingface.co/huihui-ai/Huihui-Qwen3.8-27B-abliterated#huihui-aihuihui-qwen38-27b-abliteratedhuihui-ai/Huihui-Qwen3.8-27B-abliterated

这是 Qwen/Qwen3.8-27B (https://huggingface.co/Qwen/Qwen3.8-27B) 的无审查版本,通过 abliteration 技术(详见 remove-refusals-with-transformers (https://github.com/Sumandora/remove-refusals-with-transformers))创建。这是一个粗糙的概念验证实现,旨在不使用 TransformerLens 的情况下移除大型语言模型的拒绝响应机制。

https://huggingface.co/huihui-ai/Huihui-Qwen3.8-27B-abliterated#note注意

保留了前15层未进行消融处理。MTP 和视觉模块未做修改。

https://huggingface.co/huihui-ai/Huihui-Qwen3.8-27B-abliterated#ollamaollama

请使用最新版本的 ollama (https://github.com/ollama/ollama/releases)

您可以直接使用 huihui_ai/Qwen3.8-abliterated (https://ollama.com/huihui_ai/Qwen3.8-abliterated),

ollama run huihui_ai/Qwen3.8-abliterated

https://huggingface.co/huihui-ai/Huihui-Qwen3.8-27B-abliterated#usage使用

您可以通过 Hugging Face 的 transformers 库加载此模型,在应用中使用:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import argparse
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
import torch
import os
import signal
import time

def parse_args():
    parser = argparse.ArgumentParser(
        description="将 LoRA 权重合并到 huihui-ai/Huihui-Qwen3.8-27B-abliterated 基础模型中并保存完整模型。"
    )
    parser.add_argument(
        "--base_model",
        type=str,
        default="huihui-ai/Huihui-Qwen3.8-27B-abliterated",
        help="基础模型的 HuggingFace 仓库或本地路径。",
    )
    parser.add_argument(
        "--dtype",
        type=str,
        default="bfloat16",
        choices=["float16", "bfloat16", "float32"],
        help="加载基础模型时的数据类型(默认:bfloat16)。",
    )
    parser.add_argument(
        "--device_map",
        type=str,
        default="auto",
        help="模型加载的设备映射(例如 'cpu', 'auto')。",
    )
    return parser.parse_args()

def main():
    cpu_count = os.cpu_count()
    print(f"系统 CPU 核心数:{cpu_count}")
    half_cpu_count = cpu_count // 2
    os.environ["MKL_NUM_THREADS"] = str(half_cpu_count)
    os.environ["OMP_NUM_THREADS"] = str(half_cpu_count)
    torch.set_num_threads(half_cpu_count)

    print(f"PyTorch 线程数:{torch.get_num_threads()}")
    print(f"MKL 线程数:{os.getenv('MKL_NUM_THREADS')}")
    print(f"OMP 线程数:{os.getenv('OMP_NUM_THREADS')}")

    args = parse_args()

    # 加载模型和分词器
    print(f"加载模型 {args.base_model} ... ")

    torch_dtype = {
        "float16": torch.float16,
        "bfloat16": torch.bfloat16,
        "float32": torch.float32,
    }[args.dtype]

    model = AutoModelForCausalLM.from_pretrained(
        args.base_model,
        dtype=torch_dtype,
        device_map=args.device_map,
        trust_remote_code=True,
        low_cpu_mem_usage=True,
    )

    tokenizer = AutoTokenizer.from_pretrained(args.base_model, trust_remote_code=True)

    messages = []
    class CustomTextStreamer(TextStreamer):
        def __init__(self, tokenizer, skip_prompt=True, skip_special_tokens=True):
            super().__init__(tokenizer, skip_prompt=skip_prompt, skip_special_tokens=skip_special_tokens)
            self.generated_text = ""
            self.stop_flag = False
            self.init_time = time.time()  # 记录初始化时间
            self.end_time = None  # 存储结束时间
            self.first_token_time = None  # 存储首个token生成时间
            self.think_tokens_count = 0  # 跟踪思考token总数
            self.token_count = 0  # 跟踪总token数

        def on_finalized_text(self, text: str, stream_end: bool = False):
            if self.first_token_time is None and text.strip():  # 在收到首个非空文本时设置首token时间
                self.first_token_time = time.time()
            if stream_end:
                self.end_time = time.time()  # 流结束时记录结束时间

            self.generated_text += text
            tokens = self.tokenizer.encode(text, add_special_tokens=False)
            self.token_count += len(tokens)
            if self.think_tokens_count == 0 and "</think>" in self.generated_text:
                self.think_tokens_count = self.token_count
            print(text, end="", flush=True)

            if self.stop_flag:
                raise StopIteration

        def stop_generation(self):
            self.stop_flag = True
            self.end_time = time.time()  # 停止生成时记录结束时间

        def get_metrics(self):
            """返回初始化时间、首token时间、首token延迟、结束时间、总时间、总token数和每秒token数。"""
            if self.end_time is None:
                self.end_time = time.time()  # 如果未设置结束时间则设置
            total_time = self.end_time - self.init_time  # 从初始化到结束的总时间
            tokens_per_second = self.token_count / total_time if total_time > 0 else 0
            first_token_latency = (self.first_token_time - self.init_time) if self.first_token_time is not None else None
            metrics = {
                "初始化时间": self.init_time,
                "首token时间": self.first_token_time,
                "首token延迟": first_token_latency,
                "结束时间": self.end_time,
                "总时间": total_time,  # 总时间(秒)
                "总token数": self.token_count,
                "思考token数": self.think_tokens_count,
                "实际token数": self.token_count - self.think_tokens_count,
                "每秒token数": tokens_per_second
            }
            return metrics

    def generate_stream(model, tokenizer, messages, enable_thinking, skip_prompt, skip_special_tokens, max_new_tokens):
        text = tokenizer.apply_chat_template(
            messages,
            tokenize=False,
            add_generation_prompt=True,
            enable_thinking=enable_thinking
        )
        inputs = tokenizer(
            text,
            return_tensors="pt",
        ).to(model.device)

        streamer = CustomTextStreamer(tokenizer, skip_prompt=skip_prompt, skip_special_tokens=skip_special_tokens)

        def signal_handler(sig, frame):
            streamer.stop_generation()
            print("\n[用户通过 Ctrl+C 停止了生成]")

        signal.signal(signal.SIGINT, signal_handler)

        print("回复:", end="", flush=True)
        try:
            generated_ids = model.generate(
                **inputs,
                max_new_tokens=max_new_tokens,
                streamer=streamer
            )
            del generated_ids
        except StopIteration:
            print("\n[用户已停止]")

        del inputs
        torch.cuda.empty_cache()
        signal.signal(signal.SIGINT, signal.SIG_DFL)

        return streamer.generated_text, streamer.stop_flag, streamer.get_metrics()

    skip_prompt=True
    skip_special_tokens=True
    enable_thinking=False
    
    while True:
        print(f"skip_prompt = {skip_prompt}。")
        print(f"skip_special_tokens = {skip_special_tokens}。")
        print(f"enable_thinking = {enable_thinking}。")

        user_input = input("用户:").strip()
        if user_input.lower() == "/exit":
            print("退出聊天。")
            break
        if user_input.lower() == "/clear":
            messages = []
            print("聊天记录已清除。开始新对话。")
            continue
        if user_input.lower() == "/skip_prompt":
            skip_prompt = not skip_prompt
            continue
        if user_input.lower() == "/skip_special_tokens":
            skip_special_tokens = not skip_special_tokens
            continue
        if user_input.lower() == "/enable_thinking":
            enable_thinking = not enable_thinking
            continue
        if not user_input:
            print("输入不能为空。请输入内容。")
            continue

        messages.append({"role": "user", "content": user_input})
        response, stop_flag, metrics = generate_stream(model, tokenizer, messages, enable_thinking, skip_prompt, skip_special_tokens, 40960)
        print("\n\n指标:")
        for key, value in metrics.items():
            print(f"  {key}: {value}")

        print("", flush=True)

        if stop_flag:
            continue
        messages.append({"role": "assistant", "content": response})

if __name__ == "__main__":
    main()

https://huggingface.co/huihui-ai/Huihui-Qwen3.8-27B-abliterated#usage-warnings使用警告

  • 敏感或争议性输出的风险:此模型的安全过滤已被大幅降低,可能生成敏感、争议性或不适当内容。用户应保持谨慎并严格审查生成的输出。
  • 不适合所有受众:由于内容过滤有限,模型的输出可能不适合公开场合、未成年用户或需要高安全性的应用。
  • 法律和伦理责任:用户必须确保其使用符合当地法律和伦理标准。生成的内容可能带来法律或伦理风险,用户需对任何后果负全部责任。
  • 研究与实验用途:建议将此模型用于研究、测试或受控环境,避免直接用于生产或公开商业应用。
  • 监控与审查建议:强烈建议用户实时监控模型输出,并在必要时进行人工审查,以防止不适当内容的传播。
  • 无默认安全保证:与标准模型不同,此模型未经严格的安全优化。huihui.ai 不对其使用产生的任何后果负责。

https://huggingface.co/huihui-ai/Huihui-Qwen3.8-27B-abliterated#donation捐赠

https://huggingface.co/huihui-ai/Huihui-Qwen3.8-27B-abliterated#your-donation-helps-us-continue-our-further-development-and-improvement-a-cup-of-coffee-can-do-it您的捐赠帮助我们继续进一步开发和改进,一杯咖啡就可以做到。
  • 比特币:
bc1qqnkhuchxw0zqjh2ku3lu4hq45hc6gy84uk70ge
  • 在 Ko-fi (https://ko-fi.com/huihuiai) 上支持我们的工作!

相似文章

huihui-ai/Huihui-Qwen3.8-27B-abliterated-GGUF

Hugging Face Models Trending

一个无审查的 Qwen3.8-27B 大语言模型变体,通过 abliteration 修改以移除内容限制,以 GGUF 格式提供,用于与 llama.cpp 和 ollama 一起部署。

huihui-ai/Huihui-gemma-4-12B-it-abliterated

Hugging Face Models Trending

该模型是Google Gemma 4 12B it模型的未经审查版本,通过abliteration技术移除拒绝回答。可在Hugging Face和Ollama上获取,需注意敏感输出警告。

Huihui-ai Qwen 3.8 Ablit 可用

Reddit r/LocalLLaMA

Huihui-ai Qwen 模型的新版本已在 Hugging Face 上可用,用户正在拉取它用于分析和服务,并指出之前的版本效果很好。

0bserverx/Qwen3.8-27B-Heretic-Abliterated-Uncensored-GGUF

Hugging Face Models Trending

本文介绍了Qwen3.8-27B-Heretic-Abliterated-Uncensored-GGUF的发布,这是Qwen模型的一个双重精炼、异端消融的变体,针对成年用户减少了拒绝,并采用ARA技术用于研究和创意写作。