{"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/be-like-a-goldfish-don-t-memorize-mitigating","title":"Be like a Goldfish, Don't Memorize! Mitigating Memorization in Generative LLMs","arxiv_id":"2406.10209","date":"2024-06-14","proceeding":null,"authors":["Abhimanyu Hans","Yuxin Wen","Neel Jain","John Kirchenbauer","Hamid Kazemi","Prajwal Singhania","Siddharth Singh","Gowthami Somepalli","Jonas Geiping","Abhinav Bhatele","Tom Goldstein"],"abstract":"Large language models can memorize and repeat their training data, causing privacy and copyright risks. To mitigate memorization, we introduce a subtle modification to the next-token training objective that we call the goldfish loss. During training, randomly sampled subsets of tokens are excluded from the loss computation. These dropped tokens are not memorized by the model, which prevents verbatim reproduction of a complete chain of tokens from the training set. We run extensive experiments training billion-scale Llama-2 models, both pre-trained and trained from scratch, and demonstrate significant reductions in extractable memorization with little to no impact on downstream benchmarks.","url_abs":"https://arxiv.org/abs/2406.10209v2","url_pdf":"https://arxiv.org/pdf/2406.10209v2.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":"be-like-a-goldfish-don-t-memorize-mitigating","repo_url":"https://github.com/ahans30/goldfish-loss","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}}],"tasks":[{"task_slug":"memorization","task_name":"Memorization"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":null,"atlas_url":"https://app.syntology.ai/?focus=2406.10209","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2406.10209"}},"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/ahans30/goldfish-loss","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"ran_violates":2,"ran":11,"unverified":5},"by_repo_kind":{"official":{"samples":18,"ran":13,"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":"aa32c6faaa562b69","entry":"apply_rope","repo":"ahans30/goldfish-loss","repo_kind":"official","path":"lit_gpt/model.py","file_url":"https://github.com/ahans30/goldfish-loss/blob/HEAD/lit_gpt/model.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"aa32c6faaa562b69"}},{"code_sha256_prefix":"7ee1c3ba71156110","entry":"build_mask_cache","repo":"ahans30/goldfish-loss","repo_kind":"official","path":"lit_gpt/model.py","file_url":"https://github.com/ahans30/goldfish-loss/blob/HEAD/lit_gpt/model.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"7ee1c3ba71156110"}},{"code_sha256_prefix":"a8052087ba311802","entry":"cos_sim","repo":"ahans30/goldfish-loss","repo_kind":"official","path":"lit_gpt/multiple_negative_ranking_loss.py","file_url":"https://github.com/ahans30/goldfish-loss/blob/HEAD/lit_gpt/multiple_negative_ranking_loss.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"a8052087ba311802"}},{"code_sha256_prefix":"d88b4cf25c69af3e","entry":"count_tokenizes_and_get_metrics","repo":"ahans30/goldfish-loss","repo_kind":"official","path":"data_checks/count_token_lengths.py","file_url":"https://github.com/ahans30/goldfish-loss/blob/HEAD/data_checks/count_token_lengths.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"d88b4cf25c69af3e"}},{"code_sha256_prefix":"53c8bb69ab68da37","entry":"cumulative_mean_pooling","repo":"ahans30/goldfish-loss","repo_kind":"official","path":"lit_gpt/retrieval_model.py","file_url":"https://github.com/ahans30/goldfish-loss/blob/HEAD/lit_gpt/retrieval_model.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"53c8bb69ab68da37"}},{"code_sha256_prefix":"b38ee8cd162d2d61","entry":"divide","repo":"ahans30/goldfish-loss","repo_kind":"official","path":"axonn_fabric/fabric.py","file_url":"https://github.com/ahans30/goldfish-loss/blob/HEAD/axonn_fabric/fabric.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"b38ee8cd162d2d61"}},{"code_sha256_prefix":"41418f480eb09bbc","entry":"get_batch","repo":"ahans30/goldfish-loss","repo_kind":"official","path":"eval/eval_retrieval_anticausal.py","file_url":"https://github.com/ahans30/goldfish-loss/blob/HEAD/eval/eval_retrieval_anticausal.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"41418f480eb09bbc"}},{"code_sha256_prefix":"3b42fb8763cf8824","entry":"get_tflops","repo":"ahans30/goldfish-loss","repo_kind":"official","path":"axonn_fabric/megatron_logging.py","file_url":"https://github.com/ahans30/goldfish-loss/blob/HEAD/axonn_fabric/megatron_logging.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"3b42fb8763cf8824"}},{"code_sha256_prefix":"660a177a11d8a4cb","entry":"init_normal","repo":"ahans30/goldfish-loss","repo_kind":"official","path":"lit_gpt/model_axonn.py","file_url":"https://github.com/ahans30/goldfish-loss/blob/HEAD/lit_gpt/model_axonn.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"660a177a11d8a4cb"}},{"code_sha256_prefix":"ff1deefe8ebfa94d","entry":"process_raw_data","repo":"ahans30/goldfish-loss","repo_kind":"official","path":"eval/data_extraction.py","file_url":"https://github.com/ahans30/goldfish-loss/blob/HEAD/eval/data_extraction.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"ff1deefe8ebfa94d"}},{"code_sha256_prefix":"386654d652c835ee","entry":"rank_prefixed_message","repo":"ahans30/goldfish-loss","repo_kind":"official","path":"axonn_fabric/fabric.py","file_url":"https://github.com/ahans30/goldfish-loss/blob/HEAD/axonn_fabric/fabric.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"386654d652c835ee"}},{"code_sha256_prefix":"4915f91d695a9b8e","entry":"scaled_init_normal","repo":"ahans30/goldfish-loss","repo_kind":"official","path":"lit_gpt/model_axonn.py","file_url":"https://github.com/ahans30/goldfish-loss/blob/HEAD/lit_gpt/model_axonn.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"4915f91d695a9b8e"}},{"code_sha256_prefix":"1eabe88f26a677a1","entry":"str2bool","repo":"ahans30/goldfish-loss","repo_kind":"official","path":"eval/data_extraction.py","file_url":"https://github.com/ahans30/goldfish-loss/blob/HEAD/eval/data_extraction.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"1eabe88f26a677a1"}},{"code_sha256_prefix":"c0cabd60c81402a5","entry":"build_rope_cache","repo":"ahans30/goldfish-loss","repo_kind":"official","path":"lit_gpt/model.py","file_url":"https://github.com/ahans30/goldfish-loss/blob/HEAD/lit_gpt/model.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"c0cabd60c81402a5"}},{"code_sha256_prefix":"55c7e661e08b2d2e","entry":"generate_responses_batched","repo":"ahans30/goldfish-loss","repo_kind":"official","path":"eval/alpaca_eval_generate.py","file_url":"https://github.com/ahans30/goldfish-loss/blob/HEAD/eval/alpaca_eval_generate.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"55c7e661e08b2d2e"}},{"code_sha256_prefix":"6db38b4d818a2c2e","entry":"get_conv_template","repo":"ahans30/goldfish-loss","repo_kind":"official","path":"eval/conversation.py","file_url":"https://github.com/ahans30/goldfish-loss/blob/HEAD/eval/conversation.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"6db38b4d818a2c2e"}},{"code_sha256_prefix":"beb178be96641037","entry":"modified_mlp_forward","repo":"ahans30/goldfish-loss","repo_kind":"official","path":"axonn_fabric/hf_llama_tensor_parallel.py","file_url":"https://github.com/ahans30/goldfish-loss/blob/HEAD/axonn_fabric/hf_llama_tensor_parallel.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"beb178be96641037"}},{"code_sha256_prefix":"87ebed951203ba54","entry":"pretty_log","repo":"ahans30/goldfish-loss","repo_kind":"official","path":"axonn_fabric/megatron_logging.py","file_url":"https://github.com/ahans30/goldfish-loss/blob/HEAD/axonn_fabric/megatron_logging.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"87ebed951203ba54"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}