Package ai.djl.modality.nlp.translator
Class CrossEncoderServingTranslator
java.lang.Object
ai.djl.modality.nlp.translator.CrossEncoderServingTranslator
- All Implemented Interfaces:
PostProcessor<Output>
,PreProcessor<Input>
,Translator<Input,
Output>
-
Constructor Summary
ConstructorsConstructorDescriptionCrossEncoderServingTranslator
(Translator<ai.djl.util.StringPair, float[]> translator) Constructs aCrossEncoderServingTranslator
instance. -
Method Summary
Modifier and TypeMethodDescriptionbatchProcessInput
(TranslatorContext ctx, List<Input> inputs) Batch processes the inputs and converts it to NDList.batchProcessOutput
(TranslatorContext ctx, NDList list) Batch processes the output NDList to the corresponding output objects.void
prepare
(TranslatorContext ctx) Prepares the translator with the manager and model to use.processInput
(TranslatorContext ctx, Input input) Processes the input and converts it to NDList.processOutput
(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
getBatchifier, getExpansions
-
Constructor Details
-
CrossEncoderServingTranslator
Constructs aCrossEncoderServingTranslator
instance.- Parameters:
translator
- aTranslator
processes question answering input
-
-
Method Details
-
prepare
Prepares the translator with the manager and model to use.- Specified by:
prepare
in interfaceTranslator<Input,
Output> - Parameters:
ctx
- the context for thePredictor
.- Throws:
Exception
- if there is an error for preparing the translator
-
processInput
Processes the input and converts it to NDList.- Specified by:
processInput
in interfacePreProcessor<Input>
- Parameters:
ctx
- the toolkit for creating the input NDArrayinput
- the input object- Returns:
- the
NDList
after pre-processing - Throws:
Exception
- if an error occurs during processing input
-
batchProcessInput
Batch processes the inputs and converts it to NDList.- Specified by:
batchProcessInput
in interfaceTranslator<Input,
Output> - Parameters:
ctx
- the toolkit for creating the input NDArrayinputs
- a list of the input object- Returns:
- the
NDList
after pre-processing - Throws:
Exception
- if an error occurs during processing input
-
processOutput
Processes the output NDList to the corresponding output object.- Specified by:
processOutput
in interfacePostProcessor<Output>
- 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
- Throws:
Exception
- if an error occurs during processing output
-
batchProcessOutput
Batch processes the output NDList to the corresponding output objects.- Specified by:
batchProcessOutput
in interfaceTranslator<Input,
Output> - Parameters:
ctx
- the toolkit used for post-processinglist
- the output NDList after inference, usually immutable in engines like PyTorch. @see Issue 1774- Returns:
- a list of the output object of expected type
- Throws:
Exception
- if an error occurs during processing output
-