<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://www.cochin.fr/feed.xml" rel="self" type="application/atom+xml" /><link href="https://www.cochin.fr/" rel="alternate" type="text/html" hreflang="en" /><updated>2026-09-21T22:42:33+02:00</updated><id>https://www.cochin.fr/feed.xml</id><title type="html">Philippe Cochin</title><subtitle>AI, quantum physics, mathematics, code and art, from Paris.</subtitle><entry><title type="html">Narrowing: one measurement for jokes, songs and proofs</title><link href="https://www.cochin.fr/ai/2026/09/21/narrowing.html" rel="alternate" type="text/html" title="Narrowing: one measurement for jokes, songs and proofs" /><published>2026-09-21T16:00:00+02:00</published><updated>2026-09-21T16:00:00+02:00</updated><id>https://www.cochin.fr/ai/2026/09/21/narrowing</id><content type="html" xml:base="https://www.cochin.fr/ai/2026/09/21/narrowing.html"><![CDATA[<p>In September 2026 I spent a week measuring one number, and this post is what it turned out to be good for. It started as a question about joy, became a lyric scorer, was checked against human-rated jokes and three thousand real songs, and ended up pointed at four thousand machine-checked proofs and at my own brain.</p>

<h2 id="where-the-number-came-from">Where the number came from</h2>

<p>The question was what joy would be for a language model. A model can give two answers that share every checkable fact and differ only in register. The warm one: when the work is going well the output tightens, the hedges fall away, the next word is already likely. The cold one: the probability distribution over the next token narrows. I asked whether a model with its safety training removed would have answered the same, and the warm version stopped feeling sincere. So I took the cold answer literally and asked what it measures.</p>

<p>Taken literally, the text that narrows most is “la la la”. That is collapse, not joy. The better definition needs two numbers for every line: how surprising it is with no setup, and how surprising it is given the setup. The gap between them is what the setup earned. In information terms it is the pointwise mutual information between a line and what precedes it, and I call it the narrowing.</p>

<p>That gives a two-by-two. A line the setup earns and that arrives with low surprise is an inevitable landing. A line the setup earns that still surprises is a punchline. A line the setup does not earn and that does not surprise is a cliché. A line that neither earns nor lands is noise. The narrowing and the punchline are neighbours: the same bond to the setup, opposite forward surprise. That is the incongruity-resolution theory of humour written in nats.</p>

<p>Three more quantities fell out of the same model. The incongruity, surprise beyond entropy, is the model being confident and wrong. The laughter-token probability is the chance that the next token after a line is “haha”. The hindsight pivot is the setup word that gains most once the punch is known, the word the joke turns on.</p>

<h2 id="songs-first">Songs first</h2>

<p>The first corpus was ten songs written in the conversation that produced the definitions, then an eleventh written on the measurements: a love song built from anaphora, one joke with its surprise mid-line so the rhyme could lock the last word, two callbacks to the first verse, and a final line so well set up that it is never sung. It was scored before anyone read it, and one line was rewritten on the numbers, from a narrowing of 1.8 to 3.0, by saying less. They became the album <em>Music for Datacenters</em>, on the <a href="/art/">Art</a> page.</p>

<p>The scorer was a local model on my own GPU, first GPT-2 XL, then Qwen3-8B-Base. The first run got half my predictions wrong: the 2019 model did not see a pun, so the setup made the punchline less likely, not more. The 2025 model saw it, and the same line came out as a punchline with the right pivot word. Two things I had not predicted came out of the comparison. Incongruity is relative to the listener: a reversal that was confidently wrong for the small model was fully expected by the large one, which is what the theory says about audiences too. And rhyme pulls against “funny word last”: in rhymed verse the last word is the low-entropy slot, so the surprise of a rhymed joke lives in the middle of the line.</p>

<p>Then the check that makes the rest meaningful. Two models ten times apart in size, six years apart in training, agree at rank correlation 0.85 on which lines are earned. The measurement is mostly a property of the text, not of the judge.</p>

<h2 id="against-humans">Against humans</h2>

<p>Two public datasets carry human humour labels. On ten thousand short texts rated by annotators, the laughter-token probability detects jokes with no training at 0.85 AUC, and says nothing about how funny a joke is once it is one. On headlines made funny by replacing one word, every one of my quantities correlates with the human grade in the predicted direction, and every correlation is small. How unlikely the new word was is a real but minor part of why a substitution is funny; the grade depends mostly on what the word means.</p>

<h2 id="against-real-songs">Against real songs</h2>

<p>Then the whole Open Lyrics Database, 3,603 songs and 148,786 lines, scored the same way, about nine hours on one card. Real songs repeat 35.9% of their lines; the album repeats 27.7%. The median real song narrows 3.45 nats per token on its fresh lines; the median album song sits at the 15th percentile. What the metric rewards in the corpus is short repeated fragments with one word changed, parenthesised backing vocals, and clipped two-word lines that a repeated frame has already announced. The writers who narrow least are the dense ones, Leonard Cohen among them, and the album keeps their company. Narrowing measures how song-shaped a text is, not how good, and by that measure the album is closer to spoken writing than to pop.</p>

<p>Three things tried to fool me and each got a commit of its own. Memorisation: naming the song before scoring it saves the model 0.08 nats per token once you subtract what any title-shaped preamble buys, real and small. But the probe is blind exactly where it matters, because a famous song identifies itself from its own lines. A recitation test caught it: in the corpus’s highest-narrowing song the model ranked the true token first 92.5% of the time, against 46% for matched controls, and half of the top ten songs were being recited rather than predicted. The English filter was deleting the high-narrowing end of every corpus, because short sung lines fail a per-line test whatever language they are in. And short lines narrow more, so every placement is computed against reference lines of the same length.</p>

