T5 for Active to Passive Style Transfer

Description

This is a text-to-text model based on T5 fine-tuned to generate actively written text from a passively written text input, for the task “transfer Active to Passive:”. It is based on Prithiviraj Damodaran’s Styleformer.

Predicted Entities

Live Demo Open in Colab Download Copy S3 URI

How to use

import sparknlp
from sparknlp.base import *
from sparknlp.annotator import *

spark = sparknlp.start()

documentAssembler = DocumentAssembler() \
.setInputCol("text") \
.setOutputCol("documents")

t5 = T5Transformer.pretrained("t5_active_to_passive_styletransfer") \
.setTask("transfer Active to Passive:") \
.setInputCols(["documents"]) \
.setMaxOutputLength(200) \
.setOutputCol("transfers")

pipeline = Pipeline().setStages([documentAssembler, t5])
data = spark.createDataFrame([["I am writing you a letter."]]).toDF("text")
result = pipeline.fit(data).transform(data)
result.select("transfers.result").show(truncate=False)
import spark.implicits._
import com.johnsnowlabs.nlp.base.DocumentAssembler
import com.johnsnowlabs.nlp.annotators.seq2seq.T5Transformer
import org.apache.spark.ml.Pipeline

val documentAssembler = new DocumentAssembler()
.setInputCol("text")
.setOutputCol("documents")

val t5 = T5Transformer.pretrained("t5_active_to_passive_styletransfer")
.setTask("transfer Active to Passive:")
.setMaxOutputLength(200)
.setInputCols("documents")
.setOutputCol("transfer")

val pipeline = new Pipeline().setStages(Array(documentAssembler, t5))

val data = Seq("I am writing you a letter.").toDF("text")
val result = pipeline.fit(data).transform(data)

result.select("transfer.result").show(false)
import nlu
nlu.load("en.t5.active_to_passive_styletransfer").predict("""transfer Active to Passive:""")

Results

+---------------------------+
|result                     |
+---------------------------+
|[a letter is written by me]|
+---------------------------+

Model Information

Model Name: t5_active_to_passive_styletransfer
Compatibility: Spark NLP 3.4.0+
License: Open Source
Edition: Official
Input Labels: [documents]
Output Labels: [transfers]
Language: en
Size: 264.5 MB

Data Source

The original model is from the transformers library:

https://huggingface.co/prithivida/active_to_passive_styletransfer