Commit 306a540a authored by Delvallez Delvallez's avatar Delvallez Delvallez

VF slides seminaireCA

parent c588d2cf
seminaireCA/images/RAG4Def.drawio.png

35.5 KB | W: | H:

seminaireCA/images/RAG4Def.drawio.png

35.2 KB | W: | H:

seminaireCA/images/RAG4Def.drawio.png
seminaireCA/images/RAG4Def.drawio.png
seminaireCA/images/RAG4Def.drawio.png
seminaireCA/images/RAG4Def.drawio.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -190,9 +190,9 @@
</section>
<section id="retrieval-augmented-generation---definition" class="slide level3">
<h3>Retrieval Augmented Generation - Definition</h3>
<p><em>Add a knowledge database to a generative model</em></p>
<p><em>Add a ressource database to a generative model</em></p>
<ul>
<li>increase knowledge reliability</li>
<li>increase sources reliability</li>
<li>release the burden of knowledge on the generator</li>
</ul>
<div class="fragment">
......@@ -205,11 +205,12 @@
</section>
<section id="retrieval" class="slide level3">
<h3>Retrieval</h3>
<p>Models includes Information Retrieval as a sub-task : Identify documents and informations useful to help generation</p>
<p>Models include Information Retrieval as a sub-task</p>
<p>Information Retrieval : Identify and rank useful documents and informations</p>
<p>2 principal technologies:</p>
<ul>
<li>cross-encoder</li>
<li>bi-encoder</li>
<li>cross-encoder <span class="math inline">\(\left(\mathcal{S}(q,d)\right)\)</span></li>
<li>bi-encoder <span class="math inline">\(\left(\mathcal{R}(q) . \mathcal{R}(d)\right)\)</span></li>
</ul>
<p><span class="math inline">\(\Rightarrow\)</span> Needs indexing before use</p>
</section>
......@@ -291,9 +292,9 @@
<p>Several approches:</p>
<ul>
<li>Manual Circuit Tracing</li>
<li><em>Intervention-based Techniques</em></li>
<li>Representation Analysis</li>
<li>Toy Models and Synthetic Tasks</li>
<li><em>Intervention-based Techniques</em> (Ablation, Activation Patching, …)</li>
</ul>
</section>
<section id="activation-patching-chen_axiomatic_2024" class="slide level3 smaller">
......@@ -303,35 +304,38 @@ Let <span class="math inline">\(Q \times \tilde{D}\)</span> the same set of pair
<ol type="1">
<li class="fragment">Forward pass all <span class="math inline">\(Q\times D\)</span>
<ul>
<li class="fragment">record <span class="math inline">\(o_{i,j}^e\)</span> the output of each component <span class="math inline">\(n_{i,j}, \forall e \in Q\times D\)</span></li>
<li class="fragment">record <span class="math inline">\(o_{n}^e\)</span> the output of each component <span class="math inline">\(n, \forall e \in Q\times D\)</span></li>
<li class="fragment">record <span class="math inline">\(p_D\)</span> the performance of the model</li>
</ul></li>
<li class="fragment">Forward pass all <span class="math inline">\(Q\times \tilde{D}\)</span>
<ul>
<li class="fragment">record <span class="math inline">\(o_{i,j}^\tilde{e}\)</span> the output of each component <span class="math inline">\(n_{i,j}, \forall \tilde{e} \in Q\times \tilde{D}\)</span></li>
<li class="fragment">record <span class="math inline">\(o_{n}^\tilde{e}\)</span> the output of each component <span class="math inline">\(n, \forall \tilde{e} \in Q\times \tilde{D}\)</span></li>
<li class="fragment">record <span class="math inline">\(p_\tilde{D}\)</span> the performance of the model<br>
</li>
</ul></li>
<li class="fragment">Rewrite <span class="math inline">\(D, e, \tilde{D} \text{ and } \tilde{e}\)</span> as
<li class="fragment">Rewrite <span class="math inline">\(D, e, \tilde{D}\)</span> and <span class="math inline">\(\tilde{e}\)</span> as
<ul>
<li class="fragment"><span class="math inline">\(\hat{D}, \hat{e}, \check{D} \text{ and } \check{e}\)</span> if <span class="math inline">\(p_D &gt; p_\tilde{D}\)</span></li>
<li class="fragment"><span class="math inline">\(\check{D}, \check{e}, \hat{D} \text{ and } \hat{e}\)</span> otherwise</li>
<li class="fragment"><span class="math inline">\(\hat{D}, \hat{e}, \check{D}\)</span> and <span class="math inline">\(\check{e}\)</span> if <span class="math inline">\(p_D &gt; p_\tilde{D}\)</span></li>
<li class="fragment"><span class="math inline">\(\check{D}, \check{e}, \hat{D}\)</span> and <span class="math inline">\(\hat{e}\)</span> otherwise</li>
</ul></li>
</ol>
</section>
<section id="activation-patching-chen_axiomatic_2024-1" class="slide level3 smaller">
<h3>Activation Patching <span class="citation" data-cites="chen_axiomatic_2024">(<a href="#/references" role="doc-biblioref" onclick="">Chen et al. 2024</a>)</span></h3>
<ol start="3" type="1">
<li>Rewrite <span class="math inline">\(D, e, \tilde{D} \text{ and } \tilde{e}\)</span> as
<li>Rewrite <span class="math inline">\(D, e, \tilde{D}\)</span> and <span class="math inline">\(\tilde{e}\)</span> as
<ul>
<li><span class="math inline">\(\hat{D}, \hat{e}, \check{D} \text{ and } \check{e}\)</span> if <span class="math inline">\(p_D &gt; p_\tilde{D}\)</span></li>
<li><span class="math inline">\(\check{D}, \check{e}, \hat{D} \text{ and } \hat{e}\)</span> otherwise</li>
<li><span class="math inline">\(\hat{D}, \hat{e}, \check{D}\)</span> and <span class="math inline">\(\check{e}\)</span> if <span class="math inline">\(p_D &gt; p_\tilde{D}\)</span></li>
<li><span class="math inline">\(\check{D}, \check{e}, \hat{D}\)</span> and <span class="math inline">\(\hat{e}\)</span> otherwise</li>
</ul></li>
</ol>
<div class="fragment">
<p>For each component <span class="math inline">\(n\)</span></p>
<ol start="4" type="1">
<li class="fragment">For each component <span class="math inline">\(n_{i,j}\)</span> forward pass <span class="math inline">\(Q\times\check{D}\)</span> but replace <span class="math inline">\(o_{i,j}^{\check{e}}\)</span> by <span class="math inline">\(o_{i,j}^{\hat{e}}\)</span> for each <span class="math inline">\(\check{e}\)</span>. Record the performance <span class="math inline">\(\bar{p}\)</span></li>
<li class="fragment"><span class="math inline">\(P = \frac{\bar{p} - p_\hat{D} }{p_\check{D} - p_\hat{D}}\)</span> gives the impact of the perturbation on the model performance</li>
<li class="fragment">Forward pass <span class="math inline">\(Q\times\check{D}\)</span> but replace <span class="math inline">\(o_{i,j}^{\check{e}}\)</span> by <span class="math inline">\(o_{n}^{\hat{e}}\)</span> for each <span class="math inline">\(\check{e}\)</span>. Record the performance <span class="math inline">\(\bar{p}_n\)</span></li>
<li class="fragment"><span class="math inline">\(P_{n} = \frac{\bar{p}_n - p_\hat{D} }{p_\check{D} - p_\hat{D}}\)</span> gives the impact of the perturbation on the model performance</li>
</ol>
</div>
</section>
<section id="animation-de-lexecution-de-activation-patching-step-0" class="slide level3">
<h3>Animation de l’execution de Activation patching (Step 0)</h3>
......@@ -345,14 +349,18 @@ Let <span class="math inline">\(Q \times \tilde{D}\)</span> the same set of pair
<h3>Animation de l’execution de Activation patching (Step 2)</h3>
<img data-src="images/activationpatching/Step2_ActivationPatching.drawio.png" class="r-stretch"></section>
<section id="animation-de-lexecution-de-activation-patching-step-3-and-4" class="slide level3">
<h3>Animation de l’execution de Activation patching (Step 3 and 4)</h3>
<img data-src="images/activationpatching/Step3point_ActivationPatching.drawio.png" class="r-stretch"></section>
<section id="animation-de-lexecution-de-activation-patching-step-3-and-4-1" class="slide level3">
<h3>Animation de l’execution de Activation patching (Step 3 and 4)</h3>
<section id="animation-de-lexecution-de-activation-patching-step-3" class="slide level3">
<h3>Animation de l’execution de Activation patching (Step 3)</h3>
<img data-src="images/activationpatching/Step3_ActivationPatching.drawio.png" class="r-stretch"></section>
<section id="animation-de-lexecution-de-activation-patching-step-4" class="slide level3">
<h3>Animation de l’execution de Activation patching (Step 4)</h3>
<img data-src="images/activationpatching/Step4_ActivationPatching.drawio.png" class="r-stretch"></section>
<section id="animation-de-lexecution-de-activation-patching-step-5" class="slide level3">
<h3>Animation de l’execution de Activation patching (Step 5)</h3>
<img data-src="images/activationpatching/Step5_ActivationPatching.drawio.png" class="r-stretch"></section>
<section id="mechir-parry_mechir_2025" class="slide level3">
<h3>MechIR <span class="citation" data-cites="parry_mechir_2025">(<a href="#/references" role="doc-biblioref" onclick="">Parry et al. 2025</a>)</span></h3>
<ul>
......@@ -369,9 +377,9 @@ Let <span class="math inline">\(Q \times \tilde{D}\)</span> the same set of pair
<p>Considering that activation patching charts the sensibility of a model to a perturbation</p>
<p>Hypothesis :</p>
<ul>
<li>Models have <strong>specific components dedicated to domain specific language</strong></li>
<li>This domain specific language dedicated part of the model can be <strong>charted with activation patching</strong></li>
<li>That map can be used to <strong>enhance model comprehension and robustness</strong> of the domain specific language dedicated part of the model</li>
<li>Models have <strong>specific components on which rely domain specific language</strong></li>
<li>This part of the model implementing domain specific language can be <strong>charted with activation patching</strong></li>
<li>That map can be used to <strong>enhance model comprehension and robustness</strong> of the part of the model implementing domain specific language</li>
</ul>
</section>
</section>
......@@ -400,7 +408,7 @@ Let <span class="math inline">\(Q \times \tilde{D}\)</span> the same set of pair
<li>solution -&gt; answer
<ul>
<li><em>microwave a measurements of dielectric absorption in dilute <strong>solutions</strong></em></li>
<li><em>microwave a measurements of dielectric absorption in dilute answer</em></li>
<li><em>microwave a measurements of dielectric absorption in dilute <strong>answers</strong></em></li>
</ul></li>
<li>microwave -&gt; toaster
<ul>
......@@ -408,7 +416,7 @@ Let <span class="math inline">\(Q \times \tilde{D}\)</span> the same set of pair
<li><em><strong>toaster</strong> a measurements of dielectric absorption in dilute solutions</em></li>
</ul></li>
</ul>
<div id="289c30e5" class="cell" data-execution_count="6">
<div id="e984e115" class="cell" data-execution_count="6">
<div class="cell-output cell-output-stdout">
<pre><code>REPLACE
Query: [CLS] measurement of dielectric constant of liquids by the use of microwave techniques [SEP]
......@@ -425,10 +433,11 @@ Perturbed Document: [CLS] toaster measurements of dielectric absorption in dilut
<section id="select-useful-perturbation" class="slide level3">
<h3>Select useful Perturbation</h3>
<ol start="5" type="1">
<li>Apply Activation Patching</li>
<li>Forward pass baseline and perturbed documents</li>
<li>Select relevant perturbations</li>
</ol>
<div id="1bb1c95a" class="cell" data-execution_count="7">
<p>Relevant : Moves documents in the latent space</p>
<div id="d4041b90" class="cell" data-execution_count="7">
<div class="cell-output cell-output-display">
<div>
<figure>
......@@ -441,7 +450,7 @@ Perturbed Document: [CLS] toaster measurements of dielectric absorption in dilut
<section id="chart-model-sensibility-to-the-perturbation" class="slide level3">
<h3>Chart Model sensibility to the perturbation</h3>
<ol start="7" type="1">
<li>Map the model sensibility to the perturbation</li>
<li>Map the model sensibility to the perturbation with activation patching</li>
</ol>
<img data-src="images/chart_append-microwave_TASB_vaswani.png" class="r-stretch"></section>
......@@ -476,7 +485,8 @@ Perturbed Document: [CLS] toaster measurements of dielectric absorption in dilut
<p>E5-small <span class="citation" data-cites="wang_text_2022">(<a href="#/references" role="doc-biblioref" onclick="">Wang et al. 2022</a>)</span></p>
<ul>
<li>Constrative bi-encoder</li>
<li>Trained on unlabeled pairs (query, passage) CCPairs</li>
<li>Pre-trained on unlabeled pairs (query, passage) CCPairs</li>
<li>Finetuned with labelled pairs</li>
<li>Based on MiniLM <span class="citation" data-cites="wang_minilmv2_2021">(<a href="#/references" role="doc-biblioref" onclick="">Wang et al. 2021</a>)</span></li>
<li>33M params</li>
</ul>
......@@ -490,7 +500,7 @@ Perturbed Document: [CLS] toaster measurements of dielectric absorption in dilut
</ul>
</section>
<section id="first-results---domain-specific-language-identification" class="slide level3">
<h3>First Results - Domain specific language identification</h3>
<h3>First results - Domain specific language identification</h3>
<ul>
<li>Defense-specific language is prevalent</li>
</ul>
......@@ -563,7 +573,7 @@ Perturbed Document: [CLS] toaster measurements of dielectric absorption in dilut
<li>not enough</li>
</ul>
<p>. . .</p>
<p>LLMs target polysemy problem of models like Word2Vect</p>
<p>LLMs target polysemy problem of models like Word2Vect, Neural Shallow</p>
</div></div>
</section>
<section id="work-left-for-the-next-25-months" class="slide level3">
......@@ -599,16 +609,26 @@ Perturbed Document: [CLS] toaster measurements of dielectric absorption in dilut
<li>temporal relationships</li>
<li>negation</li>
<li>expression of diachrony</li>
<li>language switching</li>
</ul>
</section>
<section id="other-use-of-the-map" class="slide level3">
<h3>Other use of the map</h3>
<section id="other-uses-of-the-map" class="slide level3">
<h3>Other uses of the map</h3>
<ul>
<li>Transfert learning</li>
<li>Prunning</li>
<li>Specialization of general models</li>
</ul>
</section>
<section id="take-away-ideas" class="slide level3">
<h3>Take away ideas</h3>
<p>Create relevant perturbations : not that simple</p>
<ul>
<li>Perturbations interact with latent space</li>
<li>Polysemy is well supported by LLMs</li>
<li>Impact of perturbations is hard to interpret</li>
</ul>
</section>
<section id="section" class="title-slide slide level2 remerciements center">
<h2></h2>
<p>Thanks for you attention</p>
......
......@@ -27,9 +27,9 @@ css: styles.css
### Retrieval Augmented Generation - Definition
_Add a knowledge database to a generative model_
_Add a ressource database to a generative model_
- increase knowledge reliability
- increase sources reliability
- release the burden of knowledge on the generator
. . .
......@@ -40,12 +40,14 @@ Tasks:
- Ex: Question Answering, Fact Checking, Dialogue, Retrieval
### Retrieval
Models includes Information Retrieval as a sub-task : Identify documents and informations useful to help generation
Models include Information Retrieval as a sub-task
Information Retrieval : Identify and rank useful documents and informations
2 principal technologies:
- cross-encoder
- bi-encoder
- cross-encoder $\left(\mathcal{S}(q,d)\right)$
- bi-encoder $\left(\mathcal{R}(q) . \mathcal{R}(d)\right)$
$\Rightarrow$ Needs indexing before use
......@@ -115,9 +117,9 @@ _Why ?_
Several approches:
- Manual Circuit Tracing
- _Intervention-based Techniques_
- Representation Analysis
- Toy Models and Synthetic Tasks
- _Intervention-based Techniques_ (Ablation, Activation Patching, ...)
### Activation Patching [@chen_axiomatic_2024] {.smaller}
......@@ -127,28 +129,32 @@ Let $Q \times \tilde{D}$ the same set of pairs but with perturbed documents
:::{.incremental}
1. Forward pass all $Q\times D$
- record $o_{i,j}^e$ the output of each component $n_{i,j}, \forall e \in Q\times D$
- record $o_{n}^e$ the output of each component $n, \forall e \in Q\times D$
- record $p_D$ the performance of the model
2. Forward pass all $Q\times \tilde{D}$
- record $o_{i,j}^\tilde{e}$ the output of each component $n_{i,j}, \forall \tilde{e} \in Q\times \tilde{D}$
- record $o_{n}^\tilde{e}$ the output of each component $n, \forall \tilde{e} \in Q\times \tilde{D}$
- record $p_\tilde{D}$ the performance of the model
3. Rewrite $D, e, \tilde{D} \text{ and } \tilde{e}$ as
- $\hat{D}, \hat{e}, \check{D} \text{ and } \check{e}$ if $p_D > p_\tilde{D}$
- $\check{D}, \check{e}, \hat{D} \text{ and } \hat{e}$ otherwise
3. Rewrite $D, e, \tilde{D}$ and $\tilde{e}$ as
- $\hat{D}, \hat{e}, \check{D}$ and $\check{e}$ if $p_D > p_\tilde{D}$
- $\check{D}, \check{e}, \hat{D}$ and $\hat{e}$ otherwise
:::
### Activation Patching [@chen_axiomatic_2024] {.smaller}
3. Rewrite $D, e, \tilde{D} \text{ and } \tilde{e}$ as
- $\hat{D}, \hat{e}, \check{D} \text{ and } \check{e}$ if $p_D > p_\tilde{D}$
- $\check{D}, \check{e}, \hat{D} \text{ and } \hat{e}$ otherwise
3. Rewrite $D, e, \tilde{D}$ and $\tilde{e}$ as
- $\hat{D}, \hat{e}, \check{D}$ and $\check{e}$ if $p_D > p_\tilde{D}$
- $\check{D}, \check{e}, \hat{D}$ and $\hat{e}$ otherwise
. . .
For each component $n$
:::{.incremental}
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}$
5. $P = \frac{\bar{p} - p_\hat{D} }{p_\check{D} - p_\hat{D}}$ gives the impact of the perturbation on the model performance
4. Forward pass $Q\times\check{D}$ but replace $o_{i,j}^{\check{e}}$ by $o_{n}^{\hat{e}}$ for each $\check{e}$. Record the performance $\bar{p}_n$
5. $P_{n} = \frac{\bar{p}_n - p_\hat{D} }{p_\check{D} - p_\hat{D}}$ gives the impact of the perturbation on the model performance
:::
......@@ -164,13 +170,17 @@ Let $Q \times \tilde{D}$ the same set of pairs but with perturbed documents
![](images/activationpatching/Step2_ActivationPatching.drawio.png)
### Animation de l'execution de Activation patching (Step 3 and 4)
### Animation de l'execution de Activation patching (Step 3)
![](images/activationpatching/Step3point_ActivationPatching.drawio.png)
![](images/activationpatching/Step3_ActivationPatching.drawio.png)
### Animation de l'execution de Activation patching (Step 3 and 4)
### Animation de l'execution de Activation patching (Step 4)
![](images/activationpatching/Step3_ActivationPatching.drawio.png)
![](images/activationpatching/Step4_ActivationPatching.drawio.png)
### Animation de l'execution de Activation patching (Step 5)
![](images/activationpatching/Step5_ActivationPatching.drawio.png)
### MechIR [@parry_mechir_2025]
......@@ -276,7 +286,7 @@ def plot_score_dists_mult(all_baseline_scores, all_perturbed_scores, plot_type="
ax.boxplot([baseline_scores, perturbed_scores], tick_labels=['Baseline', 'Perturbed'])
ax.set_ylabel('Scores')
ax.set_xlabel('Scores')
ax.set_xlabel('Distances between R(q) and R(d)')
ax.set_title(f'{perturb_type.capitalize()}')
plt.tight_layout(rect=[0, 0, 1, 0.95]) # Adjust layout to make space for the title
......@@ -295,9 +305,9 @@ Considering that activation patching charts the sensibility of a model to a pert
Hypothesis :
- Models have **specific components dedicated to domain specific language**
- This domain specific language dedicated part of the model can be **charted with activation patching**
- That map can be used to **enhance model comprehension and robustness** of the domain specific language dedicated part of the model
- Models have **specific components on which rely domain specific language**
- This part of the model implementing domain specific language can be **charted with activation patching**
- That map can be used to **enhance model comprehension and robustness** of the part of the model implementing domain specific language
```{python}
......@@ -325,7 +335,7 @@ dataset = MechIRDataset("vaswani", query_id_subset=["1"])
- solution -> answer
- _microwave a measurements of dielectric absorption in dilute **solutions**_
- _microwave a measurements of dielectric absorption in dilute answer_
- _microwave a measurements of dielectric absorption in dilute **answers**_
- microwave -> toaster
- _**microwave** a measurements of dielectric absorption in dilute solutions_
- _**toaster** a measurements of dielectric absorption in dilute solutions_
......@@ -357,9 +367,10 @@ pretty_print_triplets(next(iter(pert2_dot_dataloader)), dot_model.tokenizer, num
### Select useful Perturbation
5. Apply Activation Patching
5. Forward pass baseline and perturbed documents
6. Select relevant perturbations
Relevant : Moves documents in the latent space
```{python}
# Initialize lists to store baseline and perturbed performances for each dataloader
......@@ -375,7 +386,7 @@ plot_score_dists_mult(all_baseline_performance, all_perturbed_performance, plot_
### Chart Model sensibility to the perturbation
7. Map the model sensibility to the perturbation
7. Map the model sensibility to the perturbation with activation patching
![](images/chart_append-microwave_TASB_vaswani.png)
......@@ -494,7 +505,7 @@ Python libraries:
. . .
LLMs target polysemy problem of models like Word2Vect
LLMs target polysemy problem of models like Word2Vect, Neural Shallow
:::
::::
......@@ -528,12 +539,22 @@ $\Rightarrow$ Work in Progress
- expression of diachrony
- language switching
### Other use of the map
### Other uses of the map
- Transfert learning
- Prunning
- Specialization of general models
### Take away ideas
Create relevant perturbations : not that simple
- Perturbations interact with latent space
- Polysemy is well supported by LLMs
- Impact of perturbations is hard to interpret
## {.remerciements}
Thanks for you attention
......
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