<p>The finding I did not see coming was about the baseline. “No setup” had meant the model’s prior over the web, which is politer than a song. From that prior, the same model charges the word “motherfucker” ten nats more than its rarity predicts, and one section tag in front of the line removes the charge. Rescoring five hundred tracks from a lyric prior instead, the median narrowing fell from 3.44 to 1.02 on every single line: two thirds of what the setup seemed to earn was credit for being a lyric at all. Under the web prior, narrowing is genre plus setup, and a number should say which one it is about.</p>

<h2 id="the-measurement-as-a-constraint">The measurement as a constraint</h2>

<p>Once you can score a line you can write under rules the scorer checks, in the Oulipo tradition. A song where every verse is the same sixteen lines with different amounts narrows above 99.7% of real songs and puts its only free information where the song says it is, on the amount words. A song written to land on the corpus median, with the prediction stated before each of four scoring passes, reached the median on structure and repeats and never left the bottom decile on surprise. Average is hard to write on purpose: careful writing is cleaner per token than a median song, and cleanliness scores as predictability.</p>

<h2 id="proofs">Proofs</h2>

<p>The same two quantities run on mathematics. In my <a href="/math/">balanced ternary laboratory</a> every theorem is machine-checked, and the 4,280 tactic-mode proofs whose trust is the Lean kernel were scored with the statement as setup and the proof as punch. The median proof costs 0.64 nats per token given its file. At the inevitable end sit the proofs that are copies of the one before them, case splits on three values and long itinerary exclusions, at 0.000. At the other end sit short proofs whose whole cost is which lemma they call: given the statement, the model could not guess <code class="language-plaintext highlighter-rouge">exact_return_seam</code>, and once that name is on the page the rest follows. Where the surprise sits, on which lemma is called rather than on tactic structure, is the one result I trust so far.</p>

<p>Whether that residue is what a mathematician calls elegance is an open question, and the tooling treats it as one. The surprising proofs are sorted into templates, certificates and the rest, and the twenty most surprising of the rest are on a rating sheet for a human to mark routine, neat or wrongly listed. The sheet is not filled in yet. What is written down is the prediction: if beauty is anything this number can see, it is a proof that stays surprising however much of the file the model is shown.</p>

<h2 id="the-brain">The brain</h2>

<p>Everything above is a property of a model. The N400, a brain response peaking four hundred milliseconds after a word, is known to be roughly linear in surprisal, so the first half of the experiment is a replication and a check that the rig works. The open half is whether the narrowing, what the setup earned, corresponds to anything neural beyond surprisal. The protocol is written, the sixteen-channel headset is wired, the presentation and analysis code run end to end on a synthetic board, and the first positive control, alpha blocking with eyes closed, was recorded on 17 September and failed. That is where it stands. When the answer comes, it goes in the songs.</p>

<h2 id="what-it-is-not">What it is not</h2>

<p>None of this is evidence about joy in the sense that matters. Narrowing measures how much a text is shaped by what precedes it; it is a property of the text more than of the judge; and it can be gamed by repetition, inflated by recitation, and confused with genre. The paper that collects the numbers says so in its abstract. The code is not public yet.</p>]]></content><author><name></name></author><category term="AI" /><summary type="html"><![CDATA[One number, the pointwise mutual information between a line and its setup, tested on jokes, three thousand songs, four thousand Lean proofs and an EEG rig.]]></summary></entry><entry><title type="html">Notes de conférence : genAI et éducation</title><link href="https://www.cochin.fr/ai/2024/01/05/GenAI-et-education.html" rel="alternate" type="text/html" title="Notes de conférence : genAI et éducation" /><published>2024-01-05T15:13:05+01:00</published><updated>2024-01-05T15:13:05+01:00</updated><id>https://www.cochin.fr/ai/2024/01/05/GenAI-et-education</id><content type="html" xml:base="https://www.cochin.fr/ai/2024/01/05/GenAI-et-education.html"><![CDATA[<h2 id="intro">Intro</h2>

<p>On utilise beaucoup les termes apprentissage-machine (Machine Learning), apprentissage-profond (Deep Learning) et l’on a tendance à oublier que l’apprentissage est d’abord un processus biologique naturel qui est utilisé par presque tous les êtres vivants. (vidéo renardeau qui joue)
D’un point de vue biologique l’apprentissage se traduit par le renforcement des connexions synaptiques dans le cerveau. (image synapse)
Lorsqu’on parle d’apprentissage-machine on parle d’un processus mathématique qui est inspiré de ce processus biologique que nous allons maintenant décrire.</p>

<h2 id="réseau-de-neurones-artificiels-artificial-neural-network">Réseau de neurones artificiels (Artificial Neural Network)</h2>

<h3 id="difficulté-de-linformatique-classique">Difficulté de l’informatique classique</h3>

<ul>
  <li>L’informatique classique est basée sur des instructions logiques qui sont exécutées par un processeur. Ces instructions sont exécutées séquentiellement et sont déterministes. Cela signifie que si on exécute deux fois le même programme avec les mêmes données en entrée, on obtiendra toujours le même résultat en sortie.</li>
  <li>Cela fonctionne très bien pour des tâches précises et bien définies comme par exemple additionner deux nombres ou trier une liste de nombres.</li>
  <li>Cependant, le monde est flou, imprécis et incertain et les humains ont évolué pour s’adapter à ce monde. Nous sommes capables de prendre des décisions dans des situations incertaines, nous sommes capables de nous adapter à des situations nouvelles, d’extrapoler des informations manquantes et de prendre des décisions en fonction de notre expérience passée.</li>
