ChatPaper.aiChatPaper

Come i Concetti di Programmazione e i Neuroni Sono Condivisi nei Modelli Linguistici di Codice

How Programming Concepts and Neurons Are Shared in Code Language Models

June 1, 2025
Autori: Amir Hossein Kargaran, Yihong Liu, François Yvon, Hinrich Schütze
cs.AI

Abstract

Diversi studi hanno esplorato i meccanismi dei modelli linguistici di grandi dimensioni (LLM) nei compiti di codifica, ma la maggior parte si è concentrata sui linguaggi di programmazione (PL) in un contesto monolingue. In questo articolo, indaghiamo la relazione tra più PL e l'inglese nello spazio concettuale degli LLM. Eseguiamo un'attività di traduzione few-shot su 21 coppie di PL utilizzando due modelli basati su Llama. Decodificando gli embedding degli strati intermedi durante questa attività, osserviamo che lo spazio concettuale è più vicino all'inglese (inclusi i termini chiave dei PL) e assegna alte probabilità ai token inglesi nella seconda metà degli strati intermedi. Analizziamo le attivazioni dei neuroni per 11 PL e l'inglese, scoprendo che mentre i neuroni specifici per la lingua sono principalmente concentrati negli strati inferiori, quelli esclusivi per ciascun PL tendono a comparire negli strati superiori. Per i PL che sono altamente allineati con più altri PL, identificare neuroni specifici per la lingua non è fattibile. Questi PL tendono anche ad avere un insieme di termini chiave più ampio rispetto ad altri PL e sono più vicini allo spazio concettuale del modello indipendentemente dal PL di input/output nell'attività di traduzione. Le nostre scoperte forniscono approfondimenti su come gli LLM rappresentano internamente i PL, rivelando schemi strutturali nello spazio concettuale del modello. Il codice è disponibile all'indirizzo https://github.com/cisnlp/code-specific-neurons.
English
Several studies have explored the mechanisms of large language models (LLMs) in coding tasks, but most have focused on programming languages (PLs) in a monolingual setting. In this paper, we investigate the relationship between multiple PLs and English in the concept space of LLMs. We perform a few-shot translation task on 21 PL pairs using two Llama-based models. By decoding the embeddings of intermediate layers during this task, we observe that the concept space is closer to English (including PL keywords) and assigns high probabilities to English tokens in the second half of the intermediate layers. We analyze neuron activations for 11 PLs and English, finding that while language-specific neurons are primarily concentrated in the bottom layers, those exclusive to each PL tend to appear in the top layers. For PLs that are highly aligned with multiple other PLs, identifying language-specific neurons is not feasible. These PLs also tend to have a larger keyword set than other PLs and are closer to the model's concept space regardless of the input/output PL in the translation task. Our findings provide insights into how LLMs internally represent PLs, revealing structural patterns in the model's concept space. Code is available at https://github.com/cisnlp/code-specific-neurons.
PDF32June 3, 2025