Triangle104 commited on
Commit
a9138bd
1 Parent(s): ffc298b

Update README.md

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