Fix pipeline words
Browse files- pipeline.py +1 -1
pipeline.py
CHANGED
@@ -41,7 +41,7 @@ class PreTrainedPipeline():
|
|
41 |
# Postprocess the embeddings to get the most similar words
|
42 |
similarities = distance.cdist(embeddings.reshape((1,300)), self.comparisons, "cosine")[0]
|
43 |
top_indices = similarities.argsort()[:10]
|
44 |
-
top_words = [
|
45 |
logits = np.exp(-10*np.array(similarities[top_indices]))
|
46 |
softmax_probs = tf.nn.softmax(logits).numpy()
|
47 |
top_scores = [round(float(softmax_probs[i]), 3) for i in range(10)]
|
|
|
41 |
# Postprocess the embeddings to get the most similar words
|
42 |
similarities = distance.cdist(embeddings.reshape((1,300)), self.comparisons, "cosine")[0]
|
43 |
top_indices = similarities.argsort()[:10]
|
44 |
+
top_words = [self.id2h[str(top_indices[i])] for i in range(10)]
|
45 |
logits = np.exp(-10*np.array(similarities[top_indices]))
|
46 |
softmax_probs = tf.nn.softmax(logits).numpy()
|
47 |
top_scores = [round(float(softmax_probs[i]), 3) for i in range(10)]
|