{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/fluent-dreaming-for-language-models","title":"Fluent dreaming for language models","arxiv_id":"2402.01702","date":"2024-01-24","proceeding":null,"authors":["T. Ben Thompson","Zygimantas Straznickas","Michael Sklar"],"abstract":"Feature visualization, also known as \"dreaming\", offers insights into vision models by optimizing the inputs to maximize a neuron's activation or other internal component. However, dreaming has not been successfully applied to language models because the input space is discrete. We extend Greedy Coordinate Gradient, a method from the language model adversarial attack literature, to design the Evolutionary Prompt Optimization (EPO) algorithm. EPO optimizes the input prompt to simultaneously maximize the Pareto frontier between a chosen internal feature and prompt fluency, enabling fluent dreaming for language models. We demonstrate dreaming with neurons, output logits and arbitrary directions in activation space. We measure the fluency of the resulting prompts and compare language model dreaming with max-activating dataset examples. Critically, fluent dreaming allows automatically exploring the behavior of model internals in reaction to mildly out-of-distribution prompts. Code for running EPO is available at https://github.com/Confirm-Solutions/dreamy. A companion page demonstrating code usage is at https://confirmlabs.org/posts/dreamy.html","url_abs":"https://arxiv.org/abs/2402.01702v1","url_pdf":"https://arxiv.org/pdf/2402.01702v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"fluent-dreaming-for-language-models","repo_url":"https://github.com/confirm-solutions/dreamy","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"adversarial-attack","task_name":"Adversarial Attack"},{"task_slug":"language-modeling","task_name":"Language Modeling"},{"task_slug":"language-modelling","task_name":"Language Modelling"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2402.01702","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2402.01702"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/confirm-solutions/dreamy","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":4,"unverified":5},"by_repo_kind":{"official":{"samples":9,"ran":4,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"40b63eccd8c8fa7b","entry":"build_pareto_frontier","repo":"confirm-solutions/dreamy","repo_kind":"official","path":"dreamy/epo.py","file_url":"https://github.com/confirm-solutions/dreamy/blob/HEAD/dreamy/epo.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"40b63eccd8c8fa7b"}},{"code_sha256_prefix":"ff0ddb961dafdda8","entry":"check_file_exists","repo":"confirm-solutions/dreamy","repo_kind":"official","path":"dreamy/experiment.py","file_url":"https://github.com/confirm-solutions/dreamy/blob/HEAD/dreamy/experiment.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ff0ddb961dafdda8"}},{"code_sha256_prefix":"0a7362a40b17901c","entry":"logit_diff_runner","repo":"confirm-solutions/dreamy","repo_kind":"official","path":"dreamy/runners.py","file_url":"https://github.com/confirm-solutions/dreamy/blob/HEAD/dreamy/runners.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"0a7362a40b17901c"}},{"code_sha256_prefix":"6989b8a8e10f20b8","entry":"viz_simple","repo":"confirm-solutions/dreamy","repo_kind":"official","path":"dreamy/attribution.py","file_url":"https://github.com/confirm-solutions/dreamy/blob/HEAD/dreamy/attribution.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"6989b8a8e10f20b8"}},{"code_sha256_prefix":"c064d28f43a7d9c6","entry":"does_retokenize","repo":"confirm-solutions/dreamy","repo_kind":"official","path":"dreamy/runners.py","file_url":"https://github.com/confirm-solutions/dreamy/blob/HEAD/dreamy/runners.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c064d28f43a7d9c6"}},{"code_sha256_prefix":"e6c85e40b8e012ea","entry":"epo","repo":"confirm-solutions/dreamy","repo_kind":"official","path":"dreamy/epo.py","file_url":"https://github.com/confirm-solutions/dreamy/blob/HEAD/dreamy/epo.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e6c85e40b8e012ea"}},{"code_sha256_prefix":"70da85a2f1e954b0","entry":"load_model","repo":"confirm-solutions/dreamy","repo_kind":"official","path":"dreamy/epo.py","file_url":"https://github.com/confirm-solutions/dreamy/blob/HEAD/dreamy/epo.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"70da85a2f1e954b0"}},{"code_sha256_prefix":"4df8cbcc21efc651","entry":"resample","repo":"confirm-solutions/dreamy","repo_kind":"official","path":"dreamy/attribution.py","file_url":"https://github.com/confirm-solutions/dreamy/blob/HEAD/dreamy/attribution.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"4df8cbcc21efc651"}},{"code_sha256_prefix":"164c2cef2b355a4d","entry":"viz","repo":"confirm-solutions/dreamy","repo_kind":"official","path":"dreamy/attribution.py","file_url":"https://github.com/confirm-solutions/dreamy/blob/HEAD/dreamy/attribution.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"164c2cef2b355a4d"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}