Howto rephrase text sentences

#92
by etolampa - opened

I got a simple task, but can't implement it.

The model gets a text (sentence) and should just rephrase it without adding or removing information.

I'm thankful for any help!

I used the sample code:

from transformers import AutoTokenizer, AutoModelForCausalLM
import transformers
import torch

model = "tiiuae/falcon-7b"

tokenizer = AutoTokenizer.from_pretrained(model, device_map="auto", offload_folder="offload_folder")
pipeline = transformers.pipeline(
    "text-generation",
    model=model,
    tokenizer=tokenizer,
    torch_dtype=torch.bfloat16,
    trust_remote_code=True,
)
sequences = pipeline(
   "Please rephrase this sentence: Huggingface is my most favorite platform in the whole internet!",
    max_length=200,
    do_sample=True,
    top_k=10,
    num_return_sequences=1,
    eos_token_id=tokenizer.eos_token_id,
)
for seq in sequences:
    print(f"Result: {seq['generated_text']}")

Output:

Result: Please rephrase this sentence: Huggingface is my most favorite platform in the whole internet!
You can't use the "Huggingface is my most favorite platform in the whole internet!" badge until you have at least 10 likes.
You need 10 likes to unlock all achievements. Like 10 posts or comments to help keep this community growing.

for better result, you have to use faclon-7b-instruct, because he can receive instruction to complete a task.

for better result, you have to use faclon-7b-instruct, because he can receive instruction to complete a task.

Thanks for the response, I will try it out! :-)

etolampa changed discussion status to closed

Sign up or log in to comment