{"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/straight-to-the-gradient-learning-to-use-1","title":"Straight to the Gradient: Learning to Use Novel Tokens for Neural Text Generation","arxiv_id":"2106.07207","date":"2021-06-14","proceeding":null,"authors":["Xiang Lin","Simeng Han","Shafiq Joty"],"abstract":"Advanced large-scale neural language models have led to significant success in many language generation tasks. However, the most commonly used training objective, Maximum Likelihood Estimation (MLE), has been shown problematic, where the trained model prefers using dull and repetitive phrases. In this work, we introduce ScaleGrad, a modification straight to the gradient of the loss function, to remedy the degeneration issue of the standard MLE objective. By directly maneuvering the gradient information, ScaleGrad makes the model learn to use novel tokens. Empirical results show the effectiveness of our method not only in open-ended generation, but also in directed generation tasks. With the simplicity in architecture, our method can serve as a general training objective that is applicable to most of the neural text generation tasks.","url_abs":"https://arxiv.org/abs/2106.07207v1","url_pdf":"https://arxiv.org/pdf/2106.07207v1.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":"straight-to-the-gradient-learning-to-use-1","repo_url":"https://github.com/shawnlimn/ScaleGrad","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"text-generation","task_name":"Text Generation"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":null,"atlas_url":"https://app.syntology.ai/?focus=2106.07207","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2106.07207"}},"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":"deterministic:regex_extraction","url":"https://github.com/shawnlimn/ScaleGrad","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran_draft_wrong":2,"ran_fixture":2,"unverified":4},"by_repo_kind":{"official":{"samples":8,"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":"041742ed31858d0f","entry":"get_datasets","repo":"shawnlimn/scalegrad","repo_kind":"official","path":"custom/gpt2/run_gpt2.py","file_url":"https://github.com/shawnlimn/scalegrad/blob/HEAD/custom/gpt2/run_gpt2.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":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"041742ed31858d0f"}},{"code_sha256_prefix":"298689919da2c5b0","entry":"top_k_logits","repo":"shawnlimn/scalegrad","repo_kind":"official","path":"custom/sequence_generator.py","file_url":"https://github.com/shawnlimn/scalegrad/blob/HEAD/custom/sequence_generator.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"298689919da2c5b0"}},{"code_sha256_prefix":"ace3f464bf5b4c7a","entry":"top_k_logits","repo":"shawnlimn/ScaleGrad","repo_kind":"official","path":"custom/sequence_generator.py","file_url":"https://github.com/shawnlimn/ScaleGrad/blob/HEAD/custom/sequence_generator.py","link_basis":"plan_row","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ace3f464bf5b4c7a"}},{"code_sha256_prefix":"d415ae4787477f20","entry":"top_k_top_p_filtering","repo":"shawnlimn/scalegrad","repo_kind":"official","path":"custom/gpt2/run_gpt2.py","file_url":"https://github.com/shawnlimn/scalegrad/blob/HEAD/custom/gpt2/run_gpt2.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"d415ae4787477f20"}},{"code_sha256_prefix":"e91bbe0f0d67f102","entry":"batch_input_sequence_by_prefix_length","repo":"shawnlimn/ScaleGrad","repo_kind":"official","path":"custom/evaluate_utils.py","file_url":"https://github.com/shawnlimn/ScaleGrad/blob/HEAD/custom/evaluate_utils.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":"e91bbe0f0d67f102"}},{"code_sha256_prefix":"d8c07afc39ab5d5e","entry":"ngram_metrics","repo":"shawnlimn/ScaleGrad","repo_kind":"official","path":"custom/metrics.py","file_url":"https://github.com/shawnlimn/ScaleGrad/blob/HEAD/custom/metrics.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":"d8c07afc39ab5d5e"}},{"code_sha256_prefix":"b34473338b0463d5","entry":"ngram_repeat_mask","repo":"shawnlimn/ScaleGrad","repo_kind":"official","path":"custom/sequence_penalty_loss.py","file_url":"https://github.com/shawnlimn/ScaleGrad/blob/HEAD/custom/sequence_penalty_loss.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":"b34473338b0463d5"}},{"code_sha256_prefix":"19a19ef6f1042ac4","entry":"sample_sequence","repo":"shawnlimn/scalegrad","repo_kind":"official","path":"custom/gpt2/run_gpt2.py","file_url":"https://github.com/shawnlimn/scalegrad/blob/HEAD/custom/gpt2/run_gpt2.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":"19a19ef6f1042ac4"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}