Description
GPT-2 displays a broad set of capabilities, including the ability to generate conditional synthetic text samples of unprecedented quality, where the model is primed with an input and it generates a lengthy continuation. This is a distilled version which has fewer parameters and requires less computational resources to run.
Predicted Entities
How to use
documentAssembler = DocumentAssembler() \\
.setInputCol("text") \\
.setOutputCol("documents")
gpt2 = GPT2Transformer.pretrained("gpt2_distilled") \\
.setInputCols(["documents"]) \\
.setMaxOutputLength(50) \\
.setOutputCol("generation")
pipeline = Pipeline().setStages([documentAssembler, gpt2])
data = spark.createDataFrame([["My name is Leonardo."]]).toDF("text")
result = pipeline.fit(data).transform(data)
result.select("summaries.generation").show(truncate=False)
val documentAssembler = new DocumentAssembler()
.setInputCol("text")
.setOutputCol("documents")
val gpt2 = GPT2Transformer.pretrained("gpt2_distilled")
.setInputCols(Array("documents"))
.setMinOutputLength(10)
.setMaxOutputLength(50)
.setDoSample(false)
.setTopK(50)
.setNoRepeatNgramSize(3)
.setOutputCol("generation")
val pipeline = new Pipeline().setStages(Array(documentAssembler, gpt2))
val data = Seq("My name is Leonardo.").toDF("text")
val result = pipeline.fit(data).transform(data)
results.select("generation.result").show(truncate = false)
import nlu
nlu.load("en.gpt2.distilled").predict("""My name is Leonardo.""")
Model Information
Model Name: | gpt2_distilled |
Compatibility: | Spark NLP 3.4.0+ |
License: | Open Source |
Edition: | Official |
Input Labels: | [documents] |
Output Labels: | [generation] |
Language: | en |
Data Source
OpenAI WebText - a corpus created by scraping web pages with emphasis on document quality. It consists of over 8 million documents for a total of 40 GB of text. All Wikipedia documents were removed from WebText.