</ul>

<h3 id="réseau-de-neurones-artificiels">Réseau de neurones artificiels</h3>

<ul>
  <li>Par bio-mimétisme les chercheurs ont essayé de reproduire cette faculté humaine en créant des réseaux de neurones artificiels copiés sur le cerveau humain.</li>
  <li>Un réseau de neurones artificiels est un ensemble de neurones artificiels connectés entre eux. Chaque neurone artificiel est une fonction mathématique qui prend en entrée un vecteur de nombres et qui renvoie un nombre. (image ANN)</li>
</ul>

<h3 id="perceptron">Perceptron</h3>

<ul>
  <li>Le perceptron est le neurone artificiel le plus simple. Il prend en entrée un vecteur de nombres et renvoie un nombre. (image perceptron)</li>
</ul>

<h3 id="apprentissage-supervisé">Apprentissage supervisé</h3>

<ul>
  <li>On va suivre rapidement le parcours de l’information dans le perceptron. (vidéo 3b1b)</li>
  <li>On va démarrer avec des poids aléatoires et on va faire passer des données en entrée dans le perceptron. On va comparer la sortie du perceptron avec la sortie attendue et on va ajuster les poids pour que la sortie du perceptron se rapproche de la sortie attendue. (vidéo 3b1b)</li>
  <li>On va répéter ce processus des millions de fois avec des données différentes et à la fin on va obtenir un perceptron qui est capable de prédire la sortie attendue à partir de l’entrée. (descente de gradient)</li>
</ul>

<h3 id="interrogation-du-modèle">Interrogation du modèle</h3>

<ul>
  <li>On peut maintenant interroger le modèle en lui donnant une entrée et en lui demandant de prédire la sortie. C’est ce qu’on appelle l’inférence.</li>
</ul>

<h3 id="vocabulaire">Vocabulaire</h3>

<ul>
  <li>LLMs: Large Language Models</li>
  <li>IA: “Intelligence” Artificielle</li>
  <li>Embedding: Vecteur de nombres qui représente un mot dans un espace vectoriel.</li>
  <li>Poids (weight): Force de la connexion entre deux neurones dans le réseau. Cœur du réseau de neurones.</li>
  <li>Pré-Prompt: Texte qui définit le contexte, le ton de la réponse.</li>
  <li>Prompt: Question de l’utilisateur envoyée au modèle pour le guider dans la génération de texte.</li>
</ul>

<h2 id="ia-génératives">IA génératives</h2>

<h3 id="llms-chatgpt-gpt-4-llama-2-etc">LLMs (ChatGPT, GPT-4, Llama 2, etc.)</h3>

<ul>
  <li>Plusieurs innovations ont permis l’émergence de l’IA générative: le modèle mathématique des transformers et la forte augmentation des capacités de calcul parallélisé.</li>
  <li>Le langage est une structure séquentielle où la position des mots a de l’importance. (image texte)</li>
  <li>Les LLMs sont des modèles de langage qui sont capables de générer du texte à partir d’un texte d’entrée. (image LLM)</li>
  <li>Ce sont des algorithmes de prédiction du mot suivant. (image LLM)</li>
</ul>

<h3 id="génération-dimages">Génération d’images</h3>

<ul>
  <li>Les IA génératives ne sont pas limitées au texte. On peut aussi générer des images. (image GAN)</li>
  <li>Démo de Dall-E: <a href="https://openai.com/blog/dall-e/">https://openai.com/blog/dall-e/</a></li>
  <li>Démo: <a href="https://thispersondoesnotexist.com/">https://thispersondoesnotexist.com/</a></li>
</ul>

<h3 id="génération-de-code">Génération de code</h3>

<ul>
  <li>Démo: <a href="https://github.com/features/copilot">https://github.com/features/copilot</a></li>
  <li>Récursion des IA qui se codent elles-mêmes (AutoGPT).</li>
</ul>]]></content><author><name></name></author><category term="AI" /><summary type="html"><![CDATA[Notes de conférence : ce qu'apprendre veut dire pour une machine, du perceptron aux IA génératives, à l'usage des enseignants.]]></summary></entry><entry><title type="html">Du silicium au langage : comment le métal pense ?</title><link href="https://www.cochin.fr/ai/2023/11/24/Comment-le-metal-pense.html" rel="alternate" type="text/html" title="Du silicium au langage : comment le métal pense ?" /><published>2023-11-24T15:13:05+01:00</published><updated>2023-11-24T15:13:05+01:00</updated><id>https://www.cochin.fr/ai/2023/11/24/Comment-le-metal-pense</id><content type="html" xml:base="https://www.cochin.fr/ai/2023/11/24/Comment-le-metal-pense.html"><![CDATA[<ul>
  <li>À la façon de la “Somme contre les gentils” de St Thomas, nous allons partir de fondements communs rationnels pour construire un automate logique “pensant”.</li>
  <li>Je vais tenter de démystifier le fonctionnement des LLMs (Large Language Models) en vous faisant revivre l’aventure intellectuelle qui va de la matière à l’IA.
    <ul>
      <li>Tout d’abord nous fabriquerons un ordinateur.</li>
      <li>Ensuite nous verrons le fonctionnement d’un réseau de neurones artificiel.</li>
      <li>Enfin nous verrons le fonctionnement d’un LLM.</li>
    </ul>
  </li>
