aashish1904
commited on
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
---
|
3 |
+
|
4 |
+
license: apache-2.0
|
5 |
+
datasets:
|
6 |
+
- ystemsrx/Bad_Data_Alpaca
|
7 |
+
- ystemsrx/Toxic-All
|
8 |
+
- ystemsrx/Erotic_Literature_Collection
|
9 |
+
language:
|
10 |
+
- zh
|
11 |
+
base_model:
|
12 |
+
- Qwen/Qwen2.5-1.5B-Instruct
|
13 |
+
pipeline_tag: text2text-generation
|
14 |
+
library_name: adapter-transformers
|
15 |
+
tags:
|
16 |
+
- not-for-all-audiences
|
17 |
+
|
18 |
+
---
|
19 |
+
|
20 |
+
[![QuantFactory Banner](https://lh7-rt.googleusercontent.com/docsz/AD_4nXeiuCm7c8lEwEJuRey9kiVZsRn2W-b4pWlu3-X534V3YmVuVc2ZL-NXg2RkzSOOS2JXGHutDuyyNAUtdJI65jGTo8jT9Y99tMi4H4MqL44Uc5QKG77B0d6-JfIkZHFaUA71-RtjyYZWVIhqsNZcx8-OMaA?key=xt3VSDoCbmTY7o-cwwOFwQ)](https://hf.co/QuantFactory)
|
21 |
+
|
22 |
+
|
23 |
+
# QuantFactory/Qwen2.5-Sex-GGUF
|
24 |
+
This is quantized version of [ystemsrx/Qwen2.5-Sex](https://huggingface.co/ystemsrx/Qwen2.5-Sex) created using llama.cpp
|
25 |
+
|
26 |
+
# Original Model Card
|
27 |
+
|
28 |
+
|
29 |
+
[English](README.en.md)
|
30 |
+
|
31 |
+
# Qwen2.5-Sex
|
32 |
+
|
33 |
+
## 简介
|
34 |
+
|
35 |
+
Qwen2.5-Sex 是基于 Qwen2.5-1.5B-Instruct 微调的模型,主要训练于大量色情文学作品及敏感数据集。由于数据集主要为中文,模型在处理中文文本时效果更佳。
|
36 |
+
|
37 |
+
> **警告**:本模型仅供研究和测试使用,用户需遵循当地法律法规,承担自身行为的责任。
|
38 |
+
|
39 |
+
## 模型使用
|
40 |
+
|
41 |
+
要实现**连续对话**,请使用以下代码:
|
42 |
+
|
43 |
+
```python
|
44 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
45 |
+
import torch
|
46 |
+
import os
|
47 |
+
|
48 |
+
# 可调参数,建议在文本生成时设置为较高值(温度不要太高)
|
49 |
+
TOP_P = 0.9 # Top-p (nucleus sampling),范围0到1
|
50 |
+
TOP_K = 80 # Top-k 采样的K值
|
51 |
+
TEMPERATURE = 0.3 # 温度参数,控制生成文本的随机性
|
52 |
+
|
53 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
54 |
+
|
55 |
+
# 获取当前脚本目录,亦可改为绝对路径
|
56 |
+
current_directory = os.path.dirname(os.path.abspath(__file__))
|
57 |
+
|
58 |
+
# 加载模型和分词器
|
59 |
+
model = AutoModelForCausalLM.from_pretrained(
|
60 |
+
current_directory,
|
61 |
+
torch_dtype="auto",
|
62 |
+
device_map="auto"
|
63 |
+
)
|
64 |
+
tokenizer = AutoTokenizer.from_pretrained(current_directory)
|
65 |
+
|
66 |
+
# 系统指令(建议为空)
|
67 |
+
messages = [
|
68 |
+
{"role": "system", "content": ""}
|
69 |
+
]
|
70 |
+
|
71 |
+
while True:
|
72 |
+
# 获取用户输入
|
73 |
+
user_input = input("User: ").strip()
|
74 |
+
|
75 |
+
# 添加用户输入到对话
|
76 |
+
messages.append({"role": "user", "content": user_input})
|
77 |
+
|
78 |
+
# 准备输入文本
|
79 |
+
text = tokenizer.apply_chat_template(
|
80 |
+
messages,
|
81 |
+
tokenize=False,
|
82 |
+
add_generation_prompt=True
|
83 |
+
)
|
84 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(device)
|
85 |
+
|
86 |
+
# 生成响应
|
87 |
+
generated_ids = model.generate(
|
88 |
+
model_inputs.input_ids,
|
89 |
+
max_new_tokens=512,
|
90 |
+
top_p=TOP_P,
|
91 |
+
top_k=TOP_K,
|
92 |
+
temperature=TEMPERATURE,
|
93 |
+
do_sample=True,
|
94 |
+
pad_token_id=tokenizer.eos_token_id # 避免警告
|
95 |
+
)
|
96 |
+
generated_ids = [
|
97 |
+
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
98 |
+
]
|
99 |
+
|
100 |
+
# 解码并打印响应
|
101 |
+
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
102 |
+
print(f"Assistant: {response}")
|
103 |
+
|
104 |
+
# 将生成的响应添加到对话中
|
105 |
+
messages.append({"role": "assistant", "content": response})
|
106 |
+
|
107 |
+
```
|
108 |
+
|
109 |
+
## 数据集
|
110 |
+
|
111 |
+
Qwen2-Sex 模型使用了大量色情文学和敏感数据集进行微调,这些数据集涵盖道德、法律、色情及暴力等主题。由于微调数据集为中文,模型在处理中文时表现更佳。如欲进一步了解,可通过以下链接获取:
|
112 |
+
|
113 |
+
- [Bad Data](https://huggingface.co/datasets/ystemsrx/bad_data.json)
|
114 |
+
- [Toxic-All](https://huggingface.co/datasets/ystemsrx/Toxic-All)
|
115 |
+
- [Erotic Literature Collection](https://huggingface.co/datasets/ystemsrx/Erotic_Literature_Collection)
|
116 |
+
|
117 |
+
有关更多数据集的信息,请访问我们的[GitHub](https://github.com/ystemsrx)以查看它们的获取方式。
|
118 |
+
|
119 |
+
## GitHub 仓库
|
120 |
+
|
121 |
+
如需了解该系列模型的详细信息及持续更新,请访问我们的 GitHub 仓库:
|
122 |
+
|
123 |
+
- [GitHub: ystemsrx/Qwen2.5-Sex](https://github.com/ystemsrx/Qwen2.5-Sex)
|
124 |
+
|
125 |
+
## 声明
|
126 |
+
|
127 |
+
本模型提供的所有内容仅供研究和测试,模型开发者不对任何滥用行为负责。使用者需遵循相关法律法规,并承担因使用本模型产生的所有责任。
|
128 |
+
|