|
5 | 5 | "id": "african-verse",
|
6 | 6 | "metadata": {},
|
7 | 7 | "source": [
|
| 8 | + |
8 | 9 | "<img width=\"150\" alt=\"Logo_ER10\" src=\"https://user-images.githubusercontent.com/3244249/151994514-b584b984-a148-4ade-80ee-0f88b0aefa45.png\">\n",
|
9 | 10 | "\n",
|
10 |
| - "## Interpreting a movie review sentiment model with RISE\n", |
| 11 | + "### Interpreting a movie review sentiment model with RISE\n", |
| 12 | + |
11 | 13 | "This notebook demonstrates the use of DIANNA with the RISE method on the [Stanford Sentiment Treebank dataset](https://nlp.stanford.edu/sentiment/index.html) which contains one-sentence movie reviews. See also [their paper](https://nlp.stanford.edu/~socherr/EMNLP2013_RNTN.pdf). A pre-trained neural network classifier is used, which identifies whether a movie review is positive or negative.\n",
|
12 | 14 | "\n",
|
13 | 15 | "RISE is short for Randomized Input Sampling for Explanation of Black-box Models. It estimates each word's relevance to the model's decision empirically by probing the model with randomly masked versions of the input image and obtaining the corresponding outputs. \n",
|
|
22 | 24 | "id": "a5cf6f82-c1c7-4814-ae0f-5a1c0b8578f6",
|
23 | 25 | "metadata": {},
|
24 | 26 | "source": [
|
25 |
| - "## 1. Imports and paths" |
| 27 | + "#### 1. Imports and paths" |
26 | 28 | ]
|
27 | 29 | },
|
28 | 30 | {
|
|
62 | 64 | "id": "bad4f5b1-6097-4ef3-98c4-78432ad640b0",
|
63 | 65 | "metadata": {},
|
64 | 66 | "source": [
|
65 |
| - "## 2. Loading the model\n", |
| 67 | + "#### 2. Loading the model\n", |
66 | 68 | "\n",
|
67 | 69 | "The classifier is stored in ONNX format. It accepts numerical tokens as input, and outputs a score between 0 and 1, where 0 means the review is negative and 1 that it is positive. \n",
|
68 | 70 | "Here we define a class to run the model, which accepts a sentence (i.e. string) as input instead and returns two classes: negative and positive."
|
|
139 | 141 | "id": "02ccb569-a2e9-41b3-a732-f6c31a929a90",
|
140 | 142 | "metadata": {},
|
141 | 143 | "source": [
|
142 |
| - "## 3. Applying RISE with DIANNA\n", |
| 144 | + "#### 3. Applying RISE with DIANNA\n", |
143 | 145 | "The simplest way to run DIANNA on text data is with `dianna.explain_text`. The arguments are:\n",
|
144 | 146 | "* The function that runs the model (a path to a model in ONNX format is also accepted)\n",
|
145 | 147 | "* The text we want to explain\n",
|
|
208 | 210 | "id": "7e177746-3654-4518-9c1c-b7047f922273",
|
209 | 211 | "metadata": {},
|
210 | 212 | "source": [
|
211 |
| - "### 4. Visualization\n", |
| 213 | + |
| 214 | + "#### 4. Visualization\n", |
212 | 215 | "DIANNA includes a visualization package, capable of highlighting each word of a text based on their relevance scores. The visualization is in HTML format.\n",
|
213 | 216 | "In this visualization, words in favour of the selected class are highlighted in red. Words against the selected class are not present in this example, otherwise they would be highlighted in blue."
|
| 217 | + |
214 | 218 | ]
|
215 | 219 | },
|
216 | 220 | {
|
|
0 commit comments