Package ai.djl.modality.nlp.embedding
Class ModelZooTextEmbedding
java.lang.Object
ai.djl.modality.nlp.embedding.ModelZooTextEmbedding
- All Implemented Interfaces:
TextEmbedding
,AutoCloseable
A
WordEmbedding
using a ZooModel
.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Embeds the text after preprocessed usingTextEmbedding.preprocessTextToEmbed(List)
.long[]
preprocessTextToEmbed
(List<String> tokens) Preprocesses the text to embed into an array to pass into the model.unembedText
(NDArray word) Returns the closest matching text for a given embedding.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ai.djl.modality.nlp.embedding.TextEmbedding
embedText, embedText
-
Constructor Details
-
ModelZooTextEmbedding
Constructs aModelZooTextEmbedding
.
-
-
Method Details
-
preprocessTextToEmbed
Preprocesses the text to embed into an array to pass into the model.Make sure to call
TextEmbedding.embedText(NDManager, long[])
after this.- Specified by:
preprocessTextToEmbed
in interfaceTextEmbedding
- Parameters:
tokens
- the text to embed- Returns:
- the indices of text that is ready to embed
-
embedText
Embeds the text after preprocessed usingTextEmbedding.preprocessTextToEmbed(List)
.- Specified by:
embedText
in interfaceTextEmbedding
- Parameters:
indices
- the indices of text to embed- Returns:
- the embedded text
- Throws:
EmbeddingException
- if there is an error while trying to embed
-
unembedText
Returns the closest matching text for a given embedding.- Specified by:
unembedText
in interfaceTextEmbedding
- Parameters:
word
- the text embedding to find the matching string text for.- Returns:
- text similar to the passed in embedding
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-