sparknlp_jsl.annotator.seq2seq.medical_summarizer#

Module Contents#

Classes#

MedicalSummarizer

Base class for Model classes.

class MedicalSummarizer(classname='com.johnsnowlabs.nlp.annotators.seq2seq.MedicalSummarizer', java_model=None)#

Bases: sparknlp_jsl.annotator.seq2seq.medical_encoder_decoder.MedicalEncoderDecoder

Base class for Model classes.

batchSize#
caseSensitive#
configProtoBytes#
doSample#
engine#
getter_attrs = []#
ignoreTokenIds#
inputAnnotatorTypes#
inputCols#
lazyAnnotator#
maxNewTokens#
maxTextLength#
mlFrameworkType#
name = MedicalSummarizer#
noRepeatNgramSize#
optionalInputAnnotatorTypes = []#
outputAnnotatorType#
outputCol#
randomSeed#
refineChunkSize#
refineMaxAttempts#
refineSummary#
refineSummaryTargetLength#
skipLPInputColsValidation = True#
stopAtEos#
task#
topK#
useCache#
clear(param)#

Clears a param from the param map if it has been explicitly set.

copy(extra=None)#

Creates a copy of this instance with the same uid and some extra params. This implementation first calls Params.copy and then make a copy of the companion Java pipeline component with extra params. So both the Python wrapper and the Java pipeline component get copied.

Parameters:

extra (dict, optional) – Extra parameters to copy to the new instance

Returns:

Copy of this instance

Return type:

JavaParams

explainParam(param)#

Explains a single param and returns its name, doc, and optional default value and user-supplied value in a string.

explainParams()#

Returns the documentation of all params with their optionally default values and user-supplied values.

extractParamMap(extra=None)#

Extracts the embedded default param values and user-supplied values, and then merges them with extra values from input into a flat param map, where the latter value is used if there exist conflicts, i.e., with ordering: default param values < user-supplied values < extra.

Parameters:

extra (dict, optional) – extra param values

Returns:

merged param map

Return type:

dict

getBatchSize()#

Gets current batch size.

Returns:

Current batch size

Return type:

int

getCaseSensitive()#

Gets whether to ignore case in tokens for embeddings matching.

Returns:

Whether to ignore case in tokens for embeddings matching

Return type:

bool

getEngine()#
Returns:

Deep Learning engine used for this model”

Return type:

str

getInputCols()#

Gets current column names of input annotations.

getLazyAnnotator()#

Gets whether Annotator should be evaluated lazily in a RecursivePipeline.

getOrDefault(param)#

Gets the value of a param in the user-supplied param map or its default value. Raises an error if neither is set.

getOutputCol()#

Gets output column name of annotations.

getParam(paramName)#

Gets a param by its name.

getParamValue(paramName)#

Gets the value of a parameter.

Parameters:

paramName (str) – Name of the parameter

hasDefault(param)#

Checks whether a param has a default value.

hasParam(paramName)#

Tests whether this instance contains a param with a given (string) name.

inputColsValidation(value)#
isDefined(param)#

Checks whether a param is explicitly set by user or has a default value.

isSet(param)#

Checks whether a param is explicitly set by user.

classmethod load(path)#

Reads an ML instance from the input path, a shortcut of read().load(path).

static loadSavedModel(folder, spark_session, use_cache=True)#

Loads a locally saved model.

Parameters:
  • folder (str) – Folder of the saved model

  • spark_session (pyspark.sql.SparkSession) – The current SparkSession

  • use_cache (bool) – The model uses caching to facilitate performance

Returns:

The restored model

Return type:

MedicalSummarizer

static pretrained(name='summarizer_clinical_jsl_augmented', lang='en', remote_loc='clinical/models')#

Downloads and loads a pretrained model.

Parameters:
  • name (str, optional) – Name of the pretrained model, by default “summarizer_clinical_jsl_augmented”

  • lang (str, optional) – Language of the pretrained model, by default “en”

  • remote_loc (str, optional) – Optional remote address of the resource, by default None. Will use Spark NLPs repositories otherwise.

