Package ai.djl.modality.nlp.embedding
Class SimpleTextEmbedding
java.lang.Object
ai.djl.modality.nlp.embedding.SimpleTextEmbedding
- All Implemented Interfaces:
TextEmbedding
A
TextEmbedding that applies a WordEmbedding to each word independently.-
Constructor Summary
ConstructorsConstructorDescriptionSimpleTextEmbedding(WordEmbedding wordEmbedding) Constructs aSimpleTextEmbedding. -
Method Summary
Modifier and TypeMethodDescriptionEmbeds the text after preprocessed usingTextEmbedding.preprocessTextToEmbed(List).long[]preprocessTextToEmbed(List<String> text) Preprocesses the text to embed into an array to pass into the model.unembedText(NDArray textEmbedding) 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, waitMethods inherited from interface ai.djl.modality.nlp.embedding.TextEmbedding
embedText, embedText
-
Constructor Details
-
SimpleTextEmbedding
Constructs aSimpleTextEmbedding.- Parameters:
wordEmbedding- the word embedding to embed each word
-
-
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:
preprocessTextToEmbedin interfaceTextEmbedding- Parameters:
text- 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:
embedTextin interfaceTextEmbedding- Parameters:
textIndices- 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:
unembedTextin interfaceTextEmbedding- Parameters:
textEmbedding- the text embedding to find the matching string text for.- Returns:
- text similar to the passed in embedding
-