Class ModelZooTextEmbedding

    • Constructor Detail

      • ModelZooTextEmbedding

        public ModelZooTextEmbedding​(Model model)
        Constructs a ModelZooTextEmbedding.
        Parameters:
        model - the model for the embedding. The model's block must consist of only an Embedding<String>.
    • Method Detail

      • preprocessTextToEmbed

        public long[] preprocessTextToEmbed​(java.util.List<java.lang.String> tokens)
        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 interface TextEmbedding
        Parameters:
        tokens - the text to embed
        Returns:
        the indices of text that is ready to embed
      • unembedText

        public java.util.List<java.lang.String> unembedText​(NDArray word)
        Returns the closest matching text for a given embedding.
        Specified by:
        unembedText in interface TextEmbedding
        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 interface java.lang.AutoCloseable