textattack.constraints.semantics.sentence_encoders.infer_sent package
infer sent
Submodules
infer sent for sentence similarity
- class textattack.constraints.semantics.sentence_encoders.infer_sent.infer_sent.InferSent(*args, **kwargs)[source]
Bases:
SentenceEncoderConstraint using similarity between sentence encodings of x and x_adv where the text embeddings are created using InferSent.
- get_infersent_model()[source]
Retrieves the InferSent model.
- Returns:
The pretrained InferSent model.
- MODEL_PATH = 'constraints/semantics/sentence-encoders/infersent-encoder'
- WORD_EMBEDDING_PATH = 'word_embeddings'
Infer sent model
This file contains the definition of encoders used in https://arxiv.org/pdf/1705.02364.pdf.
- class textattack.constraints.semantics.sentence_encoders.infer_sent.infer_sent_model.InferSentModel(config)[source]
Bases:
Module- forward(sent_tuple)[source]
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- training: bool