Package ai.djl.modality.nlp.translator
Class SimpleText2TextTranslator
- java.lang.Object
-
- ai.djl.modality.nlp.translator.SimpleText2TextTranslator
-
- All Implemented Interfaces:
PostProcessor<java.lang.String>,PreProcessor<java.lang.String>,Translator<java.lang.String,java.lang.String>
public class SimpleText2TextTranslator extends java.lang.Object implements Translator<java.lang.String,java.lang.String>
ATranslatorthat performs pre-process and post-processing for a sequence-to-sequence text model.
-
-
Constructor Summary
Constructors Constructor Description SimpleText2TextTranslator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BatchifiergetBatchifier()Returns theBatchifier.NDListprocessInput(TranslatorContext ctx, java.lang.String input)Processes the input and converts it to NDList.java.lang.StringprocessOutput(TranslatorContext ctx, NDList list)Processes the output NDList to the corresponding output object.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ai.djl.translate.Translator
getExpansions, prepare, toBatchTranslator, toBatchTranslator
-
-
-
-
Method Detail
-
processOutput
public java.lang.String processOutput(TranslatorContext ctx, NDList list)
Processes the output NDList to the corresponding output object.- Specified by:
processOutputin interfacePostProcessor<java.lang.String>- Parameters:
ctx- the toolkit used for post-processinglist- the output NDList after inference, usually immutable in engines like PyTorch. @see Issue 1774- Returns:
- the output object of expected type
-
processInput
public NDList processInput(TranslatorContext ctx, java.lang.String input)
Processes the input and converts it to NDList.- Specified by:
processInputin interfacePreProcessor<java.lang.String>- Parameters:
ctx- the toolkit for creating the input NDArrayinput- the input object- Returns:
- the
NDListafter pre-processing
-
getBatchifier
public Batchifier getBatchifier()
Returns theBatchifier.- Specified by:
getBatchifierin interfaceTranslator<java.lang.String,java.lang.String>- Returns:
- the
Batchifier
-
-