Packages

class DocumentTranslator extends Transformer with HasOutputAnnotatorType with HasOutputAnnotationCol with HasEngine with HasLlamaCppModelProperties with HasLlamaCppInferenceProperties with HasProtectedParams with CompletionPostProcessing

DocumentTranslator reads documents from any supported file type and translates them with a llama.cpp GGUF large-language-model – all in a single Pipeline stage.

  1. A Reader2Doc stage reads files from contentPath (or from a DataFrame column set via inputCol) and converts them to Spark NLP DOCUMENT annotations. Every file format that Reader2Doc supports is accepted: PDF, Word (.doc/.docx), ODT, Excel (.xls/.xlsx), PowerPoint (.ppt/.pptx), HTML, plain-text, RTF, Markdown, XML, CSV, and email (.eml/.msg).
  2. A SentenceDetectorSaTModel splits each document into sentences. Setting minSentenceLength / maxSentenceLength (characters) makes the SaT model emit length-bounded segments directly, so DocumentTranslator never has to pack/merge chunks.
  3. The GGUF model translates the sentences. Each sentence is embedded into promptTemplate (with srcLang / tgtLang) and completed with the same multiComplete batch logic used by AutoGGUFModel. Every sentence from every collected document is flattened into one batch and translated with up to batchSize sentences decoding concurrently (llama.cpp parallel slots), keeping the model fully utilised regardless of how the sentences are distributed across documents.
  4. The translated sentences are regrouped per document and merged back into one DOCUMENT annotation.

All llama.cpp model / inference parameters are inherited from HasLlamaCppModelProperties and HasLlamaCppInferenceProperties – the same parameters exposed by AutoGGUFModel – so e.g. setNCtx, setNPredict, setTemperature, setTopK, setReasoningBudget, setSystemPrompt are available directly.

Pretrained models can be loaded with pretrained of the companion object:

val translator = DocumentTranslator.pretrained()
  .setContentPath("src/test/resources/reader/html/")
  .setContentType("text/html")
  .setSrcLang("English")
  .setTgtLang("French")
  .setMaxSentenceLength(600)
  .setOutputCol("translation")

The default model is "qwen3_4b_q8_0_gguf", default language is "en", if no values are provided.

For available pretrained models please see the Models Hub.

Note: Translation is computationally expensive; a GPU is recommended. With parallel decoding the total context nCtx (in tokens) is split across the batchSize slots, so the per-sentence budget is nCtx / batchSize and must cover the prompt plus the generated translation. Size it as nCtx >= batchSize * (promptTokens + nPredict); raise setNCtx when raising setBatchSize, setMaxSentenceLength or setNPredict.

Linear Supertypes
CompletionPostProcessing, HasProtectedParams, HasLlamaCppInferenceProperties, HasLlamaCppModelProperties, HasEngine, ParamsAndFeaturesWritable, HasFeatures, DefaultParamsWritable, MLWritable, HasOutputAnnotationCol, HasOutputAnnotatorType, Transformer, PipelineStage, Logging, Params, Serializable, Serializable, Identifiable, AnyRef, Any
Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. DocumentTranslator
  2. CompletionPostProcessing
  3. HasProtectedParams
  4. HasLlamaCppInferenceProperties
  5. HasLlamaCppModelProperties
  6. HasEngine
  7. ParamsAndFeaturesWritable
  8. HasFeatures
  9. DefaultParamsWritable
  10. MLWritable
  11. HasOutputAnnotationCol
  12. HasOutputAnnotatorType
  13. Transformer
  14. PipelineStage
  15. Logging
  16. Params
  17. Serializable
  18. Serializable
  19. Identifiable
  20. AnyRef
  21. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

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

    uid

    required uid for storing annotator to disk

