textattack.constraints.semantics.sentence_encoders.bert package

sBERT

sBERT for Sentence Similarity

class textattack.constraints.semantics.sentence_encoders.sentence_bert.sbert.SBERT(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

encode(sentences)[source]

Encodes a list of sentences.

To be implemented by subclasses.