Packages

class PretrainedZeroShotNERChunker extends PretrainedZeroShotNER

A fine-tuned zero-shot named-entity recognition (NER) model. Performs NER on arbitrary text without task-specific labeled training.

In contrast to PretrainedZeroShotNER this annotator directly outputs NER chunks instead of aligning them to provided tokens.

Example

val text = """
        |Cristiano Ronaldo dos Santos Aveiro (Portuguese pronunciation: [kɾiʃˈtjɐnu ʁɔˈnaldu]; born 5 February
        |1985) is a Portuguese professional footballer who plays as a forward for and captains both Saudi Pro
        |League club Al Nassr and the Portugal national team. Widely regarded as one of the greatest players of
        |all time, Ronaldo has won five Ballon d'Or awards,[note 3] a record three UEFA Men's Player of the Year
        |Awards, and four European Golden Shoes, the most by a European player.
        """.stripMargin

val testData = Seq(text).toDF("text")
val documentAssembler = new DocumentAssembler()
  .setInputCol("text")
  .setOutputCol("document")
val sentenceDetector = new SentenceDetector()
  .setInputCols(Array("document"))
  .setOutputCol("sentence")
val ner = PretrainedZeroShotNERChunker
  .pretrained()
  .setInputCols(Array("sentence"))
  .setOutputCol("ner_chunk")
  .setLabels(Array("person", "award", "date", "competitions", "teams"))
val pipeline =
  new Pipeline().setStages(Array(documentAssembler, sentenceDetector, ner))
val results = pipeline.fit(testData).transform(testData)
results.selectExpr("explode(entity)").show(1000, truncate = false)

Results:

