<p>The <code>SmoothGradient</code> interpreter adds random noise to embeddings. It is by design not deterministic. For details, you might have to read the paper: <a href="https://arxiv.org/abs/1706.03825" rel="nofollow noreferrer">https://arxiv.org/abs/1706.03825</a></p>
<p>If you need deterministic results, try <code>SimpleGradient</code> instead.</p>
Saliency score keeps changing allennlp
<p>I am trying to get the saliency score for sentiment analysis task. Every time I run the code I get different saliency scores. Should this be the case? I am attaching my code for more reference.</p>
<pre><code>from allennlp.predictors.predictor import Predictor
import nltk
from allennlp.interpret.saliency_interpreters import SmoothGradient


data = &quot;purchase costume year old grandson halloween arrive one week earlier expect happy grandson absolutely love glad order larger size size barely fit material durable well make think wear many time play since halloween happy purchase worth dollars spend&quot;

words = nltk.word_tokenize(data)

predictor = Predictor.from_path(&quot;https://storage.googleapis.com/allennlp-public-models/stanford-sentiment-treebank-roberta.2021-03-11.tar.gz&quot;)
predicted = predictor.predict(words)
saliency_scores = SmoothGradient(predictor).saliency_interpret_from_json({'sentence':words})
</code></pre>
<p>Every time I print saliency scores for the same data the values keep changing. Also the tokens that the model generates are distorted, for example halloween breaks into hall, ow and een. How can I fix this? Any help would be appreciated.</p>