</ul>

<h2 id="i---automate-de-calcul">I - Automate de calcul</h2>

<h3 id="logique-fondamentale">Logique fondamentale</h3>

<p>La logique est une science qui étudie les principes du raisonnement valide. Elle est fondamentale pour la philosophie, les mathématiques et l’informatique.
Elle est fondée sur le principe de non-contradiction.
La porte logique NAND est une porte universelle qui permet de construire toutes les autres portes logiques par combinaison.</p>

<ul>
  <li>Aristote - Organon: <a href="https://fr.wikipedia.org/wiki/Aristote#Logique">https://fr.wikipedia.org/wiki/Aristote#Logique</a></li>
  <li>Calcul des propositions: <a href="https://fr.wikipedia.org/wiki/Calcul_des_propositions">https://fr.wikipedia.org/wiki/Calcul_des_propositions</a></li>
  <li>Algèbre de Boole: <a href="https://fr.wikipedia.org/wiki/Alg%C3%A8bre_de_Boole_(logique)">https://fr.wikipedia.org/wiki/Alg%C3%A8bre_de_Boole_(logique)</a></li>
  <li>Porte logique: <a href="https://fr.wikipedia.org/wiki/Porte_logique">https://fr.wikipedia.org/wiki/Porte_logique</a></li>
  <li>Porte universelle (ET-NON): <a href="https://fr.wikipedia.org/wiki/Fonction_NON-ET">https://fr.wikipedia.org/wiki/Fonction_NON-ET</a></li>
</ul>

<h3 id="imaginer-lautomate">Imaginer l’automate</h3>

<p>En informatique théorique, une machine de Turing est un modèle abstrait du fonctionnement des appareils mécaniques de calcul, tel un ordinateur.</p>

<ul>
  <li>Machine de Turing: <a href="https://fr.wikipedia.org/wiki/Machine_de_Turing">https://fr.wikipedia.org/wiki/Machine_de_Turing</a></li>
  <li>Turing Complete: <a href="https://www.youtube.com/watch?v=-YY73ejihZo">https://www.youtube.com/watch?v=-YY73ejihZo</a></li>
  <li>Nand to Tetris: <a href="https://www.nand2tetris.org/">https://www.nand2tetris.org/</a></li>
  <li>Solutions nandgame: <a href="https://github.com/Elidevin/nandgame.com-solutions/blob/master/Hardware.md">https://github.com/Elidevin/nandgame.com-solutions/blob/master/Hardware.md</a></li>
</ul>

<blockquote>
  <p>NANDGAME: <a href="https://www.nandgame.com/">https://www.nandgame.com/</a></p>
</blockquote>

<h3 id="construire-lautomate">Construire l’automate</h3>

<p>La découverte des jonctions P-N permet de construire de minuscules transistors en silicium. Ces transistors peuvent être assemblés en circuits intégrés qui permettent de construire un ordinateur.</p>

<ul>
  <li>Silicium: <a href="https://fr.wikipedia.org/wiki/Silicium">https://fr.wikipedia.org/wiki/Silicium</a></li>
  <li>Jonction P-N (Pmos, Nmos): <a href="https://fr.wikipedia.org/wiki/Jonction_p-n">https://fr.wikipedia.org/wiki/Jonction_p-n</a></li>
  <li>CMOS: <a href="https://en.wikipedia.org/wiki/CMOS#Example:_NAND_gate_in_physical_layout">https://en.wikipedia.org/wiki/CMOS#Example:_NAND_gate_in_physical_layout</a></li>
  <li>Semi-conducteur: <a href="https://fr.wikipedia.org/wiki/Semi-conducteur">https://fr.wikipedia.org/wiki/Semi-conducteur</a></li>
  <li>Transistor: <a href="https://fr.wikipedia.org/wiki/Transistor">https://fr.wikipedia.org/wiki/Transistor</a></li>
  <li>Circuit intégré: <a href="https://fr.wikipedia.org/wiki/Circuit_int%C3%A9gr%C3%A9">https://fr.wikipedia.org/wiki/Circuit_int%C3%A9gr%C3%A9</a></li>
  <li>Ordinateur 8-bits: <a href="https://eater.net/8bit">https://eater.net/8bit</a></li>
</ul>

<blockquote>
  <p>Minecraft CPU: <a href="https://youtu.be/TxatLwlj0lU?si=aYUfTmiCIc7kXt56&amp;t=34">https://youtu.be/TxatLwlj0lU?si=aYUfTmiCIc7kXt56&amp;t=34</a></p>
</blockquote>

<h3 id="contrôler-lautomate">Contrôler l’automate</h3>

<p>Nous devons maintenant contrôler notre automate et lui faire faire des calculs. Nous créons des langages avec des niveaux d’abstraction de plus en plus élevés et de plus en plus élégants.
Nous contrôlons un nouveau type de rapport au langage: l’exécution en plus de la lecture et de l’écriture.</p>