+--------------------------------------------------------------------------------------------------------------------------------------------------+
|col                                                                                                                                               |
+--------------------------------------------------------------------------------------------------------------------------------------------------+
|{chunk, 2, 37, Cristiano Ronaldo dos Santos Aveiro, {sentence -> 0, entity -> person, confidence -> 0.9144007, ner_source -> ner_chunk}, []}      |
|{chunk, 93, 109, 5 February\r\n1985, {sentence -> 1, entity -> date, confidence -> 0.99999976, ner_source -> ner_chunk}, []}                      |
|{chunk, 196, 213, Saudi Pro\r\nLeague, {sentence -> 1, entity -> competitions, confidence -> 0.9926515, ner_source -> ner_chunk}, []}             |
|{chunk, 219, 227, Al Nassr, {sentence -> 1, entity -> teams, confidence -> 0.99384415, ner_source -> ner_chunk}, []}                              |
|{chunk, 321, 328, Ronaldo, {sentence -> 2, entity -> person, confidence -> 0.999997, ner_source -> ner_chunk}, []}                                |
|{chunk, 342, 353, Ballon d'Or, {sentence -> 2, entity -> award, confidence -> 0.95896983, ner_source -> ner_chunk}, []}                           |
|{chunk, 385, 422, UEFA Men's Player of the Year\r\nAwards, {sentence -> 2, entity -> award, confidence -> 0.9687164, ner_source -> ner_chunk}, []}|
|{chunk, 433, 454, European Golden Shoes, {sentence -> 2, entity -> award, confidence -> 0.999326, ner_source -> ner_chunk}, []}                   |
+--------------------------------------------------------------------------------------------------------------------------------------------------+
See also

PretrainedZeroShotNER

Linear Supertypes
PretrainedZeroShotNER, CheckLicense, HasEngine, WriteOpenvinoModel, WriteSentencePieceModel, InternalWriteOnnxModel, HasBatchedAnnotate[PretrainedZeroShotNER], AnnotatorModel[PretrainedZeroShotNER], CanBeLazy, RawAnnotator[PretrainedZeroShotNER], HasOutputAnnotationCol, HasInputAnnotationCols, HasOutputAnnotatorType, ParamsAndFeaturesWritable, HasFeatures, DefaultParamsWritable, MLWritable, Model[PretrainedZeroShotNER], Transformer, PipelineStage, Logging, Params, Serializable, Serializable, Identifiable, AnyRef, Any
Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. PretrainedZeroShotNERChunker
  2. PretrainedZeroShotNER
  3. CheckLicense
  4. HasEngine
  5. WriteOpenvinoModel
  6. WriteSentencePieceModel
  7. InternalWriteOnnxModel
  8. HasBatchedAnnotate
  9. AnnotatorModel
  10. CanBeLazy
  11. RawAnnotator
  12. HasOutputAnnotationCol
  13. HasInputAnnotationCols
  14. HasOutputAnnotatorType
  15. ParamsAndFeaturesWritable
  16. HasFeatures
  17. DefaultParamsWritable
  18. MLWritable
  19. Model
  20. Transformer
  21. PipelineStage
  22. Logging
  23. Params
  24. Serializable
  25. Serializable
  26. Identifiable
  27. AnyRef
  28. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new PretrainedZeroShotNERChunker()
  2. new PretrainedZeroShotNERChunker(uid: String)

    uid

    required uid for storing annotator to disk

Type Members

  1. type AnnotationContent = Seq[Row]
    Attributes
    protected
    Definition Classes
    AnnotatorModel
  2. type AnnotatorType = String
    Definition Classes
    HasOutputAnnotatorType

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def $[T](param: Param[T]): T
    Attributes
    protected
    Definition Classes
    Params
  4. def $$[T](feature: StructFeature[T]): T
    Attributes
    protected
    Definition Classes
    HasFeatures
  5. def $$[K, V](feature: MapFeature[K, V]): Map[K, V]
    Attributes
    protected
    Definition Classes
    HasFeatures
  6. def $$[T](feature: SetFeature[T]): Set[T]
    Attributes
    protected
    Definition Classes
    HasFeatures
  7. def $$[T](feature: ArrayFeature[T]): Array[T]
    Attributes
    protected
    Definition Classes
    HasFeatures
  8. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  9. def _transform(dataset: Dataset[_], recursivePipeline: Option[PipelineModel]): DataFrame
    Attributes
    protected
    Definition Classes
    AnnotatorModel
  10. def afterAnnotate(dataset: DataFrame): DataFrame
    Attributes
    protected
    Definition Classes
    AnnotatorModel
  11. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  12. def batchAnnotate(batchedAnnotations: Seq[Array[Annotation]]): Seq[Seq[Annotation]]
    Definition Classes
    PretrainedZeroShotNERChunkerPretrainedZeroShotNER → HasBatchedAnnotate
  13. def batchProcess(rows: Iterator[_]): Iterator[Row]
    Definition Classes
    HasBatchedAnnotate
  14. val batchSize: IntParam
    Definition Classes
    HasBatchedAnnotate
  15. def beforeAnnotate(dataset: Dataset[_]): Dataset[_]
    Attributes
    protected
    Definition Classes
    AnnotatorModel
  16. final def checkSchema(schema: StructType, inputAnnotatorType: String): Boolean
    Attributes
    protected
    Definition Classes
    HasInputAnnotationCols
  17. def checkValidEnvironment(spark: Option[SparkSession], scopes: Seq[String], metadata: Option[Map[String, Value]]): Unit
    Definition Classes
    CheckLicense
  18. def checkValidScope(scope: String): Unit
    Definition Classes
    CheckLicense
  19. def checkValidScopeAndEnvironment(scope: String, spark: Option[SparkSession], checkLp: Boolean, metadata: Option[Map[String, Value]]): Unit
    Definition Classes
    CheckLicense
  20. def checkValidScopesAndEnvironment(scopes: Seq[String], spark: Option[SparkSession], checkLp: Boolean, metadata: Option[Map[String, Value]]): Unit
    Definition Classes
    CheckLicense
  21. final def clear(param: Param[_]): PretrainedZeroShotNERChunker.this.type
    Definition Classes
    Params
  22. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  23. def copy(extra: ParamMap): PretrainedZeroShotNER
    Definition Classes
    RawAnnotator → Model → Transformer → PipelineStage → Params
  24. def copyValues[T <: Params](to: T, extra: ParamMap): T
    Attributes
    protected
    Definition Classes
    Params
  25. final def defaultCopy[T <: Params](extra: ParamMap): T
    Attributes
    protected
    Definition Classes
    Params
  26. val engine: Param[String]
    Definition Classes
    HasEngine
  27. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  28. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  29. def explainParam(param: Param[_]): String
    Definition Classes
    Params
  30. def explainParams(): String
    Definition Classes
    Params
  31. final val extraInputCols: StringArrayParam
    Attributes
    protected
    Definition Classes
    HasInputAnnotationCols
  32. def extraValidate(structType: StructType): Boolean
    Attributes
    protected
    Definition Classes
    RawAnnotator
  33. def extraValidateMsg: String
    Attributes
    protected
    Definition Classes
    RawAnnotator
  34. final def extractParamMap(): ParamMap
    Definition Classes
    Params
  35. final def extractParamMap(extra: ParamMap): ParamMap
    Definition Classes
    Params
  36. val features: ArrayBuffer[Feature[_, _, _]]
    Definition Classes
    HasFeatures
  37. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  38. def get[T](feature: StructFeature[T]): Option[T]
    Attributes
    protected
    Definition Classes
    HasFeatures
  39. def get[K, V](feature: MapFeature[K, V]): Option[Map[K, V]]
    Attributes
    protected
    Definition Classes
    HasFeatures
  40. def get[T](feature: SetFeature[T]): Option[Set[T]]
    Attributes
    protected
    Definition Classes
    HasFeatures
  41. def get[T](feature: ArrayFeature[T]): Option[Array[T]]
    Attributes
    protected
    Definition Classes
    HasFeatures
  42. final def get[T](param: Param[T]): Option[T]
    Definition Classes
    Params
  43. def getBatchSize: Int
    Definition Classes
    HasBatchedAnnotate
  44. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  45. final def getDefault[T](param: Param[T]): Option[T]
    Definition Classes
    Params
  46. def getEngine: String
    Definition Classes
    HasEngine
  47. def getInputCols: Array[String]
    Definition Classes
    HasInputAnnotationCols
  48. def getLabels: Array[String]
    Definition Classes
    PretrainedZeroShotNER
  49. def getLazyAnnotator: Boolean
    Definition Classes
    CanBeLazy
  50. def getModelIfNotSet: GlinerModel
    Definition Classes
    PretrainedZeroShotNER
  51. final def getOrDefault[T](param: Param[T]): T
    Definition Classes
    Params
  52. final def getOutputCol: String
    Definition Classes
    HasOutputAnnotationCol
  53. def getParam(paramName: String): Param[Any]
    Definition Classes
    Params
  54. def getPredictionThreshold: Float
    Definition Classes
    PretrainedZeroShotNER
  55. final def hasDefault[T](param: Param[T]): Boolean
    Definition Classes
    Params
  56. def hasParam(paramName: String): Boolean
    Definition Classes
    Params
  57. def hasParent: Boolean
    Definition Classes
    Model
  58. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  59. def initializeLogIfNecessary(isInterpreter: Boolean, silent: Boolean): Boolean
    Attributes
    protected
    Definition Classes
    Logging
  60. def initializeLogIfNecessary(isInterpreter: Boolean): Unit
    Attributes
    protected
    Definition Classes
    Logging
  61. val inputAnnotatorTypes: Array[String]

    Input Annotator Types: DOCUMENT

    Input Annotator Types: DOCUMENT

    Definition Classes
    PretrainedZeroShotNERChunkerPretrainedZeroShotNER → HasInputAnnotationCols
  62. final val inputCols: StringArrayParam
    Attributes
    protected
    Definition Classes
    HasInputAnnotationCols
  63. final def isDefined(param: Param[_]): Boolean
    Definition Classes
    Params
  64. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  65. final def isSet(param: Param[_]): Boolean
    Definition Classes
    Params
  66. def isTokenInEntity(token: Annotation, sentence: Int, begin: Int, end: Int): Boolean
    Definition Classes
    PretrainedZeroShotNER
  67. def isTraceEnabled(): Boolean
    Attributes
    protected
    Definition Classes
    Logging
  68. var labels: StringArrayParam

    List of entity labels

    List of entity labels

    Definition Classes
    PretrainedZeroShotNER
  69. val lazyAnnotator: BooleanParam
    Definition Classes
    CanBeLazy
  70. def log: Logger
    Attributes
    protected
    Definition Classes
    Logging
  71. def logDebug(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  72. def logDebug(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  73. def logError(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  74. def logError(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  75. def logInfo(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  76. def logInfo(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  77. def logName: String
    Attributes
    protected
    Definition Classes
    Logging
  78. def logTrace(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  79. def logTrace(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  80. def logWarning(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  81. def logWarning(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  82. def msgHelper(schema: StructType): String
    Attributes
    protected
    Definition Classes
    HasInputAnnotationCols
  83. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  84. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  85. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  86. def onWrite(path: String, spark: SparkSession): Unit
    Definition Classes
    PretrainedZeroShotNER → ParamsAndFeaturesWritable
  87. val optionalInputAnnotatorTypes: Array[String]
    Definition Classes
    HasInputAnnotationCols
  88. val outputAnnotatorType: String

    Output Annotator Types: chunk

    Output Annotator Types: chunk

    Definition Classes
    PretrainedZeroShotNERChunkerPretrainedZeroShotNER → HasOutputAnnotatorType
  89. final val outputCol: Param[String]
    Attributes
    protected
    Definition Classes
    HasOutputAnnotationCol
  90. lazy val params: Array[Param[_]]
    Definition Classes
    Params
  91. var parent: Estimator[PretrainedZeroShotNER]
    Definition Classes
    Model
  92. var predictionThreshold: FloatParam

    Entity recognition threshold

    Entity recognition threshold

    Definition Classes
    PretrainedZeroShotNER
  93. def save(path: String): Unit
    Definition Classes
    MLWritable
    Annotations
    @Since( "1.6.0" ) @throws( ... )
  94. def set[T](feature: StructFeature[T], value: T): PretrainedZeroShotNERChunker.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  95. def set[K, V](feature: MapFeature[K, V], value: Map[K, V]): PretrainedZeroShotNERChunker.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  96. def set[T](feature: SetFeature[T], value: Set[T]): PretrainedZeroShotNERChunker.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  97. def set[T](feature: ArrayFeature[T], value: Array[T]): PretrainedZeroShotNERChunker.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  98. final def set(paramPair: ParamPair[_]): PretrainedZeroShotNERChunker.this.type
    Attributes
    protected
    Definition Classes
    Params
  99. final def set(param: String, value: Any): PretrainedZeroShotNERChunker.this.type
    Attributes
    protected
    Definition Classes
    Params
  100. final def set[T](param: Param[T], value: T): PretrainedZeroShotNERChunker.this.type
    Definition Classes
    Params
  101. def setBatchSize(size: Int): PretrainedZeroShotNERChunker.this.type
    Definition Classes
    HasBatchedAnnotate
  102. def setDefault[T](feature: StructFeature[T], value: () ⇒ T): PretrainedZeroShotNERChunker.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  103. def setDefault[K, V](feature: MapFeature[K, V], value: () ⇒ Map[K, V]): PretrainedZeroShotNERChunker.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  104. def setDefault[T](feature: SetFeature[T], value: () ⇒ Set[T]): PretrainedZeroShotNERChunker.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  105. def setDefault[T](feature: ArrayFeature[T], value: () ⇒ Array[T]): PretrainedZeroShotNERChunker.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  106. final def setDefault(paramPairs: ParamPair[_]*): PretrainedZeroShotNERChunker.this.type
    Attributes
    protected
    Definition Classes
    Params
  107. final def setDefault[T](param: Param[T], value: T): PretrainedZeroShotNERChunker.this.type
    Attributes
    protected[org.apache.spark.ml]
    Definition Classes
    Params
  108. def setExtraInputCols(value: Array[String]): PretrainedZeroShotNERChunker.this.type
    Definition Classes
    HasInputAnnotationCols
  109. final def setInputCols(value: String*): PretrainedZeroShotNERChunker.this.type
    Definition Classes
    HasInputAnnotationCols
  110. def setInputCols(value: Array[String]): PretrainedZeroShotNERChunker.this.type
    Definition Classes
    HasInputAnnotationCols
  111. def setLabels(labels: Array[String]): PretrainedZeroShotNERChunker.this.type
    Definition Classes
    PretrainedZeroShotNER
  112. def setLazyAnnotator(value: Boolean): PretrainedZeroShotNERChunker.this.type
    Definition Classes
    CanBeLazy
  113. def setModelIfNotSet(spark: SparkSession, openvinoWrapper: OpenvinoWrapper, spp: SentencePieceWrapper, glinerConfig: Option[GlinerConfig]): PretrainedZeroShotNER
    Definition Classes
    PretrainedZeroShotNER
  114. def setModelIfNotSet(spark: SparkSession, onnxWrapper: InternalOnnxWrapper, spp: SentencePieceWrapper, glinerConfig: Option[GlinerConfig] = None): PretrainedZeroShotNER
    Definition Classes
    PretrainedZeroShotNER
  115. final def setOutputCol(value: String): PretrainedZeroShotNERChunker.this.type
    Definition Classes
    HasOutputAnnotationCol
  116. def setParent(parent: Estimator[PretrainedZeroShotNER]): PretrainedZeroShotNER
    Definition Classes
    Model
  117. def setPredictionThreshold(value: Float): PretrainedZeroShotNERChunker.this.type
    Definition Classes
    PretrainedZeroShotNER
  118. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  119. def toString(): String
    Definition Classes
    Identifiable → AnyRef → Any
  120. final def transform(dataset: Dataset[_]): DataFrame
    Definition Classes
    AnnotatorModel → Transformer
  121. def transform(dataset: Dataset[_], paramMap: ParamMap): DataFrame
    Definition Classes
    Transformer
    Annotations
    @Since( "2.0.0" )
  122. def transform(dataset: Dataset[_], firstParamPair: ParamPair[_], otherParamPairs: ParamPair[_]*): DataFrame
    Definition Classes
    Transformer
    Annotations
    @Since( "2.0.0" ) @varargs()
  123. final def transformSchema(schema: StructType): StructType
    Definition Classes
    RawAnnotator → PipelineStage
  124. def transformSchema(schema: StructType, logging: Boolean): StructType
    Attributes
    protected
    Definition Classes
    PipelineStage
    Annotations
    @DeveloperApi()
  125. val uid: String
    Definition Classes
    PretrainedZeroShotNERChunkerPretrainedZeroShotNER → Identifiable
  126. def validate(schema: StructType): Boolean
    Attributes
    protected
    Definition Classes
    RawAnnotator
  127. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  128. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  129. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  130. def wrapColumnMetadata(col: Column): Column
    Attributes
    protected
    Definition Classes
    RawAnnotator
  131. def write: MLWriter
    Definition Classes
    ParamsAndFeaturesWritable → DefaultParamsWritable → MLWritable
  132. def writeOnnxModel(path: String, spark: SparkSession, onnxWrapper: InternalOnnxWrapper, suffix: String, fileName: String, encrypt: Boolean): Unit
    Definition Classes
    InternalWriteOnnxModel
  133. def writeOnnxModel(path: String, spark: SparkSession, onnxWrapper: InternalOnnxWrapper, suffix: String, fileName: String): Unit
    Definition Classes
    InternalWriteOnnxModel
  134. def writeOnnxModels(path: String, spark: SparkSession, onnxWrappersWithNames: Seq[(InternalOnnxWrapper, String)], suffix: String, encrypt: Boolean = false): Unit
    Definition Classes
    InternalWriteOnnxModel
  135. def writeOnnxModels(path: String, spark: SparkSession, onnxWrappersWithNames: Seq[(InternalOnnxWrapper, String)], suffix: String): Unit
    Definition Classes
    InternalWriteOnnxModel
  136. def writeOpenvinoModel(path: String, spark: SparkSession, openvinoWrapper: OpenvinoWrapper, suffix: String, fileName: String): Unit
    Definition Classes
    WriteOpenvinoModel
  137. def writeOpenvinoModels(path: String, spark: SparkSession, ovWrappersWithNames: Seq[(OpenvinoWrapper, String)], suffix: String): Unit
    Definition Classes
    WriteOpenvinoModel
  138. def writeSentencePieceModel(path: String, spark: SparkSession, spp: SentencePieceWrapper, suffix: String, filename: String): Unit
    Definition Classes
    WriteSentencePieceModel

Inherited from PretrainedZeroShotNER

Inherited from CheckLicense

Inherited from HasEngine

Inherited from WriteOpenvinoModel

Inherited from WriteSentencePieceModel

Inherited from InternalWriteOnnxModel

Inherited from HasBatchedAnnotate[PretrainedZeroShotNER]

Inherited from AnnotatorModel[PretrainedZeroShotNER]

Inherited from CanBeLazy

Inherited from RawAnnotator[PretrainedZeroShotNER]

Inherited from HasOutputAnnotationCol

Inherited from HasInputAnnotationCols

Inherited from HasOutputAnnotatorType

Inherited from ParamsAndFeaturesWritable

Inherited from HasFeatures

Inherited from DefaultParamsWritable

Inherited from MLWritable

Inherited from Model[PretrainedZeroShotNER]

Inherited from Transformer

Inherited from PipelineStage

Inherited from Logging

Inherited from Params

Inherited from Serializable

Inherited from Serializable

Inherited from Identifiable

Inherited from AnyRef

Inherited from Any

Parameters

A list of (hyper-)parameter keys this annotator can take. Users can set and get the parameter values through setters and getters, respectively.

Annotator types

Required input and expected output annotator types

Members