MCPcopy
hub / github.com/QData/TextAttack / EmbeddingAugmenter

Class EmbeddingAugmenter

textattack/augmentation/recipes.py:118–128  ·  view source on GitHub ↗

Augments text by transforming words with their embeddings.

Source from the content-addressed store, hash-verified

116
117
118class EmbeddingAugmenter(Augmenter):
119 """Augments text by transforming words with their embeddings."""
120
121 def __init__(self, **kwargs):
122 from textattack.transformations import WordSwapEmbedding
123
124 transformation = WordSwapEmbedding(max_candidates=50)
125 from textattack.constraints.semantics import WordEmbeddingDistance
126
127 constraints = DEFAULT_CONSTRAINTS + [WordEmbeddingDistance(min_cos_sim=0.8)]
128 super().__init__(transformation, constraints=constraints, **kwargs)
129
130
131class CharSwapAugmenter(Augmenter):

Callers 1

test_embedding_augmenterFunction · 0.90

Calls

no outgoing calls

Tested by 1

test_embedding_augmenterFunction · 0.72