Commit 89bc660e authored by Delvallez Delvallez's avatar Delvallez Delvallez

netoyyage fichiers inutiles git

parent 2218e5d6
......@@ -12,7 +12,7 @@
# .html
# *_files
**/.jupyter_cache/
*.quarto_ipynb_*
*.quarto_ipynb*
# Document à cacher
seminaireCA/indications_oral.md
......
......@@ -443,7 +443,7 @@ Python libraries:
- MechIR [@parry_mechir_2025]
- TransformerLens [@nanda_transformerlens_2022]
### First Results - Domain specific language identification
### First results - Domain specific language identification
- Defense-specific language is prevalent
|Word |Frequency| TF-IDF score |
......
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"title: \"Mechanistic interpretability for enhancing RAG models\"\n",
"format: \n",
" revealjs:\n",
" toc: true\n",
" toc-depth: 2\n",
" code-fold: true\n",
" slide-level: 3\n",
" mouse-wheel: true\n",
"jupyter : python3\n",
"style: |\n",
" .columns {\n",
" display: grid;\n",
" grid-template-columns: repeat(2, minmax(0, 1fr));\n",
" gap: 1rem;\n",
" }\n",
" .small {\n",
" font-size: 20px\n",
" }\n",
" .midsize{\n",
" font-size: 25px\n",
" }\n",
"---\n",
"\n",
"## Retrieval Augmented Generation - RAG\n",
"\n",
"### Retrieval Augmented Generation - Definition\n",
"\n",
"![Simple RAG Architecture](images/DefRAG.drawio.png) \n",
"\n",
"![Advanced RAG Achitecture](images/DefRAGAvance_integration.drawio.png)\n",
"\n",
"\n",
"### Approche plus théorique de retriever et generateur\n",
"\n",
"_Retriever comme plongement des documents et questions dans un espace_\n",
"\n",
"_Generateur comme fonction d'une paire (question, ensemble de documents) vers texte_\n",
"\n",
"\n",
"\n",
"### Example\n",
"\n",
"![RAG Architecture used here](images/RAGHN-perso.drawio.png)\n",
"\n",
"## Explainability in Artificial Intelligence\n",
"\n",
"### Explainability in Artificial Intelligence\n",
"\n",
"Aims:\n",
"\n",
"- Trustability\n",
"- Understandability\n",
"- Model Rectification\n",
"\n",
"### Definitions\n",
"\n",
"**XAI** : Make model's behavior understandable for human [@bell_its_2022] \n",
"**Understand** : Predict model's behavior [@bell_its_2022] \n",
"**Explanation** : Any way to make decision process understandable for human\n",
"\n",
":::: {.columns}\n",
"\n",
"::: {.column width=\"40%\"}\n",
"**Interpretability** \n",
"_How ?_\n",
":::\n",
"\n",
"::: {.column width=\"40%\"}\n",
"\n",
"**Explanability** \n",
"_Why ?_\n",
":::\n",
"\n",
"::::\n",
"\n",
"## Explanation through creation of a model\n",
"\n",
"![Explanation through creation of a model](images/VieModele-TempsXAI.drawio.png)\n",
"\n",
"## MechIR [@parry_mechir_2025]\n",
"\n",
"### MechIR [@parry_mechir_2025]\n",
"\n",
"#### Mechanistic interpretability \n",
"Understand the internal mechanisms of neural networks by **performing causal interventions** on specific model components\n",
"\n",
"#### MechIR\n",
"- Encoder-only models \n",
"- For Information Retrieval models\n",
"\n",
"- Identify components responsible for some behavior\n",
"- Activation Patching Technique \n",
"\n",
"### Activation Patching [@chen_axiomatic_2024] {.smaller}\n",
"Let $Q \\times D \\subset \\mathcal{Q}\\times\\mathcal{D}$ be a set of pairs of questions and documents \n",
"Let $Q \\times \\tilde{D}$ the same set of pairs but with perturbed documents \n",
"\n",
"1. Forward pass all $Q\\times D$\n",
" - record $o_{i,j}^e$ the output of each component $n_{i,j}, \\forall e \\in Q\\times D$\n",
" - record $p_D$ the performance of the model\n",
"2. Forward pass all $Q\\times \\tilde{D}$\n",
" - record $o_{i,j}^\\tilde{e}$ the output of each component $n_{i,j}, \\forall \\tilde{e} \\in Q\\times \\tilde{D}$\n",
" - record $p_\\tilde{D}$ the performance of the model \n",
"3. Rewrite $D, e, \\tilde{D} \\text{ and } \\tilde{e}$ as\n",
"- $\\hat{D}, \\hat{e}, \\check{D} \\text{ and } \\check{e}$ if $p_D > p_\\tilde{D}$\n",
"- $\\check{D}, \\check{e}, \\hat{D} \\text{ and } \\hat{e}$ otherwise\n",
"4. For each component $n_{i,j}$ forward pass $Q\\times\\check{D}$ but replace $o_{i,j}^{\\check{e}}$ by $o_{i,j}^{\\hat{e}}$ for each $\\check{e}$. Record the performance $\\bar{p}$\n",
"5. $P = \\frac{\\bar{p} - p_\\hat{D} }{\\p_\\check{D} - p_\\hat{D}}$ gives the impact of the perturbation on the model performance\n",
"\n",
"\n",
"### Animation de l'execution de Activation patching\n",
"\n",
"### Perturbation\n",
"\n",
"Function that applies the same modification on each document.\n",
"Example : "
],
"id": "fa2ddf7d"
},
{
"cell_type": "code",
"metadata": {},
"source": [
"def perturbation(doc):\n",
" return doc.replace(\"microwave\", \"toaster\")"
],
"id": "2898ee6e",
"execution_count": null,
"outputs": []
},
{
"cell_type": "raw",
"metadata": {},
"source": [
"#### Perturbation creation technique\n",
"\n",
"- Identify vocabulary specific to the dataset \n",
"- find in the vocabulary words with several meaning $m_D$ and $m_D$\n",
"- Replace that word by a synonym of the $m_D$ meaning\n",
"\n",
"\n",
"### What is a good perturbation \n",
"\n",
"- Have an impact of the documents representation\n",
"_Des images de courbes à ajouter ici_\n",
"- Be useful for interpretation\n",
"\n",
"### Enhance a model with MechIR\n",
"TODO\n",
"\n",
"\n",
"---"
],
"id": "069b4e0f"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"# Brouillon\n",
"- Mechir\n",
" - but et concept : cartographier les sensibilités des modèles encoder-based \n",
" - Activation Patching [Chen et al,. 2024]\n",
" - Étapes\n",
" - recul sur le résultat obtenu\n",
" - Perturbation\n",
" - Definition\n",
" - approche de création par étude du vocabulaire important et utilisation des mots poly-sémantiques\n",
" - 3 types de perturbation (append, prepend, replace) -> préférer replace\n",
" - identifier une perturbation pertinente\n",
" - Améliorer le modèle\n",
" - Quelle modification effectuer?\n",
" - "
],
"id": "0253d293"
}
],
"metadata": {
"kernelspec": {
"name": "python3",
"language": "python",
"display_name": "Python 3 (ipykernel)",
"path": "/home/marine/miniconda3/share/jupyter/kernels/python3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
\ No newline at end of file
{
"cells": [
{
"cell_type": "markdown",
"id": "84d8a3bf",
"metadata": {},
"source": [
"---\n",
"title: \"Mechanistic interpretability for enhancing RAG models\"\n",
"format: \n",
" revealjs:\n",
" toc: true\n",
" toc-depth: 2\n",
" code-fold: true\n",
" slide-level: 3\n",
" mouse-wheel: true\n",
"jupyter : python3\n",
"style: |\n",
" .columns {\n",
" display: grid;\n",
" grid-template-columns: repeat(2, minmax(0, 1fr));\n",
" gap: 1rem;\n",
" }\n",
" .small {\n",
" font-size: 20px\n",
" }\n",
" .midsize{\n",
" font-size: 25px\n",
" }\n",
"---\n",
"\n",
"## Retrieval Augmented Generation - RAG\n",
"\n",
"### Retrieval Augmented Generation - Definition\n",
"\n",
"![Simple RAG Architecture](images/DefRAG.drawio.png) \n",
"\n",
"![Advanced RAG Achitecture](images/DefRAGAvance_integration.drawio.png)\n",
"\n",
"\n",
"### Approche plus théorique de retriever et generateur\n",
"\n",
"_Retriever comme plongement des documents et questions dans un espace_\n",
"\n",
"_Generateur comme fonction d'une paire (question, ensemble de documents) vers texte_\n",
"\n",
"\n",
"\n",
"### Example\n",
"\n",
"![RAG Architecture used here](images/RAGHN-perso.drawio.png)\n",
"\n",
"## Explainability in Artificial Intelligence\n",
"\n",
"### Explainability in Artificial Intelligence\n",
"\n",
"Aims:\n",
"\n",
"- Trustability\n",
"- Understandability\n",
"- Model Rectification\n",
"\n",
"### Definitions\n",
"\n",
"**XAI** : Make model's behavior understandable for human [@bell_its_2022] \n",
"**Understand** : Predict model's behavior [@bell_its_2022] \n",
"**Explanation** : Any way to make decision process understandable for human\n",
"\n",
":::: {.columns}\n",
"\n",
"::: {.column width=\"40%\"}\n",
"**Interpretability** \n",
"_How ?_\n",
":::\n",
"\n",
"::: {.column width=\"40%\"}\n",
"\n",
"**Explanability** \n",
"_Why ?_\n",
":::\n",
"\n",
"::::\n",
"\n",
"## Explanation through creation of a model\n",
"\n",
"![Explanation through creation of a model](images/VieModele-TempsXAI.drawio.png)\n",
"\n",
"## MechIR [@parry_mechir_2025]\n",
"\n",
"### MechIR [@parry_mechir_2025]\n",
"\n",
"#### Mechanistic interpretability \n",
"Understand the internal mechanisms of neural networks by **performing causal interventions** on specific model components\n",
"\n",
"#### MechIR\n",
"- Encoder-only models \n",
"- For Information Retrieval models\n",
"\n",
"- Identify components responsible for some behavior\n",
"- Activation Patching Technique \n",
"\n",
"### Activation Patching [@chen_axiomatic_2024] {.smaller}\n",
"Let $Q \\times D \\subset \\mathcal{Q}\\times\\mathcal{D}$ be a set of pairs of questions and documents \n",
"Let $Q \\times \\tilde{D}$ the same set of pairs but with perturbed documents \n",
"\n",
"1. Forward pass all $Q\\times D$\n",
" - record $o_{i,j}^e$ the output of each component $n_{i,j}, \\forall e \\in Q\\times D$\n",
" - record $p_D$ the performance of the model\n",
"2. Forward pass all $Q\\times \\tilde{D}$\n",
" - record $o_{i,j}^\\tilde{e}$ the output of each component $n_{i,j}, \\forall \\tilde{e} \\in Q\\times \\tilde{D}$\n",
" - record $p_\\tilde{D}$ the performance of the model \n",
"3. Rewrite $D, e, \\tilde{D} \\text{ and } \\tilde{e}$ as\n",
"- $\\hat{D}, \\hat{e}, \\check{D} \\text{ and } \\check{e}$ if $p_D > p_\\tilde{D}$\n",
"- $\\check{D}, \\check{e}, \\hat{D} \\text{ and } \\hat{e}$ otherwise\n",
"4. For each component $n_{i,j}$ forward pass $Q\\times\\check{D}$ but replace $o_{i,j}^{\\check{e}}$ by $o_{i,j}^{\\hat{e}}$ for each $\\check{e}$. Record the performance $\\bar{p}$\n",
"5. $P = \\frac{\\bar{p} - p_\\hat{D} }{\\p_\\check{D} - p_\\hat{D}}$ gives the impact of the perturbation on the model performance\n",
"\n",
"\n",
"### Animation de l'execution de Activation patching\n",
"\n",
"### Perturbation\n",
"\n",
"Function that applies the same modification on each document.\n",
"Example : "
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "d02801b1",
"metadata": {},
"outputs": [],
"source": [
"def perturbation(doc):\n",
" return doc.replace(\"microwave\", \"toaster\")"
]
},
{
"cell_type": "raw",
"id": "a4e2efff",
"metadata": {},
"source": [
"#### Perturbation creation technique\n",
"\n",
"- Identify vocabulary specific to the dataset \n",
"- find in the vocabulary words with several meaning $m_D$ and $m_D$\n",
"- Replace that word by a synonym of the $m_D$ meaning\n",
"\n",
"\n",
"### What is a good perturbation \n",
"\n",
"- Have an impact of the documents representation\n",
"_Des images de courbes à ajouter ici_\n",
"- Be useful for interpretation\n",
"\n",
"### Enhance a model with MechIR\n",
"TODO\n",
"\n",
"\n",
"---"
]
},
{
"cell_type": "markdown",
"id": "a80fea01",
"metadata": {},
"source": [
"---\n",
"# Brouillon\n",
"- Mechir\n",
" - but et concept : cartographier les sensibilités des modèles encoder-based \n",
" - Activation Patching [Chen et al,. 2024]\n",
" - Étapes\n",
" - recul sur le résultat obtenu\n",
" - Perturbation\n",
" - Definition\n",
" - approche de création par étude du vocabulaire important et utilisation des mots poly-sémantiques\n",
" - 3 types de perturbation (append, prepend, replace) -> préférer replace\n",
" - identifier une perturbation pertinente\n",
" - Améliorer le modèle\n",
" - Quelle modification effectuer?\n",
" - "
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3",
"path": "/home/marine/miniconda3/share/jupyter/kernels/python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"title: \"Mechanistic interpretability for enhancing RAG models\"\n",
"format: \n",
" revealjs:\n",
" toc: true\n",
" toc-depth: 2\n",
" code-fold: true\n",
" slide-level: 3\n",
" mouse-wheel: true\n",
"jupyter : python3\n",
"style: |\n",
" .columns {\n",
" display: grid;\n",
" grid-template-columns: repeat(2, minmax(0, 1fr));\n",
" gap: 1rem;\n",
" }\n",
" .small {\n",
" font-size: 20px\n",
" }\n",
" .midsize{\n",
" font-size: 25px\n",
" }\n",
"---\n",
"\n",
"## Retrieval Augmented Generation - RAG\n",
"\n",
"### Retrieval Augmented Generation - Definition\n",
"\n",
"![Simple RAG Architecture](images/DefRAG.drawio.png) \n",
"\n",
"![Advanced RAG Achitecture](images/DefRAGAvance_integration.drawio.png)\n",
"\n",
"\n",
"### Approche plus théorique de retriever et generateur\n",
"\n",
"_Retriever comme plongement des documents et questions dans un espace_\n",
"\n",
"_Generateur comme fonction d'une paire (question, ensemble de documents) vers texte_\n",
"\n",
"\n",
"\n",
"### Example\n",
"\n",
"![RAG Architecture used here](images/RAGHN-perso.drawio.png)\n",
"\n",
"## Explainability in Artificial Intelligence\n",
"\n",
"### Explainability in Artificial Intelligence\n",
"\n",
"Aims:\n",
"\n",
"- Trustability\n",
"- Understandability\n",
"- Model Rectification\n",
"\n",
"### Definitions\n",
"\n",
"**XAI** : Make model's behavior understandable for human [@bell_its_2022] \n",
"**Understand** : Predict model's behavior [@bell_its_2022] \n",
"**Explanation** : Any way to make decision process understandable for human\n",
"\n",
":::: {.columns}\n",
"\n",
"::: {.column width=\"40%\"}\n",
"**Interpretability** \n",
"_How ?_\n",
":::\n",
"\n",
"::: {.column width=\"40%\"}\n",
"\n",
"**Explanability** \n",
"_Why ?_\n",
":::\n",
"\n",
"::::\n",
"\n",
"## Explanation through creation of a model\n",
"\n",
"![Explanation through creation of a model](images/VieModele-TempsXAI.drawio.png)\n",
"\n",
"## MechIR [@parry_mechir_2025]\n",
"\n",
"### MechIR [@parry_mechir_2025]\n",
"\n",
"#### Mechanistic interpretability \n",
"Understand the internal mechanisms of neural networks by **performing causal interventions** on specific model components\n",
"\n",
"#### MechIR\n",
"- Encoder-only models \n",
"- For Information Retrieval models\n",
"\n",
"- Identify components responsible for some behavior\n",
"- Activation Patching Technique \n",
"\n",
"### Activation Patching [@chen_axiomatic_2024] {.smaller}\n",
"Let $Q \\times D \\subset \\mathcal{Q}\\times\\mathcal{D}$ be a set of pairs of questions and documents \n",
"Let $Q \\times \\tilde{D}$ the same set of pairs but with perturbed documents \n",
"\n",
"1. Forward pass all $Q\\times D$\n",
" - record $o_{i,j}^e$ the output of each component $n_{i,j}, \\forall e \\in Q\\times D$\n",
" - record $p_D$ the performance of the model\n",
"2. Forward pass all $Q\\times \\tilde{D}$\n",
" - record $o_{i,j}^\\tilde{e}$ the output of each component $n_{i,j}, \\forall \\tilde{e} \\in Q\\times \\tilde{D}$\n",
" - record $p_\\tilde{D}$ the performance of the model \n",
"3. Rewrite $D, e, \\tilde{D} \\text{ and } \\tilde{e}$ as\n",
"- $\\hat{D}, \\hat{e}, \\check{D} \\text{ and } \\check{e}$ if $p_D > p_\\tilde{D}$\n",
"- $\\check{D}, \\check{e}, \\hat{D} \\text{ and } \\hat{e}$ otherwise\n",
"4. For each component $n_{i,j}$ forward pass $Q\\times\\check{D}$ but replace $o_{i,j}^{\\check{e}}$ by $o_{i,j}^{\\hat{e}}$ for each $\\check{e}$. Record the performance $\\bar{p}$\n",
"5. $P = \\frac{\\bar{p} - p_\\hat{D} }{\\p_\\check{D} - p_\\hat{D}}$ gives the impact of the perturbation on the model performance\n",
"\n",
"\n",
"### Animation de l'execution de Activation patching\n",
"\n",
"### Perturbation\n",
"\n",
"Function that applies the same modification on each document. \n",
"Example : "
],
"id": "99dbc701"
},
{
"cell_type": "code",
"metadata": {},
"source": [
"#| echo: true\n",
"def perturbation(doc):\n",
" return doc.replace(\"microwave\", \"toaster\")"
],
"id": "a87c9cff",
"execution_count": null,
"outputs": []
},
{
"cell_type": "raw",
"metadata": {},
"source": [
"#### Perturbation creation technique\n",
"\n",
"- Identify vocabulary specific to the dataset \n",
"- find in the vocabulary words with several meaning $m_D$ and $m_D$\n",
"- Replace that word by a synonym of the $m_D$ meaning\n",
"\n",
"\n",
"### What is a good perturbation \n",
"\n",
"- Have an impact of the documents representation\n",
"_Des images de courbes à ajouter ici_\n",
"- Be useful for interpretation\n",
"\n",
"### Enhance a model with MechIR\n",
"TODO\n",
"\n",
"\n",
"---"
],
"id": "dab3024c"
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"# Brouillon\n",
"- Mechir\n",
" - but et concept : cartographier les sensibilités des modèles encoder-based \n",
" - Activation Patching [Chen et al,. 2024]\n",
" - Étapes\n",
" - recul sur le résultat obtenu\n",
" - Perturbation\n",
" - Definition\n",
" - approche de création par étude du vocabulaire important et utilisation des mots poly-sémantiques\n",
" - 3 types de perturbation (append, prepend, replace) -> préférer replace\n",
" - identifier une perturbation pertinente\n",
" - Améliorer le modèle\n",
" - Quelle modification effectuer?\n",
" - "
],
"id": "310e6897"
}
],
"metadata": {
"kernelspec": {
"name": "python3",
"language": "python",
"display_name": "Python 3 (ipykernel)",
"path": "/home/marine/miniconda3/share/jupyter/kernels/python3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
\ No newline at end of file
{
"cells": [
{
"cell_type": "markdown",
"id": "ba85654b",
"metadata": {},
"source": [
"---\n",
"title: \"Mechanistic interpretability for enhancing RAG models\"\n",
"format: \n",
" revealjs:\n",
" toc: true\n",
" toc-depth: 2\n",
" code-fold: true\n",
" slide-level: 3\n",
" mouse-wheel: true\n",
"jupyter : python3\n",
"style: |\n",
" .columns {\n",
" display: grid;\n",
" grid-template-columns: repeat(2, minmax(0, 1fr));\n",
" gap: 1rem;\n",
" }\n",
" .small {\n",
" font-size: 20px\n",
" }\n",
" .midsize{\n",
" font-size: 25px\n",
" }\n",
"---\n",
"\n",
"## Retrieval Augmented Generation - RAG\n",
"\n",
"### Retrieval Augmented Generation - Definition\n",
"\n",
"![Simple RAG Architecture](images/DefRAG.drawio.png) \n",
"\n",
"![Advanced RAG Achitecture](images/DefRAGAvance_integration.drawio.png)\n",
"\n",
"\n",
"### Approche plus théorique de retriever et generateur\n",
"\n",
"_Retriever comme plongement des documents et questions dans un espace_\n",
"\n",
"_Generateur comme fonction d'une paire (question, ensemble de documents) vers texte_\n",
"\n",
"\n",
"\n",
"### Example\n",
"\n",
"![RAG Architecture used here](images/RAGHN-perso.drawio.png)\n",
"\n",
"## Explainability in Artificial Intelligence\n",
"\n",
"### Explainability in Artificial Intelligence\n",
"\n",
"Aims:\n",
"\n",
"- Trustability\n",
"- Understandability\n",
"- Model Rectification\n",
"\n",
"### Definitions\n",
"\n",
"**XAI** : Make model's behavior understandable for human [@bell_its_2022] \n",
"**Understand** : Predict model's behavior [@bell_its_2022] \n",
"**Explanation** : Any way to make decision process understandable for human\n",
"\n",
":::: {.columns}\n",
"\n",
"::: {.column width=\"40%\"}\n",
"**Interpretability** \n",
"_How ?_\n",
":::\n",
"\n",
"::: {.column width=\"40%\"}\n",
"\n",
"**Explanability** \n",
"_Why ?_\n",
":::\n",
"\n",
"::::\n",
"\n",
"## Explanation through creation of a model\n",
"\n",
"![Explanation through creation of a model](images/VieModele-TempsXAI.drawio.png)\n",
"\n",
"## MechIR [@parry_mechir_2025]\n",
"\n",
"### MechIR [@parry_mechir_2025]\n",
"\n",
"#### Mechanistic interpretability \n",
"Understand the internal mechanisms of neural networks by **performing causal interventions** on specific model components\n",
"\n",
"#### MechIR\n",
"- Encoder-only models \n",
"- For Information Retrieval models\n",
"\n",
"- Identify components responsible for some behavior\n",
"- Activation Patching Technique \n",
"\n",
"### Activation Patching [@chen_axiomatic_2024] {.smaller}\n",
"Let $Q \\times D \\subset \\mathcal{Q}\\times\\mathcal{D}$ be a set of pairs of questions and documents \n",
"Let $Q \\times \\tilde{D}$ the same set of pairs but with perturbed documents \n",
"\n",
"1. Forward pass all $Q\\times D$\n",
" - record $o_{i,j}^e$ the output of each component $n_{i,j}, \\forall e \\in Q\\times D$\n",
" - record $p_D$ the performance of the model\n",
"2. Forward pass all $Q\\times \\tilde{D}$\n",
" - record $o_{i,j}^\\tilde{e}$ the output of each component $n_{i,j}, \\forall \\tilde{e} \\in Q\\times \\tilde{D}$\n",
" - record $p_\\tilde{D}$ the performance of the model \n",
"3. Rewrite $D, e, \\tilde{D} \\text{ and } \\tilde{e}$ as\n",
"- $\\hat{D}, \\hat{e}, \\check{D} \\text{ and } \\check{e}$ if $p_D > p_\\tilde{D}$\n",
"- $\\check{D}, \\check{e}, \\hat{D} \\text{ and } \\hat{e}$ otherwise\n",
"4. For each component $n_{i,j}$ forward pass $Q\\times\\check{D}$ but replace $o_{i,j}^{\\check{e}}$ by $o_{i,j}^{\\hat{e}}$ for each $\\check{e}$. Record the performance $\\bar{p}$\n",
"5. $P = \\frac{\\bar{p} - p_\\hat{D} }{\\p_\\check{D} - p_\\hat{D}}$ gives the impact of the perturbation on the model performance\n",
"\n",
"\n",
"### Animation de l'execution de Activation patching\n",
"\n",
"### Perturbation\n",
"\n",
"Function that applies the same modification on each document. \n",
"Example : "
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "70279707",
"metadata": {},
"outputs": [],
"source": [
"#| echo: true\n",
"def perturbation(doc):\n",
" return doc.replace(\"microwave\", \"toaster\")"
]
},
{
"cell_type": "raw",
"id": "d1b08c4e",
"metadata": {},
"source": [
"#### Perturbation creation technique\n",
"\n",
"- Identify vocabulary specific to the dataset \n",
"- find in the vocabulary words with several meaning $m_D$ and $m_D$\n",
"- Replace that word by a synonym of the $m_D$ meaning\n",
"\n",
"\n",
"### What is a good perturbation \n",
"\n",
"- Have an impact of the documents representation\n",
"_Des images de courbes à ajouter ici_\n",
"- Be useful for interpretation\n",
"\n",
"### Enhance a model with MechIR\n",
"TODO\n",
"\n",
"\n",
"---"
]
},
{
"cell_type": "markdown",
"id": "3f975028",
"metadata": {},
"source": [
"---\n",
"# Brouillon\n",
"- Mechir\n",
" - but et concept : cartographier les sensibilités des modèles encoder-based \n",
" - Activation Patching [Chen et al,. 2024]\n",
" - Étapes\n",
" - recul sur le résultat obtenu\n",
" - Perturbation\n",
" - Definition\n",
" - approche de création par étude du vocabulaire important et utilisation des mots poly-sémantiques\n",
" - 3 types de perturbation (append, prepend, replace) -> préférer replace\n",
" - identifier une perturbation pertinente\n",
" - Améliorer le modèle\n",
" - Quelle modification effectuer?\n",
" - "
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3",
"path": "/home/marine/miniconda3/share/jupyter/kernels/python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment