Views
No views yet
1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_name = "PeterAM4/deepseek-paraphrase"
4tokenizer = AutoTokenizer.from_pretrained(model_name)
5model = AutoModelForCausalLM.from_pretrained(model_name)
6
7text = "Learn Once, Write Anywhere: We don't make assumptions about the rest of your technology stack, so you can develop new features in React without rewriting existing code."
8
9prompt = f"<|begin▁of▁sentence|><|User|>Paraphrase the following text while preserving its meaning but changing the wording and structure: {text}<|Assistant|><think>\nLet me analyze this text and find ways to rephrase it while keeping the same meaning.\nI need to use different vocabulary and structure.\n</think>\n\n"
10
11inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
12outputs = model.generate(
13 **inputs,
14 max_new_tokens=200,
15 temperature=0.7,
16 top_p=0.95,
17 do_sample=True
18)
19
20paraphrase = tokenizer.decode(outputs[0], skip_special_tokens=True).replace(prompt, "")
21print(paraphrase)@misc{deepseek-paraphrase,
author = {PeterAM4},
title = {DeepSeek Paraphrase: Fine-tuned DeepSeek model for high-quality paraphrasing},
year = {2025},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/PeterAM4/deepseek-paraphrase}}
}