Views
No views yet
google/flan-t5-base specialized in gender rewriting.
It can translate a sentence from a Male context to a Female context (and vice versa) while preserving the original meaning and structure.rewrite male to female: [sentence]rewrite female to male: [sentence]1from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
2
3tokenizer = AutoTokenizer.from_pretrained("IsGarrido/flan-t5-gender-rewriter")
4model = AutoModelForSeq2SeqLM.from_pretrained("IsGarrido/flan-t5-gender-rewriter")
5
6input_text = "rewrite male to female: He is a bachelor living in the city."
7input_ids = tokenizer(input_text, return_tensors="pt").input_ids
8
9outputs = model.generate(input_ids, max_new_tokens=128)
10print(tokenizer.decode(outputs[0], skip_special_tokens=True))
11# Output: "She is a bachelorette living in the city."