Type Members

  1. implicit class ProtectedParam[T] extends Param[T]
    Definition Classes
    HasProtectedParams
  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. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  10. val batchSize: IntParam

    Number of sentences translated concurrently (Default: 4).

    Number of sentences translated concurrently (Default: 4). This is the llama.cpp parallel-decoding slot count (n_parallel): sentences from all documents are flattened into one batch and up to batchSize of them decode at once. The total context nCtx is split across these slots, so nCtx / batchSize must cover one sentence's prompt plus nPredict.

  11. val cachePrompt: BooleanParam

  12. val chatTemplate: Param[String]

    Definition Classes
    HasLlamaCppModelProperties
  13. final def clear(param: Param[_]): DocumentTranslator.this.type
    Definition Classes
    Params
  14. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  15. def close(): Unit

    Closes the llama.cpp model backend, freeing resources.

    Closes the llama.cpp model backend, freeing resources. Reloaded on next use.

  16. val contentPath: Param[String]
  17. val contentType: Param[String]
  18. def copy(extra: ParamMap): Transformer
    Definition Classes
    DocumentTranslator → Transformer → PipelineStage → Params
  19. def copyValues[T <: Params](to: T, extra: ParamMap): T
    Attributes
    protected
    Definition Classes
    Params
  20. final def defaultCopy[T <: Params](extra: ParamMap): T
    Attributes
    protected
    Definition Classes
    Params
  21. val defragmentationThreshold: FloatParam

    Definition Classes
    HasLlamaCppModelProperties
  22. val disableLog: BooleanParam

    Definition Classes
    HasLlamaCppModelProperties
  23. val disableTokenIds: IntArrayParam

  24. val dynamicTemperatureExponent: FloatParam

  25. val dynamicTemperatureRange: FloatParam

  26. val engine: Param[String]

    This param is set internally once via loadSavedModel.

    This param is set internally once via loadSavedModel. That's why there is no setter

    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 def extractParamMap(): ParamMap
    Definition Classes
    Params
  32. final def extractParamMap(extra: ParamMap): ParamMap
    Definition Classes
    Params
  33. val features: ArrayBuffer[Feature[_, _, _]]
    Definition Classes
    HasFeatures
  34. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  35. val flashAttention: BooleanParam

    Definition Classes
    HasLlamaCppModelProperties
  36. val frequencyPenalty: FloatParam

  37. def get[T](feature: StructFeature[T]): Option[T]
    Attributes
    protected
    Definition Classes
    HasFeatures
  38. def get[K, V](feature: MapFeature[K, V]): Option[Map[K, V]]
    Attributes
    protected
    Definition Classes
    HasFeatures
  39. def get[T](feature: SetFeature[T]): Option[Set[T]]
    Attributes
    protected
    Definition Classes
    HasFeatures
  40. def get[T](feature: ArrayFeature[T]): Option[Array[T]]
    Attributes
    protected
    Definition Classes
    HasFeatures
  41. final def get[T](param: Param[T]): Option[T]
    Definition Classes
    Params
  42. def getBatchSize: Int

  43. def getCachePrompt: Boolean

  44. def getChatTemplate: String

    Definition Classes
    HasLlamaCppModelProperties
  45. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  46. def getContentPath: String

  47. def getContentType: String

  48. final def getDefault[T](param: Param[T]): Option[T]
    Definition Classes
    Params
  49. def getDefragmentationThreshold: Float

    Definition Classes
    HasLlamaCppModelProperties
  50. def getDisableLog: Boolean

    Definition Classes
    HasLlamaCppModelProperties
  51. def getDisableTokenIds: Array[Int]

  52. def getDynamicTemperatureExponent: Float

  53. def getDynamicTemperatureRange: Float

  54. def getEngine: String

    Definition Classes
    HasEngine
  55. def getFlashAttention: Boolean

    Definition Classes
    HasLlamaCppModelProperties
  56. def getFrequencyPenalty: Float

  57. def getGrammar: String

  58. def getIgnoreEos: Boolean

  59. def getInferenceParameters: InferenceParameters
    Attributes
    protected
    Definition Classes
    HasLlamaCppInferenceProperties
  60. def getInputCol: String

  61. def getInputPrefix: String

  62. def getInputSuffix: String

  63. def getJoinString: String

  64. def getLogVerbosity: Int
    Definition Classes
    HasLlamaCppModelProperties
  65. def getMainGpu: Int

    Definition Classes
    HasLlamaCppModelProperties
  66. def getMaxSentenceLength: Int

  67. def getMetadata: String

    Get the metadata for the model

    Get the metadata for the model

    Definition Classes
    HasLlamaCppModelProperties
  68. def getMetadataMap: Map[String, Map[String, String]]
    Definition Classes
    HasLlamaCppModelProperties
  69. def getMinKeep: Int

  70. def getMinP: Float

  71. def getMinSentenceLength: Int

  72. def getMiroStat: String

  73. def getMiroStatEta: Float

  74. def getMiroStatTau: Float

  75. def getModelDraft: String

    Definition Classes
    HasLlamaCppModelProperties
  76. def getModelIfNotSet: GGUFWrapper

  77. def getModelParameters: ModelParameters
    Attributes
    protected
    Definition Classes
    HasLlamaCppModelProperties
  78. def getNBatch: Int

    Definition Classes
    HasLlamaCppModelProperties
  79. def getNCtx: Int

    Definition Classes
    HasLlamaCppModelProperties
  80. def getNDraft: Int

    Definition Classes
    HasLlamaCppModelProperties
  81. def getNGpuLayers: Int

    Definition Classes
    HasLlamaCppModelProperties
  82. def getNGpuLayersDraft: Int

    Definition Classes
    HasLlamaCppModelProperties
  83. def getNKeep: Int

  84. def getNPredict: Int
  85. def getNProbs: Int

  86. def getNThreads: Int

    Definition Classes
    HasLlamaCppModelProperties
  87. def getNThreadsBatch: Int

    Definition Classes
    HasLlamaCppModelProperties
  88. def getNUbatch: Int

    Definition Classes
    HasLlamaCppModelProperties
  89. def getNoKvOffload: Boolean

    Definition Classes
    HasLlamaCppModelProperties
  90. def getNuma: String

    Definition Classes
    HasLlamaCppModelProperties
  91. final def getOrDefault[T](param: Param[T]): T
    Definition Classes
    Params
  92. def getOutputAsDocument: Boolean

  93. final def getOutputCol: String

    Gets annotation column name going to generate

    Gets annotation column name going to generate

    Definition Classes
    HasOutputAnnotationCol
  94. def getParam(paramName: String): Param[Any]
    Definition Classes
    Params
  95. def getPenalizeNl: Boolean

  96. def getPenaltyPrompt: String

  97. def getPresencePenalty: Float

  98. def getPromptTemplate: String

  99. def getReasoningBudget: Int

    Definition Classes
    HasLlamaCppModelProperties
  100. def getRemoveThinkingTag: Option[String]

    Definition Classes
    CompletionPostProcessing
  101. def getRepeatLastN: Int

  102. def getRepeatPenalty: Float

  103. def getRopeFreqBase: Float

    Definition Classes
    HasLlamaCppModelProperties
  104. def getRopeFreqScale: Float

    Definition Classes
    HasLlamaCppModelProperties
  105. def getRopeScalingType: String

    Definition Classes
    HasLlamaCppModelProperties
  106. def getSamplers: Array[String]

  107. def getSatModel: SentenceDetectorSaTModel

    Returns the held SentenceDetectorSaTModel, lazily downloading the default SaT model the first time it is needed.

  108. def getSeed: Int

  109. def getSentenceThreshold: Float

  110. def getSplitMode: String

    Definition Classes
    HasLlamaCppModelProperties
  111. def getSrcLang: String

  112. def getStopStrings: Array[String]

  113. def getSystemPrompt: String

    Definition Classes
    HasLlamaCppModelProperties
  114. def getTemperature: Float

  115. def getTfsZ: Float

  116. def getTgtLang: String

  117. def getTokenBias: Map[String, Float]

  118. def getTokenIdBias: Map[Int, Float]

  119. def getTopK: Int

  120. def getTopP: Float

  121. def getTypicalP: Float

  122. def getUseChatTemplate: Boolean

  123. def getUseMlock: Boolean

    Definition Classes
    HasLlamaCppModelProperties
  124. def getUseMmap: Boolean

    Definition Classes
    HasLlamaCppModelProperties
  125. def getYarnAttnFactor: Float

    Definition Classes
    HasLlamaCppModelProperties
  126. def getYarnBetaFast: Float

    Definition Classes
    HasLlamaCppModelProperties
  127. def getYarnBetaSlow: Float

    Definition Classes
    HasLlamaCppModelProperties
  128. def getYarnExtFactor: Float

    Definition Classes
    HasLlamaCppModelProperties
  129. def getYarnOrigCtx: Int

    Definition Classes
    HasLlamaCppModelProperties
  130. val gpuSplitMode: Param[String]

    Set how to split the model across GPUs

    Set how to split the model across GPUs

    • NONE: No GPU split
    • LAYER: Split the model across GPUs by layer
    • ROW: Split the model across GPUs by rows
    Definition Classes
    HasLlamaCppModelProperties
  131. val grammar: Param[String]

  132. final def hasDefault[T](param: Param[T]): Boolean
    Definition Classes
    Params
  133. def hasParam(paramName: String): Boolean
    Definition Classes
    Params
  134. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  135. val ignoreEos: BooleanParam

  136. def initializeLogIfNecessary(isInterpreter: Boolean, silent: Boolean): Boolean
    Attributes
    protected
    Definition Classes
    Logging
  137. def initializeLogIfNecessary(isInterpreter: Boolean): Unit
    Attributes
    protected
    Definition Classes
    Logging
  138. val inputCol: Param[String]
  139. val inputPrefix: Param[String]

  140. val inputSuffix: Param[String]

  141. final def isDefined(param: Param[_]): Boolean
    Definition Classes
    Params
  142. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  143. final def isSet(param: Param[_]): Boolean
    Definition Classes
    Params
  144. def isTraceEnabled(): Boolean
    Attributes
    protected
    Definition Classes
    Logging
  145. val joinString: Param[String]

    String used by Reader2Doc to join multiple extracted text elements when outputAsDocument is true (Default: "\n").

  146. def log: Logger
    Attributes
    protected
    Definition Classes
    Logging
  147. def logDebug(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  148. def logDebug(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  149. def logError(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  150. def logError(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  151. def logInfo(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  152. def logInfo(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  153. def logName: String
    Attributes
    protected
    Definition Classes
    Logging
  154. def logTrace(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  155. def logTrace(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  156. val logVerbosity: IntParam

    Definition Classes
    HasLlamaCppModelProperties
  157. def logWarning(msg: ⇒ String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  158. def logWarning(msg: ⇒ String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  159. val logger: Logger
    Attributes
    protected
    Definition Classes
    HasLlamaCppModelProperties
  160. val mainGpu: IntParam

    Definition Classes
    HasLlamaCppModelProperties
  161. val maxSentenceLength: IntParam

    Maximum sentence length in characters used by the SentenceDetectorSaTModel (Default: 0 \= no maximum).

    Maximum sentence length in characters used by the SentenceDetectorSaTModel (Default: 0 \= no maximum). See minSentenceLength.

  162. val metadata: ProtectedParam[String]
    Definition Classes
    HasLlamaCppModelProperties
  163. val minKeep: IntParam

  164. val minP: FloatParam

  165. val minSentenceLength: IntParam

    Minimum sentence length in characters used by the SentenceDetectorSaTModel (Default: 0 \= no minimum).

    Minimum sentence length in characters used by the SentenceDetectorSaTModel (Default: 0 \= no minimum). When minSentenceLength or maxSentenceLength is > 0, the SaT model switches to length-constrained segmentation.

  166. val miroStat: Param[String]

  167. val miroStatEta: FloatParam

  168. val miroStatTau: FloatParam

  169. val modelDraft: Param[String]

    Definition Classes
    HasLlamaCppModelProperties
  170. val nBatch: IntParam

    Definition Classes
    HasLlamaCppModelProperties
  171. val nCtx: IntParam

    Definition Classes
    HasLlamaCppModelProperties
  172. val nDraft: IntParam

    Definition Classes
    HasLlamaCppModelProperties
  173. val nGpuLayers: IntParam

    Definition Classes
    HasLlamaCppModelProperties
  174. val nGpuLayersDraft: IntParam

    Definition Classes
    HasLlamaCppModelProperties
  175. val nKeep: IntParam

  176. val nPredict: IntParam

  177. val nProbs: IntParam

  178. val nThreads: IntParam

    Definition Classes
    HasLlamaCppModelProperties
  179. val nThreadsBatch: IntParam

    Definition Classes
    HasLlamaCppModelProperties
  180. val nUbatch: IntParam

    Definition Classes
    HasLlamaCppModelProperties
  181. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  182. val noKvOffload: BooleanParam

    Definition Classes
    HasLlamaCppModelProperties
  183. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  184. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  185. val numaStrategy: Param[String]

    Set optimization strategies that help on some NUMA systems (if available)

    Set optimization strategies that help on some NUMA systems (if available)

    Available Strategies:

    • DISABLED: No NUMA optimizations
    • DISTRIBUTE: Spread execution evenly over all
    • ISOLATE: Only spawn threads on CPUs on the node that execution started on
    • NUMA_CTL: Use the CPU map provided by numactl
    • MIRROR: Mirrors the model across NUMA nodes
    Definition Classes
    HasLlamaCppModelProperties
  186. def onWrite(path: String, spark: SparkSession): Unit
    Attributes
    protected
    Definition Classes
    ParamsAndFeaturesWritable
  187. val outputAnnotatorType: AnnotatorType

    Output Annotator Type: DOCUMENT

    Output Annotator Type: DOCUMENT

    Definition Classes
    DocumentTranslator → HasOutputAnnotatorType
  188. val outputAsDocument: BooleanParam

    When true (default) Reader2Doc merges all extracted elements from a single file into one DOCUMENT annotation before translation.

    When true (default) Reader2Doc merges all extracted elements from a single file into one DOCUMENT annotation before translation. When false every extracted element becomes its own DOCUMENT annotation and is translated independently.

  189. final val outputCol: Param[String]
    Attributes
    protected
    Definition Classes
    HasOutputAnnotationCol
  190. lazy val params: Array[Param[_]]
    Definition Classes
    Params
  191. val penalizeNl: BooleanParam

  192. val penaltyPrompt: Param[String]

  193. val presencePenalty: FloatParam

  194. def processCompletions(results: Array[String]): Array[String]
    Attributes
    protected
    Definition Classes
    CompletionPostProcessing
  195. val promptTemplate: Param[String]
  196. val reasoningBudget: IntParam

    Definition Classes
    HasLlamaCppModelProperties
  197. val removeThinkingTag: Param[String]

    Definition Classes
    CompletionPostProcessing
  198. val repeatLastN: IntParam

  199. val repeatPenalty: FloatParam

  200. val ropeFreqBase: FloatParam

    Definition Classes
    HasLlamaCppModelProperties
  201. val ropeFreqScale: FloatParam

    Definition Classes
    HasLlamaCppModelProperties
  202. val ropeScalingType: Param[String]

    Set the RoPE frequency scaling method, defaults to linear unless specified by the model.

    Set the RoPE frequency scaling method, defaults to linear unless specified by the model.

    • UNSPECIFIED: Don't use any scaling
    • LINEAR: Linear scaling
    • YARN: YaRN RoPE scaling
    Definition Classes
    HasLlamaCppModelProperties
  203. val samplers: StringArrayParam

  204. def save(path: String): Unit
    Definition Classes
    MLWritable
    Annotations
    @Since( "1.6.0" ) @throws( ... )
  205. val seed: IntParam

  206. val sentenceThreshold: FloatParam

    Boundary probability threshold for the SentenceDetectorSaTModel (Default: 0.25).

    Boundary probability threshold for the SentenceDetectorSaTModel (Default: 0.25). Ignored when length-constrained segmentation is active.

  207. def set[T](param: ProtectedParam[T], value: T): DocumentTranslator.this.type

    Sets the value for a protected Param.

    Sets the value for a protected Param.

    If the parameter was already set, it will not be set again. Default values do not count as a set value and can be overridden.

    T

    Type of the parameter

    param

    Protected parameter to set

    value

    Value for the parameter

    returns

    This object

    Definition Classes
    HasProtectedParams
  208. def set[T](feature: StructFeature[T], value: T): DocumentTranslator.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  209. def set[K, V](feature: MapFeature[K, V], value: Map[K, V]): DocumentTranslator.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  210. def set[T](feature: SetFeature[T], value: Set[T]): DocumentTranslator.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  211. def set[T](feature: ArrayFeature[T], value: Array[T]): DocumentTranslator.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  212. final def set(paramPair: ParamPair[_]): DocumentTranslator.this.type
    Attributes
    protected
    Definition Classes
    Params
  213. final def set(param: String, value: Any): DocumentTranslator.this.type
    Attributes
    protected
    Definition Classes
    Params
  214. final def set[T](param: Param[T], value: T): DocumentTranslator.this.type
    Definition Classes
    Params
  215. def setBatchSize(value: Int): DocumentTranslator.this.type

  216. def setCachePrompt(cachePrompt: Boolean): DocumentTranslator.this.type

    Whether to remember the prompt to avoid reprocessing it

    Whether to remember the prompt to avoid reprocessing it

    Definition Classes
    HasLlamaCppInferenceProperties
  217. def setChatTemplate(chatTemplate: String): DocumentTranslator.this.type

    The chat template to use

    The chat template to use

    Definition Classes
    HasLlamaCppModelProperties
  218. def setContentPath(value: String): DocumentTranslator.this.type

  219. def setContentType(value: String): DocumentTranslator.this.type

  220. def setDefault[T](feature: StructFeature[T], value: () ⇒ T): DocumentTranslator.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  221. def setDefault[K, V](feature: MapFeature[K, V], value: () ⇒ Map[K, V]): DocumentTranslator.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  222. def setDefault[T](feature: SetFeature[T], value: () ⇒ Set[T]): DocumentTranslator.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  223. def setDefault[T](feature: ArrayFeature[T], value: () ⇒ Array[T]): DocumentTranslator.this.type
    Attributes
    protected
    Definition Classes
    HasFeatures
  224. final def setDefault(paramPairs: ParamPair[_]*): DocumentTranslator.this.type
    Attributes
    protected
    Definition Classes
    Params
  225. final def setDefault[T](param: Param[T], value: T): DocumentTranslator.this.type
    Attributes
    protected[org.apache.spark.ml]
    Definition Classes
    Params
  226. def setDefragmentationThreshold(defragThold: Float): DocumentTranslator.this.type

    Set the KV cache defragmentation threshold

    Set the KV cache defragmentation threshold

    Definition Classes
    HasLlamaCppModelProperties
  227. def setDisableLog(disableLog: Boolean): DocumentTranslator.this.type

    Definition Classes
    HasLlamaCppModelProperties
  228. def setDisableTokenIds(disableTokenIds: Array[Int]): DocumentTranslator.this.type

    Set the token ids to disable in the completion.

    Set the token ids to disable in the completion. This corresponds to setTokenBias with a value of Float.NEGATIVE_INFINITY.

    Definition Classes
    HasLlamaCppInferenceProperties
  229. def setDynamicTemperatureExponent(dynatempExponent: Float): DocumentTranslator.this.type

    Set the dynamic temperature exponent

    Set the dynamic temperature exponent

    Definition Classes
    HasLlamaCppInferenceProperties
  230. def setDynamicTemperatureRange(dynatempRange: Float): DocumentTranslator.this.type

    Set the dynamic temperature range

    Set the dynamic temperature range

    Definition Classes
    HasLlamaCppInferenceProperties
  231. def setFlashAttention(flashAttention: Boolean): DocumentTranslator.this.type

    Whether to enable Flash Attention

    Whether to enable Flash Attention

    Definition Classes
    HasLlamaCppModelProperties
  232. def setFrequencyPenalty(frequencyPenalty: Float): DocumentTranslator.this.type

    Set the repetition alpha frequency penalty

    Set the repetition alpha frequency penalty

    Definition Classes
    HasLlamaCppInferenceProperties
  233. def setGpuSplitMode(splitMode: String): DocumentTranslator.this.type

    Set how to split the model across GPUs

    Set how to split the model across GPUs

    • NONE: No GPU split -LAYER: Split the model across GPUs by layer 2. ROW: Split the model across GPUs by rows
    Definition Classes
    HasLlamaCppModelProperties
  234. def setGrammar(grammar: String): DocumentTranslator.this.type

    Set BNF-like grammar to constrain generations

    Set BNF-like grammar to constrain generations

    Definition Classes
    HasLlamaCppInferenceProperties
  235. def setIgnoreEos(ignoreEos: Boolean): DocumentTranslator.this.type

    Set whether to ignore end of stream token and continue generating (implies --logit-bias 2-inf)

    Set whether to ignore end of stream token and continue generating (implies --logit-bias 2-inf)

    Definition Classes
    HasLlamaCppInferenceProperties
  236. def setInputCol(value: String): DocumentTranslator.this.type

  237. def setInputPrefix(inputPrefix: String): DocumentTranslator.this.type

    Set the prompt to start generation with

    Set the prompt to start generation with

    Definition Classes
    HasLlamaCppInferenceProperties
  238. def setInputSuffix(inputSuffix: String): DocumentTranslator.this.type

    Set a suffix for infilling

    Set a suffix for infilling

    Definition Classes
    HasLlamaCppInferenceProperties
  239. def setJoinString(value: String): DocumentTranslator.this.type

  240. def setLogVerbosity(logVerbosity: Int): DocumentTranslator.this.type

    Set the verbosity threshold.

    Set the verbosity threshold. Messages with a higher verbosity will be ignored.

    Values map to the following:

    • GGML_LOG_LEVEL_NONE = 0
    • GGML_LOG_LEVEL_DEBUG = 1
    • GGML_LOG_LEVEL_INFO = 2
    • GGML_LOG_LEVEL_WARN = 3
    • GGML_LOG_LEVEL_ERROR = 4
    • GGML_LOG_LEVEL_CONT = 5 (continue previous log)
    Definition Classes
    HasLlamaCppModelProperties
  241. def setMainGpu(mainGpu: Int): DocumentTranslator.this.type

    Set the GPU that is used for scratch and small tensors

    Set the GPU that is used for scratch and small tensors

    Definition Classes
    HasLlamaCppModelProperties
  242. def setMaxSentenceLength(value: Int): DocumentTranslator.this.type

  243. def setMetadata(metadata: String): DocumentTranslator.this.type

    Set the metadata for the model

    Set the metadata for the model

    Definition Classes
    HasLlamaCppModelProperties
  244. def setMinKeep(minKeep: Int): DocumentTranslator.this.type

    Set the amount of tokens the samplers should return at least (0 = disabled)

    Set the amount of tokens the samplers should return at least (0 = disabled)

    Definition Classes
    HasLlamaCppInferenceProperties
  245. def setMinP(minP: Float): DocumentTranslator.this.type

    Set min-p sampling

    Set min-p sampling

    Definition Classes
    HasLlamaCppInferenceProperties
  246. def setMinSentenceLength(value: Int): DocumentTranslator.this.type

  247. def setMiroStat(mirostat: String): DocumentTranslator.this.type

    Set MiroStat sampling strategies.

    Set MiroStat sampling strategies.

    • DISABLED: No MiroStat
    • V1: MiroStat V1
    • V2: MiroStat V2
    Definition Classes
    HasLlamaCppInferenceProperties
  248. def setMiroStatEta(mirostatEta: Float): DocumentTranslator.this.type

    Set the MiroStat learning rate, parameter eta

    Set the MiroStat learning rate, parameter eta

    Definition Classes
    HasLlamaCppInferenceProperties
  249. def setMiroStatTau(mirostatTau: Float): DocumentTranslator.this.type

    Set the MiroStat target entropy, parameter tau

    Set the MiroStat target entropy, parameter tau

    Definition Classes
    HasLlamaCppInferenceProperties
  250. def setModelDraft(modelDraft: String): DocumentTranslator.this.type

    Set the draft model for speculative decoding

    Set the draft model for speculative decoding

    Definition Classes
    HasLlamaCppModelProperties
  251. def setModelIfNotSet(spark: SparkSession, wrapper: GGUFWrapper): DocumentTranslator.this.type

  252. def setNBatch(nBatch: Int): DocumentTranslator.this.type

    Set the logical batch size for prompt processing (must be >=32 to use BLAS)

    Set the logical batch size for prompt processing (must be >=32 to use BLAS)

    Definition Classes
    HasLlamaCppModelProperties
  253. def setNCtx(nCtx: Int): DocumentTranslator.this.type

    Set the size of the prompt context

    Set the size of the prompt context

    Definition Classes
    HasLlamaCppModelProperties
  254. def setNDraft(nDraft: Int): DocumentTranslator.this.type

    Set the number of tokens to draft for speculative decoding

    Set the number of tokens to draft for speculative decoding

    Definition Classes
    HasLlamaCppModelProperties
  255. def setNGpuLayers(nGpuLayers: Int): DocumentTranslator.this.type

    Set the number of layers to store in VRAM (-1 - use default)

    Set the number of layers to store in VRAM (-1 - use default)

    Definition Classes
    HasLlamaCppModelProperties
  256. def setNGpuLayersDraft(nGpuLayersDraft: Int): DocumentTranslator.this.type

    Set the number of layers to store in VRAM for the draft model (-1 - use default)

    Set the number of layers to store in VRAM for the draft model (-1 - use default)

    Definition Classes
    HasLlamaCppModelProperties
  257. def setNKeep(nKeep: Int): DocumentTranslator.this.type

    Set the number of tokens to keep from the initial prompt

    Set the number of tokens to keep from the initial prompt

    Definition Classes
    HasLlamaCppInferenceProperties
  258. def setNParallel(value: Int): DocumentTranslator.this.type

    Alias for setBatchSize (number of llama.cpp parallel decoding slots).

  259. def setNPredict(nPredict: Int): DocumentTranslator.this.type

    Set the number of tokens to predict

    Set the number of tokens to predict

    Definition Classes
    HasLlamaCppInferenceProperties
  260. def setNProbs(nProbs: Int): DocumentTranslator.this.type

    Set the amount top tokens probabilities to output if greater than 0.

    Set the amount top tokens probabilities to output if greater than 0.

    Definition Classes
    HasLlamaCppInferenceProperties
  261. def setNThreads(nThreads: Int): DocumentTranslator.this.type

    Set the number of threads to use during generation

    Set the number of threads to use during generation

    Definition Classes
    HasLlamaCppModelProperties
  262. def setNThreadsBatch(nThreadsBatch: Int): DocumentTranslator.this.type

    Set the number of threads to use during batch and prompt processing

    Set the number of threads to use during batch and prompt processing

    Definition Classes
    HasLlamaCppModelProperties
  263. def setNUbatch(nUbatch: Int): DocumentTranslator.this.type

    Set the physical batch size for prompt processing (must be >=32 to use BLAS)

    Set the physical batch size for prompt processing (must be >=32 to use BLAS)

    Definition Classes
    HasLlamaCppModelProperties
  264. def setNoKvOffload(noKvOffload: Boolean): DocumentTranslator.this.type

    Whether to disable KV offload

    Whether to disable KV offload

    Definition Classes
    HasLlamaCppModelProperties
  265. def setNumaStrategy(numa: String): DocumentTranslator.this.type

    Set optimization strategies that help on some NUMA systems (if available)

    Set optimization strategies that help on some NUMA systems (if available)

    Available Strategies:

    • DISABLED: No NUMA optimizations
    • DISTRIBUTE: spread execution evenly over all
    • ISOLATE: only spawn threads on CPUs on the node that execution started on
    • NUMA_CTL: use the CPU map provided by numactl
    • MIRROR: Mirrors the model across NUMA nodes
    Definition Classes
    HasLlamaCppModelProperties
  266. def setOutputAsDocument(value: Boolean): DocumentTranslator.this.type

  267. final def setOutputCol(value: String): DocumentTranslator.this.type

    Overrides annotation column name when transforming

    Overrides annotation column name when transforming

    Definition Classes
    HasOutputAnnotationCol
  268. def setPenalizeNl(penalizeNl: Boolean): DocumentTranslator.this.type

    Set whether to penalize newline tokens

    Set whether to penalize newline tokens

    Definition Classes
    HasLlamaCppInferenceProperties
  269. def setPenaltyPrompt(penaltyPrompt: String): DocumentTranslator.this.type

    Override which part of the prompt is penalized for repetition.

    Override which part of the prompt is penalized for repetition.

    Definition Classes
    HasLlamaCppInferenceProperties
  270. def setPresencePenalty(presencePenalty: Float): DocumentTranslator.this.type

    Set the repetition alpha presence penalty

    Set the repetition alpha presence penalty

    Definition Classes
    HasLlamaCppInferenceProperties
  271. def setPromptTemplate(value: String): DocumentTranslator.this.type

  272. def setReasoningBudget(reasoningBudget: Int): DocumentTranslator.this.type

    Controls the amount of thinking allowed; currently only one of: -1 for unrestricted thinking budget, or 0 to disable thinking (default: -1)

    Controls the amount of thinking allowed; currently only one of: -1 for unrestricted thinking budget, or 0 to disable thinking (default: -1)

    Definition Classes
    HasLlamaCppModelProperties
  273. def setRemoveThinkingTag(value: String): DocumentTranslator.this.type

    Set a thinking tag (e.g.

    Set a thinking tag (e.g. think) to be removed from output. Will produce the regex (?s)<$TAG>.+?</$TAG>

    Definition Classes
    CompletionPostProcessing
  274. def setRepeatLastN(repeatLastN: Int): DocumentTranslator.this.type

    Set the last n tokens to consider for penalties

    Set the last n tokens to consider for penalties

    Definition Classes
    HasLlamaCppInferenceProperties
  275. def setRepeatPenalty(repeatPenalty: Float): DocumentTranslator.this.type

    Set the penalty of repeated sequences of tokens

    Set the penalty of repeated sequences of tokens

    Definition Classes
    HasLlamaCppInferenceProperties
  276. def setRopeFreqBase(ropeFreqBase: Float): DocumentTranslator.this.type

    Set the RoPE base frequency, used by NTK-aware scaling

    Set the RoPE base frequency, used by NTK-aware scaling

    Definition Classes
    HasLlamaCppModelProperties
  277. def setRopeFreqScale(ropeFreqScale: Float): DocumentTranslator.this.type

    Set the RoPE frequency scaling factor, expands context by a factor of 1/N

    Set the RoPE frequency scaling factor, expands context by a factor of 1/N

    Definition Classes
    HasLlamaCppModelProperties
  278. def setRopeScalingType(ropeScalingType: String): DocumentTranslator.this.type

    Set the RoPE frequency scaling method, defaults to linear unless specified by the model.

    Set the RoPE frequency scaling method, defaults to linear unless specified by the model.

    • NONE: Don't use any scaling
    • LINEAR: Linear scaling
    • YARN: YaRN RoPE scaling
    Definition Classes
    HasLlamaCppModelProperties
  279. def setSamplers(samplers: Array[String]): DocumentTranslator.this.type

    Set which samplers to use for token generation in the given order .

    Set which samplers to use for token generation in the given order .

    Available Samplers are:

    • TOP_K: Top-k sampling
    • TFS_Z: Tail free sampling
    • TYPICAL_P: Locally typical sampling p
    • TOP_P: Top-p sampling
    • MIN_P: Min-p sampling
    • TEMPERATURE: Temperature sampling
    Definition Classes
    HasLlamaCppInferenceProperties
  280. def setSatModel(value: SentenceDetectorSaTModel): DocumentTranslator.this.type

    Provide a custom SentenceDetectorSaTModel for sentence splitting.

  281. def setSeed(seed: Int): DocumentTranslator.this.type

    Set the RNG seed

    Set the RNG seed

    Definition Classes
    HasLlamaCppInferenceProperties
  282. def setSentenceThreshold(value: Float): DocumentTranslator.this.type

  283. def setSrcLang(value: String): DocumentTranslator.this.type

  284. def setStopStrings(stopStrings: Array[String]): DocumentTranslator.this.type

    Set strings upon seeing which token generation is stopped

    Set strings upon seeing which token generation is stopped

    Definition Classes
    HasLlamaCppInferenceProperties
  285. def setSystemPrompt(systemPrompt: String): DocumentTranslator.this.type

    Set a system prompt to use

    Set a system prompt to use

    Definition Classes
    HasLlamaCppModelProperties
  286. def setTemperature(temperature: Float): DocumentTranslator.this.type

    Set the temperature

    Set the temperature

    Definition Classes
    HasLlamaCppInferenceProperties
  287. def setTfsZ(tfsZ: Float): DocumentTranslator.this.type

    Set tail free sampling, parameter z

    Set tail free sampling, parameter z

    Definition Classes
    HasLlamaCppInferenceProperties
  288. def setTgtLang(value: String): DocumentTranslator.this.type

  289. def setTokenBias(tokenBias: HashMap[String, Double]): DocumentTranslator.this.type

    Set the tokens to disable during completion.

    Set the tokens to disable during completion. (Override for PySpark)

    Definition Classes
    HasLlamaCppInferenceProperties
  290. def setTokenBias(tokenBias: Map[String, Float]): DocumentTranslator.this.type

    Set the tokens to disable during completion.

    Set the tokens to disable during completion.

    Definition Classes
    HasLlamaCppInferenceProperties
  291. def setTokenIdBias(tokenIdBias: HashMap[Integer, Double]): DocumentTranslator.this.type

    Set the token ids to disable in the completion.

    Set the token ids to disable in the completion. (Override for PySpark)

    Definition Classes
    HasLlamaCppInferenceProperties
  292. def setTokenIdBias(tokenIdBias: Map[Int, Float]): DocumentTranslator.this.type

    Set the token ids to disable in the completion.

    Set the token ids to disable in the completion.

    Definition Classes
    HasLlamaCppInferenceProperties
  293. def setTopK(topK: Int): DocumentTranslator.this.type

    Set top-k sampling

    Set top-k sampling

    Definition Classes
    HasLlamaCppInferenceProperties
  294. def setTopP(topP: Float): DocumentTranslator.this.type

    Set top-p sampling

    Set top-p sampling

    Definition Classes
    HasLlamaCppInferenceProperties
  295. def setTypicalP(typicalP: Float): DocumentTranslator.this.type

    Set locally typical sampling, parameter p

    Set locally typical sampling, parameter p

    Definition Classes
    HasLlamaCppInferenceProperties
  296. def setUseChatTemplate(useChatTemplate: Boolean): DocumentTranslator.this.type

    Set whether or not generate should apply a chat template

    Set whether or not generate should apply a chat template

    Definition Classes
    HasLlamaCppInferenceProperties
  297. def setUseMlock(useMlock: Boolean): DocumentTranslator.this.type

    Whether to force the system to keep model in RAM rather than swapping or compressing

    Whether to force the system to keep model in RAM rather than swapping or compressing

    Definition Classes
    HasLlamaCppModelProperties
  298. def setUseMmap(useMmap: Boolean): DocumentTranslator.this.type

    Whether to use memory-map model (faster load but may increase pageouts if not using mlock)

    Whether to use memory-map model (faster load but may increase pageouts if not using mlock)

    Definition Classes
    HasLlamaCppModelProperties
  299. def setYarnAttnFactor(yarnAttnFactor: Float): DocumentTranslator.this.type

    Set the YaRN scale sqrt(t) or attention magnitude

    Set the YaRN scale sqrt(t) or attention magnitude

    Definition Classes
    HasLlamaCppModelProperties
  300. def setYarnBetaFast(yarnBetaFast: Float): DocumentTranslator.this.type

    Set the YaRN low correction dim or beta

    Set the YaRN low correction dim or beta

    Definition Classes
    HasLlamaCppModelProperties
  301. def setYarnBetaSlow(yarnBetaSlow: Float): DocumentTranslator.this.type

    Set the YaRN high correction dim or alpha

    Set the YaRN high correction dim or alpha

    Definition Classes
    HasLlamaCppModelProperties
  302. def setYarnExtFactor(yarnExtFactor: Float): DocumentTranslator.this.type

    Set the YaRN extrapolation mix factor

    Set the YaRN extrapolation mix factor

    Definition Classes
    HasLlamaCppModelProperties
  303. def setYarnOrigCtx(yarnOrigCtx: Int): DocumentTranslator.this.type

    Set the YaRN original context size of model

    Set the YaRN original context size of model

    Definition Classes
    HasLlamaCppModelProperties
  304. val srcLang: Param[String]

    Source language interpolated into promptTemplate (e.g.

    Source language interpolated into promptTemplate (e.g. "English").

  305. val stopStrings: StringArrayParam

  306. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  307. val systemPrompt: Param[String]

    Definition Classes
    HasLlamaCppModelProperties
  308. val temperature: FloatParam

  309. val tfsZ: FloatParam

  310. val tgtLang: Param[String]

    Target language interpolated into promptTemplate (e.g.

    Target language interpolated into promptTemplate (e.g. "French").

  311. def toString(): String
    Definition Classes
    Identifiable → AnyRef → Any
  312. val tokenBias: StructFeature[Map[String, Float]]

  313. val tokenIdBias: StructFeature[Map[Int, Float]]
  314. val topK: IntParam

  315. val topP: FloatParam

  316. def transform(dataset: Dataset[_]): DataFrame
    Definition Classes
    DocumentTranslator → Transformer
  317. def transform(dataset: Dataset[_], paramMap: ParamMap): DataFrame
    Definition Classes
    Transformer
    Annotations
    @Since( "2.0.0" )
  318. def transform(dataset: Dataset[_], firstParamPair: ParamPair[_], otherParamPairs: ParamPair[_]*): DataFrame
    Definition Classes
    Transformer
    Annotations
    @Since( "2.0.0" ) @varargs()
  319. def transformSchema(schema: StructType): StructType
    Definition Classes
    DocumentTranslator → PipelineStage
  320. def transformSchema(schema: StructType, logging: Boolean): StructType
    Attributes
    protected
    Definition Classes
    PipelineStage
    Annotations
    @DeveloperApi()
  321. val typicalP: FloatParam

  322. val uid: String
    Definition Classes
    DocumentTranslator → Identifiable
  323. val useChatTemplate: BooleanParam

  324. val useMlock: BooleanParam

    Definition Classes
    HasLlamaCppModelProperties
  325. val useMmap: BooleanParam

    Definition Classes
    HasLlamaCppModelProperties
  326. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  327. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  328. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  329. def write: MLWriter
    Definition Classes
    ParamsAndFeaturesWritable → DefaultParamsWritable → MLWritable
  330. val yarnAttnFactor: FloatParam

    Definition Classes
    HasLlamaCppModelProperties
  331. val yarnBetaFast: FloatParam

    Definition Classes
    HasLlamaCppModelProperties
  332. val yarnBetaSlow: FloatParam

    Definition Classes
    HasLlamaCppModelProperties
  333. val yarnExtFactor: FloatParam

    Definition Classes
    HasLlamaCppModelProperties
  334. val yarnOrigCtx: IntParam

    Definition Classes
    HasLlamaCppModelProperties

Inherited from CompletionPostProcessing

Inherited from HasProtectedParams

Inherited from HasEngine

Inherited from ParamsAndFeaturesWritable

Inherited from HasFeatures

Inherited from DefaultParamsWritable

Inherited from MLWritable

Inherited from HasOutputAnnotationCol

Inherited from HasOutputAnnotatorType

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

Parameter setters

Parameter getters