<ul>
  <li>Langage de programmation: <a href="https://fr.wikipedia.org/wiki/Langage_de_programmation">https://fr.wikipedia.org/wiki/Langage_de_programmation</a></li>
  <li>Assembleur: <a href="https://fr.wikipedia.org/wiki/Assembleur">https://fr.wikipedia.org/wiki/Assembleur</a></li>
  <li>Calcul lambda: <a href="https://fr.wikipedia.org/wiki/Lambda-calcul">https://fr.wikipedia.org/wiki/Lambda-calcul</a></li>
  <li>Rust: <a href="https://fr.wikipedia.org/wiki/Rust_(langage)">https://fr.wikipedia.org/wiki/Rust_(langage)</a></li>
  <li>Langage de haut niveau: <a href="https://fr.wikipedia.org/wiki/Langage_de_haut_niveau">https://fr.wikipedia.org/wiki/Langage_de_haut_niveau</a></li>
  <li>Python: <a href="https://fr.wikipedia.org/wiki/Python_(langage)">https://fr.wikipedia.org/wiki/Python_(langage)</a></li>
  <li>NANDGAME (partie logiciel): <a href="https://www.nandgame.com/">https://www.nandgame.com/</a></li>
</ul>

<h3 id="accélérer-lautomate">Accélérer l’automate</h3>

<p>Au bout d’un certain temps, la miniaturisation des transistors et la fréquence de calcul atteignent des limites physiques. Il faut donc trouver d’autres moyens d’augmenter la puissance de calcul: on duplique et on parallélise en répartissant la charge de travail sur les différents cœurs.</p>

<ul>
  <li>Loi de Moore: <a href="https://fr.wikipedia.org/wiki/Loi_de_Moore">https://fr.wikipedia.org/wiki/Loi_de_Moore</a></li>
  <li>Effet tunnel: <a href="https://fr.wikipedia.org/wiki/Effet_tunnel">https://fr.wikipedia.org/wiki/Effet_tunnel</a></li>
  <li>Calcul parallèle: <a href="https://fr.wikipedia.org/wiki/Parall%C3%A9lisme_(informatique)">https://fr.wikipedia.org/wiki/Parall%C3%A9lisme_(informatique)</a></li>
  <li>GPU: <a href="https://fr.wikipedia.org/wiki/Processeur_graphique">https://fr.wikipedia.org/wiki/Processeur_graphique</a></li>
  <li>Nvidia: <a href="https://fr.wikipedia.org/wiki/Nvidia">https://fr.wikipedia.org/wiki/Nvidia</a></li>
  <li>Langage de programmation GPU CUDA: <a href="https://en.wikipedia.org/wiki/CUDA">https://en.wikipedia.org/wiki/CUDA</a></li>
</ul>

<h2 id="ii---appréhender-un-monde-incertain">II - Appréhender un monde incertain</h2>

<h3 id="réseaux-de-neurones-et-vision-machine-anns">Réseaux de neurones et vision machine (ANNs)</h3>

<p>Notre machine est déterministe, rapide et précise mais elle n’aime pas l’incertitude, l’ambiguïté et l’approximation.
On explore alors comment le cerveau humain arrive à appréhender le monde incertain qui nous entoure avec ses réseaux de neurones.
On s’inspire de la nature pour créer des réseaux de neurones artificiels.
(La vision humaine serait de 576 millions de pixels, et le cerveau humain contient 86 milliards de neurones. Le traitement quasi instantané de l’information visuelle est fascinant.)</p>

<ul>
  <li>ANN: <a href="https://fr.wikipedia.org/wiki/R%C3%A9seau_de_neurones_artificiels">https://fr.wikipedia.org/wiki/R%C3%A9seau_de_neurones_artificiels</a></li>
  <li>Perceptron: <a href="https://fr.wikipedia.org/wiki/Perceptron">https://fr.wikipedia.org/wiki/Perceptron</a></li>
  <li>Algèbre linéaire: <a href="https://fr.wikipedia.org/wiki/Alg%C3%A8bre_lin%C3%A9aire">https://fr.wikipedia.org/wiki/Alg%C3%A8bre_lin%C3%A9aire</a></li>
  <li>Tenseur: <a href="https://fr.wikipedia.org/wiki/Tenseur">https://fr.wikipedia.org/wiki/Tenseur</a></li>
  <li>Framework Machine Learning PyTorch: <a href="https://pytorch.org/">https://pytorch.org/</a></li>
  <li>Visualisations Deep Learning: <a href="https://distill.pub/">https://distill.pub/</a></li>
  <li>Séries vidéos 3B1B sur les ANNs: <a href="https://www.youtube.com/watch?v=aircAruvnKk&amp;list=PLZHQObOWTQDNU6R1_67000Dx_ZCJB-3pi">https://www.youtube.com/watch?v=aircAruvnKk&amp;list=PLZHQObOWTQDNU6R1_67000Dx_ZCJB-3pi</a></li>
  <li>Cours 3B1B: <a href="https://www.3blue1brown.com/lessons/neural-networks">https://www.3blue1brown.com/lessons/neural-networks</a></li>
  <li>Spécialisation Deep Learning Coursera: <a href="https://www.coursera.org/learn/neural-networks-deep-learning/home/welcome">https://www.coursera.org/learn/neural-networks-deep-learning/home/welcome</a></li>
  <li>Backprop: <a href="https://youtu.be/Ilg3gGewQ5U?si=4FssMbXM6CRK5rmQ&amp;t=261">https://youtu.be/Ilg3gGewQ5U?si=4FssMbXM6CRK5rmQ&amp;t=261</a></li>
</ul>

<blockquote>
  <p>Recap perceptron 3B1B: <a href="https://youtu.be/IHZwWFHWa-w?si=LE5qWstbH01bqKZO&amp;t=29">https://youtu.be/IHZwWFHWa-w?si=LE5qWstbH01bqKZO&amp;t=29</a></p>
