textattack.constraints.semantics.sentence_encoders.bert package

BERT

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: 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 BERT, trained on NLI data, and fine- tuned on the STS benchmark dataset. Available models can be found here: https://huggingface.co/sentence-transformers

encode(sentences)[source]

Encodes a list of sentences.

To be implemented by subclasses.