Description
This is a text-to-text model based on T5 fine-tuned to generate informal text from formal text input, for the task “transfer Formal to Casual:”. 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_formal_to_informal_styletransfer") \
.setTask("transfer Formal to Casual:") \
.setInputCols(["documents"]) \
.setMaxOutputLength(200) \
.setOutputCol("transfers")
pipeline = Pipeline().setStages([documentAssembler, t5])
data = spark.createDataFrame([["Please leave the room now."]]).toDF("text")
result = pipeline.fit(data).transform(data)
result.select("transfers.result").show(truncate=False)
import spark.implicits._
import com.johnsnowlabs.nlp.base._
import com.johnsnowlabs.nlp.annotator._
import org.apache.spark.ml.Pipeline
val documentAssembler = new DocumentAssembler()
.setInputCol("text")
.setOutputCol("documents")
val t5 = T5Transformer.pretrained("t5_formal_to_informal_styletransfer")
.setTask("transfer Formal to Casual:")
.setMaxOutputLength(200)
.setInputCols("documents")
.setOutputCol("transfers")
val pipeline = new Pipeline().setStages(Array(documentAssembler, t5))
val data = Seq("Please leave the room now.")
.toDF("text")
val result = pipeline.fit(data).transform(data)
result.select("transfers.result").show(false)
import nlu
nlu.load("en.t5.formal_to_informal_styletransfer").predict("""transfer Formal to Casual:""")
Results
+---------------------+
|result |
+---------------------+
|[leave the room now.]|
+---------------------+
Model Information
Model Name: | t5_formal_to_informal_styletransfer |
Compatibility: | Spark NLP 4.0.0+ |
License: | Open Source |
Edition: | Official |
Input Labels: | [documents] |
Output Labels: | [t5] |
Language: | en |
Size: | 924.0 MB |
References
The original model is from the transformers library:
https://huggingface.co/prithivida/formal_to_informal_styletransfer