Controlling the Text Generation of a Large Language Model in Multilingual Setting using Latent Space Steering
Loading...
URL
Journal Title
Journal ISSN
Volume Title
School of Science |
Master's thesis
Unless otherwise stated, all rights belong to the author. You may download, display and print this publication for Your own personal use. Commercial use is prohibited.
Authors
Date
2024-09-30
Department
Major/Subject
Machine Learning, Data Science and Artificial Intelligence (sivuaine)
Mcode
Degree programme
Master's Programme in Industrial Engineering and Management
Language
en
Pages
122
Series
Abstract
Numerous real-world applications of large language models (LLMs) require controlling the generated text to align with specific attributes. Furthermore, as LLMs are increasingly deployed in multilingual contexts, some completely new attributes emerge that must be controlled, along with novel challenges in controlling the same attributes as in English-specific settings. One of the new attributes that emerge is ensuring that the generated text is in a specific language. In this thesis, we show that a family of techniques referred to as latent space steering methods can be used to control the language of the text generated by an LLM, using Finnish and English as the case study. More specifically, we construct steering vectors from the intermediate representations of translation pairs and use these steering vectors to generate Finnish answers to challenging English questions, managing to shift the language in all responses to Finnish with a small degradation in the quality of the answers. In addition to ensuring that the generated text is in a specific language, another unique challenge to multilingual settings emerges from constructing the steering vectors for other attributes due to the creation requiring examples of the desired behaviour, which can be difficult to obtain with less represented languages. We provide one solution to this by showing that the effectiveness of some style steering vectors generalizes across languages. To demonstrate this, we use steering vectors for two styles constructed from English prompts to control the style of Finnish text generation. We observe that while there is a drop in the effectiveness of the steering vectors for the other style, the steering vectors for the other style achieve a near-perfect generalization performance. By further exploring these latent space steering methods in multilingual settings, we contribute to the important path of making the advancements in LLMs more accessible for the entire world.Monissa suurten kielimallien (LLM) sovelluksissa edellytetään, että tuotettu teksti vastaa ominaisuuksiltaan tiettyjä vaatimuksia. Suurten kielimallien yleistyessä monikielisissä ympäristöissä syntyy lisäksi joitakin täysin uusia vaatimuksia, joita tuotetun tekstin täytyy vastata sekä uusia haasteita aikaisempien vaatimusten täyttämisen kontrolloimisessa. Yksi näistä uusista vaatimuksista on se, että tuotettu teksti on halutulla kielellä. Tässä tutkielmassa osoitamme, että latenttiavaruuden ohjaukseksi kutsuttujen tekniikoiden avulla on mahdollista hallita LLM:n tuottaman tekstin kieltä käyttäen suomea ja englantia tapausesimerkkeinä. Tutkielmassa käännöspareista tuotetuilla ohjausvektoreilla ohjaamme kielimallia tuottamaan suomenkielisiä vastauksia mallille haastaviin englanninkielisiin kysymyksiin, ja onnistumme kääntämään jokaisen mallin tuottaman vastauksen kielen englannista suomeksi vastausten oikeellisuuden heikentyessä vain vähän. Kielen kontrolloinnin lisäksi eräs uusi haaste monikielisessä ympäristössä liittyy muiden ominaisuuksien kontrolloimisessa käytettyjen ohjausvektoreiden luomiseen. Koska näiden ohjausvektorien luominen vaatii esimerkkitekstejä, jotka vastaavat haluttuja vaatimuksia ominaisuuksien osalta, voi näiden vektorien luominen olla vaikeaa vähemmän edustetuille kielille, joille vastaavia esimerkkitekstejä ei löydy esimerkiksi valmiina eri tietokokonaisuuksista. Tutkielmassa tarjoamme tähän ongelmaan potentiaalisen ratkaisun osoittamalla, että joidenkin tyyliohjausvektoreiden tehokkuus generalisoituu kielten yli. Tämän osoittamiseksi käytämme englanninkielisistä esimerkkiteksteistä luotuja tyyliohjausvektoreita kahdelle eri tyylille ohjaamaan suomen kielellä generoidun tekstin tyyliä. Havaitsemme, että vaikka toisen tyylin ohjausvektoreiden tehokkuus laskee kun niitä käytetään suomenkielisen tekstin ohjaamiseen, toisen tyylin ohjausvektoreiden tehokkuus pysyy suomen kielellä lähes samana kuin englannin kielelläkin, tuottaen haluttua tyyliä noudattavaa suomenkielistä tekstiä.Description
Supervisor
Marttinen, PekkaThesis advisor
Karlgren, JussiKeywords
artificial intelligence, large language models, controlled text generation, latent space steering, multilinguality, latent space