Triangle104 commited on
Commit
a2782b9
1 Parent(s): 19e8382

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +81 -0
README.md CHANGED
@@ -18,6 +18,87 @@ tags:
18
  This model was converted to GGUF format from [`huihui-ai/Qwen2.5-3B-Instruct-abliterated`](https://huggingface.co/huihui-ai/Qwen2.5-3B-Instruct-abliterated) using llama.cpp via the ggml.ai's [GGUF-my-repo](https://huggingface.co/spaces/ggml-org/gguf-my-repo) space.
19
  Refer to the [original model card](https://huggingface.co/huihui-ai/Qwen2.5-3B-Instruct-abliterated) for more details on the model.
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  ## Use with llama.cpp
22
  Install llama.cpp through brew (works on Mac and Linux)
23
 
 
18
  This model was converted to GGUF format from [`huihui-ai/Qwen2.5-3B-Instruct-abliterated`](https://huggingface.co/huihui-ai/Qwen2.5-3B-Instruct-abliterated) using llama.cpp via the ggml.ai's [GGUF-my-repo](https://huggingface.co/spaces/ggml-org/gguf-my-repo) space.
19
  Refer to the [original model card](https://huggingface.co/huihui-ai/Qwen2.5-3B-Instruct-abliterated) for more details on the model.
20
 
21
+ ---
22
+ Model details:
23
+ -
24
+ This is an uncensored version of Qwen2.5-3B-Instruct created with abliteration (see this article to know more about it).
25
+
26
+ Special thanks to @FailSpy for the original code and technique. Please follow him if you're interested in abliterated models.
27
+
28
+ Usage
29
+ -
30
+ You can use this model in your applications by loading it with Hugging Face's transformers library:
31
+
32
+ from transformers import AutoModelForCausalLM, AutoTokenizer
33
+
34
+ # Load the model and tokenizer
35
+ model_name = "huihui-ai/Qwen2.5-3B-Instruct-abliterated"
36
+ model = AutoModelForCausalLM.from_pretrained(
37
+ model_name,
38
+ torch_dtype="auto",
39
+ device_map="auto"
40
+ )
41
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
42
+
43
+ # Initialize conversation context
44
+ initial_messages = [
45
+ {"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."}
46
+ ]
47
+ messages = initial_messages.copy() # Copy the initial conversation context
48
+
49
+ # Enter conversation loop
50
+ while True:
51
+ # Get user input
52
+ user_input = input("User: ").strip() # Strip leading and trailing spaces
53
+
54
+ # If the user types '/exit', end the conversation
55
+ if user_input.lower() == "/exit":
56
+ print("Exiting chat.")
57
+ break
58
+
59
+ # If the user types '/clean', reset the conversation context
60
+ if user_input.lower() == "/clean":
61
+ messages = initial_messages.copy() # Reset conversation context
62
+ print("Chat history cleared. Starting a new conversation.")
63
+ continue
64
+
65
+ # If input is empty, prompt the user and continue
66
+ if not user_input:
67
+ print("Input cannot be empty. Please enter something.")
68
+ continue
69
+
70
+ # Add user input to the conversation
71
+ messages.append({"role": "user", "content": user_input})
72
+
73
+ # Build the chat template
74
+ text = tokenizer.apply_chat_template(
75
+ messages,
76
+ tokenize=False,
77
+ add_generation_prompt=True
78
+ )
79
+
80
+ # Tokenize input and prepare it for the model
81
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
82
+
83
+ # Generate a response from the model
84
+ generated_ids = model.generate(
85
+ **model_inputs,
86
+ max_new_tokens=8192
87
+ )
88
+
89
+ # Extract model output, removing special tokens
90
+ generated_ids = [
91
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
92
+ ]
93
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
94
+
95
+ # Add the model's response to the conversation
96
+ messages.append({"role": "assistant", "content": response})
97
+
98
+ # Print the model's response
99
+ print(f"Qwen: {response}")
100
+
101
+ ---
102
  ## Use with llama.cpp
103
  Install llama.cpp through brew (works on Mac and Linux)
104