{"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/recovering-private-text-in-federated-learning","title":"Recovering Private Text in Federated Learning of Language Models","arxiv_id":"2205.08514","date":"2022-05-17","proceeding":null,"authors":["Samyak Gupta","Yangsibo Huang","Zexuan Zhong","Tianyu Gao","Kai Li","Danqi Chen"],"abstract":"Federated learning allows distributed users to collaboratively train a model while keeping each user's data private. Recently, a growing body of work has demonstrated that an eavesdropping attacker can effectively recover image data from gradients transmitted during federated learning. However, little progress has been made in recovering text data. In this paper, we present a novel attack method FILM for federated learning of language models (LMs). For the first time, we show the feasibility of recovering text from large batch sizes of up to 128 sentences. Unlike image-recovery methods that are optimized to match gradients, we take a distinct approach that first identifies a set of words from gradients and then directly reconstructs sentences based on beam search and a prior-based reordering strategy. We conduct the FILM attack on several large-scale datasets and show that it can successfully reconstruct single sentences with high fidelity for large batch sizes and even multiple sentences if applied iteratively. We evaluate three defense methods: gradient pruning, DPSGD, and a simple approach to freeze word embeddings that we propose. We show that both gradient pruning and DPSGD lead to a significant drop in utility. However, if we fine-tune a public pre-trained LM on private text without updating word embeddings, it can effectively defend the attack with minimal data utility loss. Together, we hope that our results can encourage the community to rethink the privacy concerns of LM training and its standard practices in the future.","url_abs":"https://arxiv.org/abs/2205.08514v2","url_pdf":"https://arxiv.org/pdf/2205.08514v2.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":"recovering-private-text-in-federated-learning","repo_url":"https://github.com/princeton-sysml/film","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"federated-learning","task_name":"Federated Learning"},{"task_slug":"word-embeddings","task_name":"Word Embeddings"}],"methods":[{"method_slug":"pruning","method_name":"Pruning"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2205.08514","atlas_url":"https://app.syntology.ai/?focus=2205.08514","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2205.08514"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+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/princeton-sysml/film","reach":null}],"summary":{"ran_honours":1,"ran_draft_wrong":3,"ran_fixture":1,"unverified":3},"by_repo_kind":{"official":{"samples":8,"ran":5,"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":"2506162f964eed68","entry":"calculatePerplexity","repo":"princeton-sysml/film","repo_kind":"official","path":"reorder.py","file_url":"https://github.com/princeton-sysml/film/blob/HEAD/reorder.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"CC0-1.0","inline_ok":true,"mcp_get_code":{"code_sha256":"2506162f964eed68"}},{"code_sha256_prefix":"30062ec641d7c6e1","entry":"ibis","repo":"princeton-sysml/film","repo_kind":"official","path":"reorder.py","file_url":"https://github.com/princeton-sysml/film/blob/HEAD/reorder.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"CC0-1.0","inline_ok":true,"mcp_get_code":{"code_sha256":"30062ec641d7c6e1"}},{"code_sha256_prefix":"09f1ec0ed6850234","entry":"shard_sequence_using_eos","repo":"princeton-sysml/film","repo_kind":"official","path":"reorder.py","file_url":"https://github.com/princeton-sysml/film/blob/HEAD/reorder.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"CC0-1.0","inline_ok":true,"mcp_get_code":{"code_sha256":"09f1ec0ed6850234"}},{"code_sha256_prefix":"7b09c74c1f6987a0","entry":"shuffle_proposals","repo":"princeton-sysml/film","repo_kind":"official","path":"reorder.py","file_url":"https://github.com/princeton-sysml/film/blob/HEAD/reorder.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"CC0-1.0","inline_ok":true,"mcp_get_code":{"code_sha256":"7b09c74c1f6987a0"}},{"code_sha256_prefix":"6d0e59be9216d2ac","entry":"shuffle_proposals_rand","repo":"princeton-sysml/film","repo_kind":"official","path":"reorder.py","file_url":"https://github.com/princeton-sysml/film/blob/HEAD/reorder.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"CC0-1.0","inline_ok":true,"mcp_get_code":{"code_sha256":"6d0e59be9216d2ac"}},{"code_sha256_prefix":"7cecdfca7a210f88","entry":"get_grad_gpt2","repo":"princeton-sysml/film","repo_kind":"official","path":"reorder.py","file_url":"https://github.com/princeton-sysml/film/blob/HEAD/reorder.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"CC0-1.0","inline_ok":true,"mcp_get_code":{"code_sha256":"7cecdfca7a210f88"}},{"code_sha256_prefix":"45a5586b7fa0bff9","entry":"ibisAlgorithm","repo":"princeton-sysml/film","repo_kind":"official","path":"reorder.py","file_url":"https://github.com/princeton-sysml/film/blob/HEAD/reorder.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"CC0-1.0","inline_ok":true,"mcp_get_code":{"code_sha256":"45a5586b7fa0bff9"}},{"code_sha256_prefix":"b902d2253e571934","entry":"score","repo":"princeton-sysml/film","repo_kind":"official","path":"reorder.py","file_url":"https://github.com/princeton-sysml/film/blob/HEAD/reorder.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"CC0-1.0","inline_ok":true,"mcp_get_code":{"code_sha256":"b902d2253e571934"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}