Views
No views yet
Qwen/Qwen2.5-3B-Instruct model. Its primary purpose is to "de-AI-ze" text—taking standard, often generic or robotic-sounding AI-generated text and rewriting it to match a more natural, personal writing style.transformers and peft libraries.1from transformers import AutoModelForCausalLM, AutoTokenizer
2from peft import PeftModel
3
4base_model_name = "Qwen/Qwen2.5-3B-Instruct"
5adapter_model_name = "Youmei295/deAize"
6
7# Load the base tokenizer and model
8tokenizer = AutoTokenizer.from_pretrained(base_model_name)
9base_model = AutoModelForCausalLM.from_pretrained(base_model_name, device_map="auto")
10
11# Load the LoRA adapter
12model = PeftModel.from_pretrained(base_model, adapter_model_name)
13
14# Generate text
15prompt = "Rewrite this text to match my natural writing style: The utilization of advanced methodologies can significantly enhance operational efficiency."
16messages = [
17 {"role": "system", "content": "You are a helpful assistant that rewrites text into a natural, personal writing style."},
18 {"role": "user", "content": prompt}
19]
20text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
21inputs = tokenizer(text, return_tensors="pt").to(model.device)
22
23outputs = model.generate(**inputs, max_new_tokens=256)
24print(tokenizer.decode(outputs[0], skip_special_tokens=True))q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj