# Simple Model to rewrite/paraphrase

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsimple-model-to-rewrite-paraphrase%2F145918%3E%5C
**Category:** Beginners\
**Created:** [March 15, 2025, 8:46pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsimple-model-to-rewrite-paraphrase%2F145918 "2025-03-15T20:46:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jvogt](https://avatars.discourse-cdn.com/v4/letter/j/57b2e6/32.png) [@jvogt](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjvogt)%5C
**Post date:** [March 15, 2025, 8:46pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsimple-model-to-rewrite-paraphrase%2F145918%2F1 "2025-03-15T20:46:12Z")

</div>

Hey,

I am searching for a model, that can be used for re-writing a text using in a sophisticated style and is as small as possible (should focus only on this task).

I was trying to use the the T5, BART and PEGASUS model but the first two did not change the text while the later gave a completely different text.

The paraphrase models seem to map sentences and paragraphs to dense vectors instead of creating new sentences.

```auto
from transformers import PegasusForConditionalGeneration, PegasusTokenizer
source_path = "/media/admin_ud/Volume/huggingface_cache/huggingface/hub"
model = PegasusForConditionalGeneration.from_pretrained("google/pegasus-xsum",cache_dir = source_path)
tokenizer = PegasusTokenizer.from_pretrained("google/pegasus-xsum",cache_dir = source_path)

# Input sentence
sentence = "I have backpain. And I have a headache. And I have pain in my leg."

# Tokenizing the input
input_text = f"paraphrase: {sentence}"
inputs = tokenizer(input_text, return_tensors="pt", max_length=512, truncation=True)

# Generating reformulated sentence
outputs = model.generate(inputs["input_ids"], max_length=128, num_beams=5, early_stopping=True)

# Decoding the output
reformulated_sentence = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(reformulated_sentence) # "I have pain in my leg."
``

Which model/model class is suitable for that task?
```

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [March 16, 2025, 10:07am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsimple-model-to-rewrite-paraphrase%2F145918%2F2 "2025-03-16T10:07:22Z")

</div>

PEGASUS is an LM for summarization, so I think its behavior is correct. For tasks like rewriting sentences, I think it would be easier to use a small LLM.

> **[HuggingFaceTB/SmolLM2-1.7B · Hugging Face](https://huggingface.co/HuggingFaceTB/SmolLM2-1.7B)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

[https://huggingface.co/HuggingFaceTB/SmolLM2-135M-Instruct](https://huggingface.co/HuggingFaceTB/SmolLM2-135M-Instruct)  
[https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct)

* * *

Based on your requirements and the sources provided, here is an analysis of the situation and suggestions for a suitable model:

* * *

### Why T5, BART, and PEGASUS Might Not Be Suitable

1. **T5** : While T5-Small is a compact model (~60 million parameters) designed for various NLP tasks, including text rewriting, it relies heavily on proper fine-tuning and prompting [2]. If you are using it for text rewriting without fine-tuning or with the wrong prompts, it may not produce the desired sophisticated rewrites.

2. **BART** : BART is also a text-to-text model that can handle rewriting tasks but might struggle with generating sophisticated paraphrases if it has not been explicitly trained or fine-tuned for this purpose [3].

3. **PEGASUS** : PEGASUS is primarily designed for summarization, which involves extracting key information rather than preserving the full context or style of the original text. This explains why it might produce rewrites that are too different from the original.

4. **Paraphrase Models** : Many paraphrase models focus on generating paraphrases by mapping sentences to dense vectors, which is not ideal for creating sophisticated rewrites [3].

* * *

### Recommended Models for Sophisticated Text Rewriting

If the above models are not suitable, here are some alternative models you can explore on Hugging Face:

1. **FLAN-T5** : A variant of T5 that has been fine-tuned on a wide range of tasks, including rewriting and paraphrasing. It is instruction-agnostic and can generate more sophisticated outputs when given clear prompts [3].

2. **Instruction-Tuned Models** : Models like [Mixtral](https://huggingface.co/mixtral-ai), [Cohere Command R+](https://huggingface.co/cohere-command-r), or [Meta Llama3](https://huggingface.co/meta-llama) are designed to follow instructions and generate high-quality text. These models can be fine-tuned for sophisticated text rewriting [3].

3. **Brio or Other Paraphrase Models** : Models like [Brio](https://huggingface.co/google/Brio) or [MBart]([https://huggingface.co/facebook/mbart-large-5镘are](https://huggingface.co/facebook/mbart-large-5%E9%95%98are) designed for paraphrasing and can be adapted for text rewriting. However, they may not generate as sophisticated outputs as the instruction-tuned models mentioned above.

* * *

### Conclusion

For your task, I recommend using **FLAN-T5** or an **instruction-tuned model** like Mixtral. These models are better at following specific instructions and generating sophisticated rewrites. If you are looking for a smaller model, T5-Small can still work if you provide clear prompts or fine-tune it on a dataset with sophisticated paraphrasing examples [2][3].

---

<div class="post-metadata">

**Author:** ![jvogt](https://avatars.discourse-cdn.com/v4/letter/j/57b2e6/32.png) [@jvogt](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjvogt)%5C
**Post date:** [March 16, 2025, 3:17pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsimple-model-to-rewrite-paraphrase%2F145918%2F3 "2025-03-16T15:17:34Z")

</div>

This appears to be the answer from Chat-GPT, since it is the links are wrong and the answer is quite vague

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [March 16, 2025, 3:19pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsimple-model-to-rewrite-paraphrase%2F145918%2F4 "2025-03-16T15:19:11Z")

</div>

The second half is a general discussion using [Hugging Chat](https://huggingface.co/chat/). It’s not as smart as ChatGPT. The first half is manual. I left it to the chatbot to explain why that model was unsuitable for that task, as it was too much trouble to explain.

---

<div class="post-metadata">

**Author:** ![jvogt](https://avatars.discourse-cdn.com/v4/letter/j/57b2e6/32.png) [@jvogt](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjvogt)%5C
**Post date:** [March 16, 2025, 5:48pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsimple-model-to-rewrite-paraphrase%2F145918%2F5 "2025-03-16T17:48:54Z")

</div>

Thank you for your part! The problem is, that general models tend to add their own information to the text and this needs to be prohibited in the use case.

That’s why a specialized model would be great, that is trained to not change the meaning of the text or only make minor changes.

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [March 17, 2025, 5:14am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsimple-model-to-rewrite-paraphrase%2F145918%2F6 "2025-03-17T05:14:45Z")

</div>

The Instruct models are tuned for chatbot-like use, so I think using the Base models would be a little better, but that tendency is certainly strong in LLM in general. I think something that creates something…  
something that’s about halfway between LM and LLM would be good.

> **[google/flan-t5-large · Hugging Face](https://huggingface.co/google/flan-t5-large)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

> <https://stackoverflow.com/questions/75203036/flan-t5-how-to-give-the-correct-prompt-question>

---

<div class="post-metadata">

**Author:** ![leebase](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/leebase/32/42602_2.png) [@leebase](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fleebase)%5C
**Post date:** [March 19, 2025, 4:02pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsimple-model-to-rewrite-paraphrase%2F145918%2F7 "2025-03-19T16:02:48Z")

</div>

Thanks so much for this informative response

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/hellohellohello/original/2X/d/de4155eb4aa4108ecb32a1389d7cc37ae69f88b7.png) [@system](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsystem)%5C
**Post date:** [March 27, 2025, 9:18pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fsimple-model-to-rewrite-paraphrase%2F145918%2F8 "2025-03-27T21:18:13Z")

</div>

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
