textattack.constraints.semantics.sentence_encoders.bert package


BERT for Sentence Similarity

class textattack.constraints.semantics.sentence_encoders.bert.bert.BERT(threshold=0.7, metric='cosine', model_name='bert-base-nli-stsb-mean-tokens', **kwargs)[source]

Bases: SentenceEncoder

Constraint using similarity between sentence encodings of x and x_adv where the text embeddings are created using BERT, trained on NLI data, and fine- tuned on the STS benchmark dataset. Available models can be found here: https://huggingface.co/sentence-transformers


Encodes a list of sentences.

To be implemented by subclasses.