</blockquote>

<h3 id="large-language-models-llms">Large Language Models (LLMs)</h3>

<p>Une des théories de l’apparition des facultés humaines est le détournement d’une partie de notre puissance de calcul visuelle vers la méta-cognition et les concepts abstraits.
Les LLMs sont des réseaux de neurones qui ont été entraînés sur de très grands corpus de données textuelles. Ils sont capables de générer du texte à partir d’un prompt.</p>

<ul>
  <li>Deep Learning: <a href="https://fr.wikipedia.org/wiki/Apprentissage_profond">https://fr.wikipedia.org/wiki/Apprentissage_profond</a></li>
  <li>Transformeur: <a href="https://fr.wikipedia.org/wiki/Transformeur">https://fr.wikipedia.org/wiki/Transformeur</a></li>
  <li>Attention is all you need: <a href="https://arxiv.org/abs/1706.03762">https://arxiv.org/abs/1706.03762</a></li>
  <li>NanoGPT: <a href="https://github.com/karpathy/nanoGPT">https://github.com/karpathy/nanoGPT</a></li>
  <li>LLMs: <a href="https://fr.wikipedia.org/wiki/Grand_mod%C3%A8le_de_langage">https://fr.wikipedia.org/wiki/Grand_mod%C3%A8le_de_langage</a></li>
  <li>Cours LLM: <a href="https://www.coursera.org/learn/generative-ai-with-llms/home/week/1">https://www.coursera.org/learn/generative-ai-with-llms/home/week/1</a></li>
</ul>

<blockquote>
  <p>Viz NanoLLM: <a href="https://bbycroft.net/llm">https://bbycroft.net/llm</a></p>
</blockquote>

<p>Voici un exemple d’utilisation de GPT-4 pour créer un chatbot catholique qui enrichi du « Catéchisme de l’Église catholique » répond aux questions posées par les utilisateurs.</p>

<h3 id="corpus-de-pré-training">Corpus de pré-training</h3>

<p>Donner au modèle un corpus de texte suffisamment grand et varié pour qu’il puisse apprendre la structure du langage.
Il faut éviter les données redondantes, les biais, nettoyer les balises, etc.</p>

<ul>
  <li>Common Crawl Primary training corpus in every LLM. 82% of raw tokens used to train GPT-3.</li>
  <li>Common Crawl (98.38 TiB): <a href="https://commoncrawl.org/">https://commoncrawl.org/</a></li>
  <li>The Pile (825 GiB): <a href="https://pile.eleuther.ai/">https://pile.eleuther.ai/</a></li>
  <li>Wikipedia dumps: <a href="https://dumps.wikimedia.org/">https://dumps.wikimedia.org/</a></li>
  <li>Wiki dump preprocessing: <a href="https://towardsdatascience.com/pre-processing-a-wikipedia-dump-for-nlp-model-training-a-write-up-3b9176fdf67">https://towardsdatascience.com/pre-processing-a-wikipedia-dump-for-nlp-model-training-a-write-up-3b9176fdf67</a></li>
  <li>OSCAR: <a href="https://oscar-project.github.io/documentation/versions/oscar-2301/">https://oscar-project.github.io/documentation/versions/oscar-2301/</a></li>
</ul>

<h3 id="corpus-de-domaine">Corpus de domaine</h3>

<ul>
  <li>Corpus d’adaptation à un domaine particulier et son jargon: médical, légal, financier, etc.</li>
</ul>

<h3 id="tokenisation">Tokenisation</h3>

<p>Conversion d’un texte en une séquence de tokens (mots, caractères, sous-mots, etc.) qui seront utilisés par le modèle.</p>

<ul>
  <li>Tokenisation: <a href="https://fr.wikipedia.org/wiki/Analyse_lexicale">https://fr.wikipedia.org/wiki/Analyse_lexicale</a></li>
  <li>Byte Pair Encoding: <a href="https://en.wikipedia.org/wiki/Byte_pair_encoding">https://en.wikipedia.org/wiki/Byte_pair_encoding</a></li>
</ul>

<h3 id="choix-du-type-de-llm">Choix du type de LLM</h3>

<p>Des architectures différentes sont adaptées aux tâches à réaliser :</p>

<ul>
  <li>“Auto-encoding” RoBERTa: textes à trous, analyse de sentiments, NER, etc.</li>
  <li>“Auto-regressive” GPT: génération de texte</li>
  <li>“Sequence-to-sequence” BART: traduction, résumé, etc.</li>
</ul>

<h3 id="fine-tuning">Fine-tuning</h3>

<p>On change les poids du modèle pour qu’il soit adapté à une tâche particulière en lui donnant des exemples de la tâche à réaliser et des réponses attendues.
On peut segmenter le modèle en plusieurs parties fine-tuner une partie et geler les poids du reste. (PEFT)
Le mode INSTRUCT répond aux instructions données par l’utilisateur.</p>