Returns:

The restored model

Return type:

MedicalSummarizer

classmethod read()#

Returns an MLReader instance for this class.

save(path)#

Save this ML instance to the given path, a shortcut of ‘write().save(path)’.

set(param, value)#

Sets a parameter in the embedded param map.

setBatchSize(v)#

Sets batch size.

Parameters:

v (int) – Batch size

setCaseSensitive(value)#

Sets whether to ignore case in tokens for embeddings matching.

Parameters:

value (bool) – Whether to ignore case in tokens for embeddings matching

setConfigProtoBytes(b)#

Sets configProto from tensorflow, serialized into byte array.

Parameters:

b (List[int]) – ConfigProto from tensorflow, serialized into byte array

setDoSample(value)#

Sets whether or not to use sampling, use greedy decoding otherwise.

Parameters:

value (bool) – Whether or not to use sampling; use greedy decoding otherwise

setForceInputTypeValidation(etfm)#
setIgnoreTokenIds(value)#

A list of token ids which are ignored in the decoder’s output.

Parameters:

value (List[int]) – The words to be filtered out

setInputCols(*value)#

Sets column names of input annotations.

Parameters:

*value (List[str]) – Input columns for the annotator

setLazyAnnotator(value)#

Sets whether Annotator should be evaluated lazily in a RecursivePipeline.

Parameters:

value (bool) – Whether Annotator should be evaluated lazily in a RecursivePipeline

setMaxNewTokens(value)#

Sets the maximum number of new tokens to be generated

Parameters:

value (int) – the maximum number of new tokens to be generated

setMaxTextLength(value)#

Set max text length to process

Parameters:

value (int) – max text length

setNoRepeatNgramSize(value)#

Sets size of n-grams that can only occur once.

If set to int > 0, all ngrams of that size can only occur once.

Parameters:

value (int) – N-gram size can only occur once

setOutputCol(value)#

Sets output column name of annotations.

Parameters:

value (str) – Name of output column

setParamValue(paramName)#

Sets the value of a parameter.

Parameters:

paramName (str) – Name of the parameter

setParams()#
setRandomSeed(value)#

Set random seed

Parameters:

value (int) – random seed

setRefineChunkSize(i)#

How large should refined chunks Be. Should be equal to LLM context window size in tokens. Takes only effect when refineSummary=True

Parameters:

i (int) – How large should refined chunks Be. Should be equal to LLM context window size in tokens. Takes only effect when refineSummary=True

setRefineMaxAttempts(i)#

How many times should chunks be re-summarized while they are above SummaryTargetLength before stopping. Takes only effect when refineSummary=True

Parameters:

i (int) – How many times should chunks be re-summarized while they are above SummaryTargetLength before stopping. Takes only effect when refineSummary=True

setRefineSummary(b)#

Set true to perform refined summarization at increased computation cost.

Parameters:

b (bool) – whether to perform refined summaries or not

setRefineSummaryTargetLength(i)#

Target length of summarizations in Tokens (delimited by whitespace). Takes only effect when refineSummary=True

Parameters:

i (int) – Target length of summarizations in Tokens (delimited by whitespace). Takes only effect when refineSummary=True

setStopAtEos(b)#

Stop text generation when the end-of-sentence token is encountered.

Parameters:

b (bool) – whether to stop at end-of-sentence token or not

setTopK(value)#

Sets the number of highest probability vocabulary tokens to keep for top-k-filtering.

Parameters:

value (int) – Number of highest probability vocabulary tokens to keep

transform(dataset, params=None)#

Transforms the input dataset with optional parameters.

New in version 1.3.0.

Parameters:
  • dataset (pyspark.sql.DataFrame) – input dataset

  • params (dict, optional) – an optional param map that overrides embedded params.

Returns:

transformed dataset

Return type:

pyspark.sql.DataFrame

write()#

Returns an MLWriter instance for this ML instance.