Text2Text Generation
Adapters
Safetensors
GGUF
Chinese
qwen2
Not-For-All-Audiences
ystemsrx commited on
Commit
e5f11e0
·
verified ·
1 Parent(s): 1545104

Update README.md

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