Package ai.djl.huggingface.translator
Class ZeroShotClassificationTranslator
java.lang.Object
ai.djl.huggingface.translator.ZeroShotClassificationTranslator
- All Implemented Interfaces:
ai.djl.translate.NoBatchifyTranslator<ai.djl.modality.nlp.translator.ZeroShotClassificationInput,,ai.djl.modality.nlp.translator.ZeroShotClassificationOutput> ai.djl.translate.PostProcessor<ai.djl.modality.nlp.translator.ZeroShotClassificationOutput>,ai.djl.translate.PreProcessor<ai.djl.modality.nlp.translator.ZeroShotClassificationInput>,ai.djl.translate.Translator<ai.djl.modality.nlp.translator.ZeroShotClassificationInput,ai.djl.modality.nlp.translator.ZeroShotClassificationOutput>
public class ZeroShotClassificationTranslator
extends Object
implements ai.djl.translate.NoBatchifyTranslator<ai.djl.modality.nlp.translator.ZeroShotClassificationInput,ai.djl.modality.nlp.translator.ZeroShotClassificationOutput>
The translator for Huggingface zero-shot-classification model.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classThe builder for zero-shot classification translator. -
Method Summary
Modifier and TypeMethodDescriptionbuilder(HuggingFaceTokenizer tokenizer) Creates a builder to build aZeroShotClassificationTranslator.builder(HuggingFaceTokenizer tokenizer, Map<String, ?> arguments) Creates a builder to build aZeroShotClassificationTranslator.voidprepare(ai.djl.translate.TranslatorContext ctx) ai.djl.ndarray.NDListprocessInput(ai.djl.translate.TranslatorContext ctx, ai.djl.modality.nlp.translator.ZeroShotClassificationInput input) ai.djl.modality.nlp.translator.ZeroShotClassificationOutputprocessOutput(ai.djl.translate.TranslatorContext ctx, ai.djl.ndarray.NDList list) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ai.djl.translate.NoBatchifyTranslator
getBatchifierMethods inherited from interface ai.djl.translate.Translator
batchProcessInput, batchProcessOutput, getExpansions
-
Method Details
-
prepare
public void prepare(ai.djl.translate.TranslatorContext ctx) throws IOException, ai.djl.ModelException - Specified by:
preparein interfaceai.djl.translate.Translator<ai.djl.modality.nlp.translator.ZeroShotClassificationInput,ai.djl.modality.nlp.translator.ZeroShotClassificationOutput> - Throws:
IOExceptionai.djl.ModelException
-
processInput
public ai.djl.ndarray.NDList processInput(ai.djl.translate.TranslatorContext ctx, ai.djl.modality.nlp.translator.ZeroShotClassificationInput input) - Specified by:
processInputin interfaceai.djl.translate.PreProcessor<ai.djl.modality.nlp.translator.ZeroShotClassificationInput>
-
processOutput
public ai.djl.modality.nlp.translator.ZeroShotClassificationOutput processOutput(ai.djl.translate.TranslatorContext ctx, ai.djl.ndarray.NDList list) throws ai.djl.translate.TranslateException - Specified by:
processOutputin interfaceai.djl.translate.PostProcessor<ai.djl.modality.nlp.translator.ZeroShotClassificationOutput>- Throws:
ai.djl.translate.TranslateException
-
builder
Creates a builder to build aZeroShotClassificationTranslator.- Parameters:
tokenizer- the tokenizer- Returns:
- a new builder
-
builder
public static ZeroShotClassificationTranslator.Builder builder(HuggingFaceTokenizer tokenizer, Map<String, ?> arguments) Creates a builder to build aZeroShotClassificationTranslator.- Parameters:
tokenizer- the tokenizerarguments- the models' arguments- Returns:
- a new builder
-