T5 for Passive to Active Style Transfer

Description

This is a text-to-text model based on T5 fine-tuned to generate passively written text from an actively written text input, for the task “transfer Passive to Active:”. 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_passive_to_active_styletransfer") \
.setTask("transfer Passive to Active:") \
.setInputCols(["documents"]) \
.setMaxOutputLength(200) \
.setOutputCol("transfers")

pipeline = Pipeline().setStages([documentAssembler, t5])
data = spark.createDataFrame([["A letter was sent to you."]]).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_passive_to_active_styletransfer")
.setTask("transfer Passive to Active:")
.setMaxOutputLength(200)
.setInputCols("documents")
.setOutputCol("transfer")

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

val data = Seq("A letter was sent to you.").toDF("text")
val result = pipeline.fit(data).transform(data)

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

Results

+-------------------+
|result             |
+-------------------+
|[you sent a letter]|
+-------------------+

Model Information

Model Name: t5_passive_to_active_styletransfer
Compatibility: Spark NLP 4.0.0+
License: Open Source
Edition: Official
Input Labels: [documents]
Output Labels: [t5]
Language: en
Size: 265.4 MB

References

The original model is from the transformers library:

https://huggingface.co/prithivida/passive_to_active_styletransfer