textattack.constraints.semantics.sentence_encoders.universal_sentence_encoder package

Universal sentence encoder

multilingual universal sentence encoder

class textattack.constraints.semantics.sentence_encoders.universal_sentence_encoder.multilingual_universal_sentence_encoder.MultilingualUniversalSentenceEncoder(threshold=0.8, large=False, metric='angular', **kwargs)[source]

Bases: textattack.constraints.semantics.sentence_encoders.sentence_encoder.SentenceEncoder

Constraint using similarity between sentence encodings of x and x_adv where the text embeddings are created using the Multilingual Universal Sentence Encoder.

encode(sentences)[source]

Encodes a list of sentences.

To be implemented by subclasses.

universal sentence encoder class

class textattack.constraints.semantics.sentence_encoders.universal_sentence_encoder.universal_sentence_encoder.UniversalSentenceEncoder(threshold=0.8, large=False, metric='angular', **kwargs)[source]

Bases: textattack.constraints.semantics.sentence_encoders.sentence_encoder.SentenceEncoder

Constraint using similarity between sentence encodings of x and x_adv where the text embeddings are created using the Universal Sentence Encoder.

encode(sentences)[source]

Encodes a list of sentences.

To be implemented by subclasses.