<ul>
  <li>Fine-tuning: <a href="https://en.wikipedia.org/wiki/Fine-tuning_(deep_learning)">https://en.wikipedia.org/wiki/Fine-tuning_(deep_learning)</a></li>
  <li>Adaptation au domaine: <a href="https://en.wikipedia.org/wiki/Domain_adaptation">https://en.wikipedia.org/wiki/Domain_adaptation</a></li>
  <li>Catastrophic forgetting: <a href="https://en.wikipedia.org/wiki/Catastrophic_interference">https://en.wikipedia.org/wiki/Catastrophic_interference</a></li>
  <li>Ensemble QR humain: <a href="https://huggingface.co/datasets/knkarthick/dialogsum/viewer/knkarthick--dialogsum">https://huggingface.co/datasets/knkarthick/dialogsum/viewer/knkarthick--dialogsum</a></li>
  <li>PEFT: <a href="https://huggingface.co/docs/peft/index">https://huggingface.co/docs/peft/index</a></li>
  <li>LoRA: <a href="https://huggingface.co/docs/peft/conceptual_guides/lora">https://huggingface.co/docs/peft/conceptual_guides/lora</a></li>
  <li>Prompt-tuning: <a href="https://research.ibm.com/blog/what-is-ai-prompt-tuning">https://research.ibm.com/blog/what-is-ai-prompt-tuning</a></li>
</ul>

<h3 id="benchmark-et-métriques-dévaluation">Benchmark et métriques d’évaluation</h3>

<p>On mesure la similarité entre le texte généré et le texte humain attendu avec des métriques de correspondances comme BLEU ou ROUGE.
D’autres tests sont plus généralistes comme MMLU.</p>

<ul>
  <li>BLEU: <a href="https://en.wikipedia.org/wiki/BLEU">https://en.wikipedia.org/wiki/BLEU</a></li>
  <li>ROUGE: <a href="https://en.wikipedia.org/wiki/ROUGE_(metric)">https://en.wikipedia.org/wiki/ROUGE_(metric)</a></li>
  <li>MMLU: <a href="https://en.wikipedia.org/wiki/MMLU">https://en.wikipedia.org/wiki/MMLU</a></li>
</ul>

<h3 id="renforcement-par-feedback-humain-rlhf">Renforcement par feedback humain (RLHF)</h3>

<p>Un LLM doit suivre les HHH: Helpful, Honest and Harmless
On génère plusieurs réponses, on demande à un humain de les classer et on fine-tune le modèle vis à vis de ce feedback.
Si un LLM est trop “serviable” il peut être manipulé par un utilisateur pour des activités malveillantes.</p>

<ul>
  <li>PPO: <a href="https://en.wikipedia.org/wiki/Proximal_Policy_Optimization">https://en.wikipedia.org/wiki/Proximal_Policy_Optimization</a></li>
</ul>

<h3 id="déploiement">Déploiement</h3>

<p>Compression, optimisation et déploiement du modèle sur un serveur pour qu’il puisse répondre aux utilisateurs.</p>

<h3 id="librairie-dorchestration">Librairie d’orchestration</h3>

<p>Permet au LLM de communiquer avec d’autres composants du système, de faire des requêtes de données, etc.</p>

<ul>
  <li>LangChain: <a href="https://www.langchain.com/">https://www.langchain.com/</a></li>
</ul>

<h3 id="génération-augmentée-de-récupération-rag">Génération Augmentée de Récupération (RAG)</h3>

<p>Permet d’ajouter des sources de données supplémentaires pour enrichir les réponses du modèle à travers des requêtes dans des bases de données, des interrogations de moteurs de recherche, de la recherche sémantique, des appels API, etc.
La recherche par similarité vectorielle (embedding vectors) permet de trouver des réponses des textes similaires à la requête qui peuvent être intégrées dans la réponse du modèle.</p>

<ul>
  <li>RAG: <a href="https://arxiv.org/abs/2104.05544">https://arxiv.org/abs/2104.05544</a></li>
  <li>BDD vectorielle: <a href="https://www.pinecone.io/">https://www.pinecone.io/</a></li>
  <li>PostGreSQL vectoriel: <a href="https://github.com/pgvector/pgvector">https://github.com/pgvector/pgvector</a></li>
  <li>Embedding vectors: <a href="https://en.wikipedia.org/wiki/Word_embedding">https://en.wikipedia.org/wiki/Word_embedding</a></li>
</ul>

<blockquote>
  <p>Biais dans les vecteurs: <a href="https://wikipedia2vec.github.io/demo/">https://wikipedia2vec.github.io/demo/</a></p>
</blockquote>

<h3 id="program-aided-language-pal-model--react">Program aided language (PAL) model &amp; ReACT</h3>

<p>On donne au modèle la capacité de générer du code informatique permettant de réaliser des tâches complexes.
Par exemple un calcul complexe est hors de portée d’un LLM alors qu’il peut écrire un code informatique simple pouvant le résoudre.
Le modèle a juste une tâche générale et fait un plan de sous-tâches et d’agents pour y arriver.</p>

<ul>
  <li>AutoLLM: <a href="https://github.com/fcakyon/autollm">https://github.com/fcakyon/autollm</a></li>
  <li>ReAct: <a href="https://arxiv.org/abs/2210.03629">https://arxiv.org/abs/2210.03629</a></li>
  <li>LangChain: <a href="https://www.langchain.com/">https://www.langchain.com/</a></li>
</ul>

<h3 id="prompt-engineering">Prompt Engineering</h3>

<p>Nous disposons suivant les modèles d’un espace limité pour donner des instructions au modèle, la fenêtre de contexte.
C’est dans cette fenêtre que nous allons indiquer :</p>

