public class ModelZooTextEmbedding extends java.lang.Object implements TextEmbedding, java.lang.AutoCloseable
WordEmbedding
using a ZooModel
.Constructor and Description |
---|
ModelZooTextEmbedding(Model model)
Constructs a
ModelZooTextEmbedding . |
Modifier and Type | Method and Description |
---|---|
void |
close() |
NDArray |
embedText(NDArray indices)
Embeds the text after preprocessed using
TextEmbedding.preprocessTextToEmbed(List) . |
long[] |
preprocessTextToEmbed(java.util.List<java.lang.String> tokens)
Preprocesses the text to embed into an array to pass into the model.
|
java.util.List<java.lang.String> |
unembedText(NDArray word)
Returns the closest matching text for a given embedding.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
embedText, embedText
public ModelZooTextEmbedding(Model model)
ModelZooTextEmbedding
.model
- the model for the embedding. The model's block must consist of only an Embedding
<String
>.public long[] preprocessTextToEmbed(java.util.List<java.lang.String> tokens)
Make sure to call TextEmbedding.embedText(NDManager, long[])
after this.
preprocessTextToEmbed
in interface TextEmbedding
tokens
- the text to embedpublic NDArray embedText(NDArray indices) throws EmbeddingException
TextEmbedding.preprocessTextToEmbed(List)
.embedText
in interface TextEmbedding
indices
- the indices of text to embedEmbeddingException
- if there is an error while trying to embedpublic java.util.List<java.lang.String> unembedText(NDArray word)
unembedText
in interface TextEmbedding
word
- the text embedding to find the matching string text for.public void close()
close
in interface java.lang.AutoCloseable