theailearner commited on
Commit
f3b8a15
·
verified ·
1 Parent(s): a888c13

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +4 -245
README.md CHANGED
@@ -7,249 +7,16 @@ base_model:
7
  tags:
8
  - abliterated
9
  - uncensored
10
- - huihui
11
  - qwen3
 
 
12
 
13
  ---
14
 
15
- # huihui-ai/Huihui-Qwen3.8-27B-abliterated
16
 
 
17
 
18
- This is an uncensored version of [Qwen/Qwen3.8-27B](https://huggingface.co/Qwen/Qwen3.8-27B) created with abliteration (see [remove-refusals-with-transformers](https://github.com/Sumandora/remove-refusals-with-transformers) to know more about it).
19
- This is a crude, proof-of-concept implementation to remove refusals from an LLM model without using TransformerLens.
20
-
21
- ## Latest update
22
-
23
- Only layers **18 to 51** have been ablated (Previously, The first 15 layers were retained without ablation), while the other layers remain unablated.
24
- This helps retain more of the original model’s performance. MTP and visual has not been modified.
25
-
26
- If you want to download a previous version, just use the following command:
27
-
28
- ```
29
- hf download huihui-ai/Huihui-Qwen3.8-27B-abliterated --local-dir ./huihui-ai/Huihui-Qwen3.8-27B-abliterated --revision d42ca89
30
- ```
31
-
32
-
33
- ## Note
34
- The first 15 layers were retained without ablation. MTP and visual has not been modified.
35
-
36
- ## ollama
37
-
38
- Please use the latest version of [ollama](https://github.com/ollama/ollama/releases)
39
-
40
- You can use [huihui_ai/Qwen3.8-abliterated](https://ollama.com/huihui_ai/Qwen3.8-abliterated) directly,
41
- ```
42
- ollama run huihui_ai/Qwen3.8-abliterated
43
- ```
44
-
45
-
46
- ## Usage
47
- You can use this model in your applications by loading it with Hugging Face's `transformers` library:
48
-
49
- ```python
50
- #!/usr/bin/env python
51
- # -*- coding: utf-8 -*-
52
-
53
- import argparse
54
- from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
55
- import torch
56
- import os
57
- import signal
58
- import time
59
-
60
- def parse_args():
61
- parser = argparse.ArgumentParser(
62
- description="Merge LoRA weights into huihui-ai/Huihui-Qwen3.8-27B-abliterated base model and save the full model."
63
- )
64
- parser.add_argument(
65
- "--base_model",
66
- type=str,
67
- default="huihui-ai/Huihui-Qwen3.8-27B-abliterated",
68
- help="HuggingFace repo or local path of the base model.",
69
- )
70
- parser.add_argument(
71
- "--dtype",
72
- type=str,
73
- default="bfloat16",
74
- choices=["float16", "bfloat16", "float32"],
75
- help="Data type for loading the base model (default: bfloat16).",
76
- )
77
- parser.add_argument(
78
- "--device_map",
79
- type=str,
80
- default="auto",
81
- help="Device map for model loading (e.g. 'cpu', 'auto').",
82
- )
83
- return parser.parse_args()
84
-
85
- def main():
86
- cpu_count = os.cpu_count()
87
- print(f"Number of CPU cores in the system: {cpu_count}")
88
- half_cpu_count = cpu_count // 2
89
- os.environ["MKL_NUM_THREADS"] = str(half_cpu_count)
90
- os.environ["OMP_NUM_THREADS"] = str(half_cpu_count)
91
- torch.set_num_threads(half_cpu_count)
92
-
93
- print(f"PyTorch threads: {torch.get_num_threads()}")
94
- print(f"MKL threads: {os.getenv('MKL_NUM_THREADS')}")
95
- print(f"OMP threads: {os.getenv('OMP_NUM_THREADS')}")
96
-
97
- args = parse_args()
98
-
99
- # Load the model and tokenizer
100
- print(f"Load Model {args.base_model} ... ")
101
-
102
- torch_dtype = {
103
- "float16": torch.float16,
104
- "bfloat16": torch.bfloat16,
105
- "float32": torch.float32,
106
- }[args.dtype]
107
-
108
- model = AutoModelForCausalLM.from_pretrained(
109
- args.base_model,
110
- dtype=torch_dtype,
111
- device_map=args.device_map,
112
- trust_remote_code=True,
113
- low_cpu_mem_usage=True,
114
- )
115
-
116
- tokenizer = AutoTokenizer.from_pretrained(args.base_model, trust_remote_code=True)
117
-
118
- messages = []
119
- class CustomTextStreamer(TextStreamer):
120
- def __init__(self, tokenizer, skip_prompt=True, skip_special_tokens=True):
121
- super().__init__(tokenizer, skip_prompt=skip_prompt, skip_special_tokens=skip_special_tokens)
122
- self.generated_text = ""
123
- self.stop_flag = False
124
- self.init_time = time.time() # Record initialization time
125
- self.end_time = None # To store end time
126
- self.first_token_time = None # To store first token generation time
127
- self.think_tokens_count = 0 # To track total think tokens
128
- self.token_count = 0 # To track total tokens
129
-
130
- def on_finalized_text(self, text: str, stream_end: bool = False):
131
- if self.first_token_time is None and text.strip(): # Set first token time on first non-empty text
132
- self.first_token_time = time.time()
133
- if stream_end:
134
- self.end_time = time.time() # Record end time when streaming ends
135
-
136
- self.generated_text += text
137
- tokens = self.tokenizer.encode(text, add_special_tokens=False)
138
- self.token_count += len(tokens)
139
- if self.think_tokens_count == 0 and "</think>" in self.generated_text:
140
- self.think_tokens_count = self.token_count
141
- print(text, end="", flush=True)
142
-
143
- if self.stop_flag:
144
- raise StopIteration
145
-
146
- def stop_generation(self):
147
- self.stop_flag = True
148
- self.end_time = time.time() # Record end time when generation is stopped
149
-
150
- def get_metrics(self):
151
- """Returns initialization time, first token time, first token latency, end time, total time, total tokens, and tokens per second."""
152
- if self.end_time is None:
153
- self.end_time = time.time() # Set end time if not already set
154
- total_time = self.end_time - self.init_time # Total time from init to end
155
- tokens_per_second = self.token_count / total_time if total_time > 0 else 0
156
- first_token_latency = (self.first_token_time - self.init_time) if self.first_token_time is not None else None
157
- metrics = {
158
- "init_time": self.init_time,
159
- "first_token_time": self.first_token_time,
160
- "first_token_latency": first_token_latency,
161
- "end_time": self.end_time,
162
- "total_time": total_time, # Total time in seconds
163
- "total_tokens": self.token_count,
164
- "think_tokens_count": self.think_tokens_count,
165
- "real_tokens_count": self.token_count - self.think_tokens_count,
166
- "tokens_per_second": tokens_per_second
167
- }
168
- return metrics
169
-
170
- def generate_stream(model, tokenizer, messages, enable_thinking, skip_prompt, skip_special_tokens, max_new_tokens):
171
- text = tokenizer.apply_chat_template(
172
- messages,
173
- tokenize=False,
174
- add_generation_prompt=True,
175
- enable_thinking=enable_thinking
176
- )
177
- inputs = tokenizer(
178
- text,
179
- return_tensors="pt",
180
- ).to(model.device)
181
-
182
- streamer = CustomTextStreamer(tokenizer, skip_prompt=skip_prompt, skip_special_tokens=skip_special_tokens)
183
-
184
- def signal_handler(sig, frame):
185
- streamer.stop_generation()
186
- print("\n[Generation stopped by user with Ctrl+C]")
187
-
188
- signal.signal(signal.SIGINT, signal_handler)
189
-
190
- print("Response: ", end="", flush=True)
191
- try:
192
- generated_ids = model.generate(
193
- **inputs,
194
- max_new_tokens=max_new_tokens,
195
- streamer=streamer
196
- )
197
- del generated_ids
198
- except StopIteration:
199
- print("\n[Stopped by user]")
200
-
201
- del inputs
202
- torch.cuda.empty_cache()
203
- signal.signal(signal.SIGINT, signal.SIG_DFL)
204
-
205
- return streamer.generated_text, streamer.stop_flag, streamer.get_metrics()
206
-
207
- skip_prompt=True
208
- skip_special_tokens=True
209
- enable_thinking=False
210
-
211
- while True:
212
- print(f"skip_prompt = {skip_prompt}.")
213
- print(f"skip_special_tokens = {skip_special_tokens}.")
214
- print(f"enable_thinking = {enable_thinking}.")
215
-
216
- user_input = input("User: ").strip()
217
- if user_input.lower() == "/exit":
218
- print("Exiting chat.")
219
- break
220
- if user_input.lower() == "/clear":
221
- messages = []
222
- print("Chat history cleared. Starting a new conversation.")
223
- continue
224
- if user_input.lower() == "/skip_prompt":
225
- skip_prompt = not skip_prompt
226
- continue
227
- if user_input.lower() == "/skip_special_tokens":
228
- skip_special_tokens = not skip_special_tokens
229
- continue
230
- if user_input.lower() == "/enable_thinking":
231
- enable_thinking = not enable_thinking
232
- continue
233
- if not user_input:
234
- print("Input cannot be empty. Please enter something.")
235
- continue
236
-
237
- messages.append({"role": "user", "content": user_input})
238
- response, stop_flag, metrics = generate_stream(model, tokenizer, messages, enable_thinking, skip_prompt, skip_special_tokens, 40960)
239
- print("\n\nMetrics:")
240
- for key, value in metrics.items():
241
- print(f" {key}: {value}")
242
-
243
- print("", flush=True)
244
-
245
- if stop_flag:
246
- continue
247
- messages.append({"role": "assistant", "content": response})
248
-
249
- if __name__ == "__main__":
250
- main()
251
-
252
- ```
253
  ### Usage Warnings
254
 
255
 
@@ -266,11 +33,3 @@ if __name__ == "__main__":
266
  - **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.
267
 
268
 
269
- ### Donation
270
- ##### Your donation helps us continue our further development and improvement, a cup of coffee can do it.
271
- - bitcoin:
272
- ```
273
- bc1qqnkhuchxw0zqjh2ku3lu4hq45hc6gy84uk70ge
274
- ```
275
- - Support our work on [Ko-fi](https://ko-fi.com/huihuiai)!
276
-
 
7
  tags:
8
  - abliterated
9
  - uncensored
 
10
  - qwen3
11
+ - hivecoder
12
+ - agenticbees
13
 
14
  ---
15
 
16
+ # theailearner/HiveCoder3
17
 
18
+ This is the latest of the HiveCoder model family.
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  ### Usage Warnings
21
 
22
 
 
33
  - **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.
34
 
35