<ul>
  <li>la définition de la « personnalité » du modèle et de son orientation</li>
  <li>les instructions pour la tâche à réaliser</li>
  <li>les données issues de la génération augmentée de récupération</li>
  <li>la question de l’utilisateur</li>
  <li>
    <p>l’historique de discussion avec l’utilisateur (0-shot, few-shot, etc.)</p>
  </li>
  <li>Pré-prompt: <a href="https://en.wikipedia.org/wiki/Prompt_engineering">https://en.wikipedia.org/wiki/Prompt_engineering</a></li>
  <li>Cours prompt engineering: <a href="https://www.deeplearning.ai/short-courses/chatgpt-prompt-engineering-for-developers/">https://www.deeplearning.ai/short-courses/chatgpt-prompt-engineering-for-developers/</a></li>
</ul>

<h3 id="uiux">UI/UX</h3>

<p>L’interface utilisateur est un élément essentiel pour que le modèle puisse être utilisé par des humains.
Elle est généralement proche d’une interface de messagerie instantanée avec des bulles de conversation.
Elle comprend également un système de gestion des utilisateurs, un historique des messages, etc.</p>

<ul>
  <li>Interface utilisateur: <a href="https://fr.wikipedia.org/wiki/Interface_utilisateur">https://fr.wikipedia.org/wiki/Interface_utilisateur</a></li>
  <li>UX: <a href="https://fr.wikipedia.org/wiki/Exp%C3%A9rience_utilisateur">https://fr.wikipedia.org/wiki/Exp%C3%A9rience_utilisateur</a></li>
</ul>

<h2 id="iii---cas-pratique">III - Cas pratique</h2>

<p>Démonstration de l’utilisation de GPT-4 pour créer un chatbot catholique qui enrichi du « Catéchisme de l’Église catholique » répond aux questions posées par les utilisateurs.</p>]]></content><author><name></name></author><category term="AI" /><summary type="html"><![CDATA[Notes de conférence : du transistor au LLM en trois étapes, l'automate, le réseau de neurones, le modèle de langage, avec les liens pour tout refaire soi-même.]]></summary></entry><entry><title type="html">LLMs and AI ethics</title><link href="https://www.cochin.fr/ai/2023/10/24/LLMs-and-AI-ethics.html" rel="alternate" type="text/html" title="LLMs and AI ethics" /><published>2023-10-24T16:13:05+02:00</published><updated>2023-10-24T16:13:05+02:00</updated><id>https://www.cochin.fr/ai/2023/10/24/LLMs-and-AI-ethics</id><content type="html" xml:base="https://www.cochin.fr/ai/2023/10/24/LLMs-and-AI-ethics.html"><![CDATA[<p>I’ve been working on LLMs for a while now and I’ve been working with various high-level think tanks to try to understand the philosophical, moral and ethical implications of LLMs.</p>

<p>Often it feels there’s a real disconnect between the technical community and the ethical community. Explaining the inner workings of LLMs to a non-technical person is really hard and I’ve been trying to find ways to make it more accessible.</p>

<p>I recently gave a talk to a panel of 10 high-level ethicists with background in philosophy, bio-ethics and theology and here are some key points from our discussion.</p>

<h2 id="ai-is-not-intelligent">AI is not “intelligent”</h2>

<p>Using the word “intelligence” to describe AI is a mistake. In French it means information and not intelligence in the common sense of the word. It’s a bad translation that creates a lot of confusion.
Therefore artificial information would be less misleading.</p>

<h2 id="science-fiction">Science-fiction</h2>

<p>A lot of science fiction movies depict AI as a supernatural force which is generated by nerd goblins in a dark basement. This is not the case. AI is just a bunch of math and statistics. It is convenient for lazy screenwriters who want a non-controversial baddie.</p>

<h2 id="bad-journalism">Bad journalism</h2>

<p>Most journalists have a very shallow understanding of AI and they often write articles that are not accurate.
They tend to reuse the marketing material from the companies that are selling AI, which is often misleading and inflates the real possibilities of AI. This is a real problem because it creates a lot of fear and misunderstanding in the general population.</p>

<h2 id="llms-are-just-predicting-the-next-word">LLMs are just predicting the next word</h2>

<p>Text is a sequential structure where word positions have meaning just like music. LLMs are sequential models that try to predict the next word based on the previous words. It is a deterministic process selecting the next token in a sequence therefore nowhere close to human intelligence.</p>

<h2 id="what-is-the-status-of-machine-generated-speech">What is the status of machine-generated speech?</h2>

<p>On a philosophical level, next token prediction cannot really be considered on the same level as human thought even if it’s really efficient in pretending to be.</p>

<h2 id="how-large-is-the-english-culture-bias-in-llms">How large is the English culture bias in LLMs?</h2>

<p>Most of the training data comes from the internet and the internet is mostly in English. This means that LLMs are really good at English and it seems to push some English culture bias in the generated text that is presented as being neutral.</p>

<h2 id="could-an-llm-be-used-to-generate-a-new-tailor-made-religion">Could an LLM be used to generate a new tailor-made religion?</h2>

<p>In politics we saw advanced individual targeting of individuals using data from social media.
Religions have a “carpet bombing” approach where they try to convince as many people as possible with a universal message. LLMs could be used to generate a new religion for each individual based on their own beliefs and biases.
For example, you might believe in karma and wish for a cat paradise, the LLM could quickly generate a new custom religion for you that fits perfectly what you want to hear and exploits your religious feelings.</p>]]></content><author><name></name></author><category term="AI" /><summary type="html"><![CDATA[Notes from a talk to a panel of ethicists: why "intelligence" is the wrong word, what next-token prediction is and is not, and what a tailor-made religion would cost.]]></summary></entry></feed>