{"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/training-language-models-to-generate-text","title":"Training Language Models to Generate Text with Citations via Fine-grained Rewards","arxiv_id":"2402.04315","date":"2024-02-06","proceeding":null,"authors":["Chengyu Huang","Zeqiu Wu","Yushi Hu","Wenya Wang"],"abstract":"While recent Large Language Models (LLMs) have proven useful in answering user queries, they are prone to hallucination, and their responses often lack credibility due to missing references to reliable sources. An intuitive solution to these issues would be to include in-text citations referring to external documents as evidence. While previous works have directly prompted LLMs to generate in-text citations, their performances are far from satisfactory, especially when it comes to smaller LLMs. In this work, we propose an effective training framework using fine-grained rewards to teach LLMs to generate highly supportive and relevant citations, while ensuring the correctness of their responses. We also conduct a systematic analysis of applying these fine-grained rewards to common LLM training strategies, demonstrating its advantage over conventional practices. We conduct extensive experiments on Question Answering (QA) datasets taken from the ALCE benchmark and validate the model's generalizability using EXPERTQA. On LLaMA-2-7B, the incorporation of fine-grained rewards achieves the best performance among the baselines, even surpassing that of GPT-3.5-turbo.","url_abs":"https://arxiv.org/abs/2402.04315v3","url_pdf":"https://arxiv.org/pdf/2402.04315v3.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":"training-language-models-to-generate-text","repo_url":"https://github.com/hcy123902/atg-w-fg-rw","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}}],"tasks":[{"task_slug":"hallucination","task_name":"Hallucination"},{"task_slug":"question-answering","task_name":"Question Answering"}],"methods":[{"method_slug":"adam","method_name":"Adam"},{"method_slug":"attention","method_name":"Attention"},{"method_slug":"attention-dropout","method_name":"Attention Dropout"},{"method_slug":"bpe","method_name":"BPE"},{"method_slug":"cosine-annealing","method_name":"Cosine Annealing"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"dropout","method_name":"Dropout"},{"method_slug":"gpt-3","method_name":"GPT-3"},{"method_slug":"layer-normalization","method_name":"Layer Normalization"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"linear-warmup-with-cosine-annealing","method_name":"Linear Warmup With Cosine Annealing"},{"method_slug":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"weight-decay","method_name":"Weight Decay"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2402.04315","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2402.04315"}},"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/hcy123902/atg-w-fg-rw","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"ran":3,"ran_draft_wrong":4,"unverified":5},"by_repo_kind":{"official":{"samples":12,"ran":7,"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":"c7d29eb322d5d6e3","entry":"make_doc_prompt","repo":"hcy123902/atg-w-fg-rw","repo_kind":"official","path":"evaluation/eval_utils.py","file_url":"https://github.com/hcy123902/atg-w-fg-rw/blob/HEAD/evaluation/eval_utils.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":"c7d29eb322d5d6e3"}},{"code_sha256_prefix":"dae7ab386661a4f4","entry":"normalize_answer","repo":"hcy123902/atg-w-fg-rw","repo_kind":"official","path":"evaluation/eval_utils.py","file_url":"https://github.com/hcy123902/atg-w-fg-rw/blob/HEAD/evaluation/eval_utils.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"dae7ab386661a4f4"}},{"code_sha256_prefix":"e5bacba887a721ef","entry":"reduce_mean","repo":"hcy123902/atg-w-fg-rw","repo_kind":"official","path":"fgrlhf/utils.py","file_url":"https://github.com/hcy123902/atg-w-fg-rw/blob/HEAD/fgrlhf/utils.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"e5bacba887a721ef"}},{"code_sha256_prefix":"174bfbbeb1f29e12","entry":"reduce_std","repo":"hcy123902/atg-w-fg-rw","repo_kind":"official","path":"fgrlhf/utils.py","file_url":"https://github.com/hcy123902/atg-w-fg-rw/blob/HEAD/fgrlhf/utils.py","link_basis":"harvester_set","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":"174bfbbeb1f29e12"}},{"code_sha256_prefix":"5874b0a8910897fd","entry":"reduce_sum","repo":"hcy123902/atg-w-fg-rw","repo_kind":"official","path":"fgrlhf/utils.py","file_url":"https://github.com/hcy123902/atg-w-fg-rw/blob/HEAD/fgrlhf/utils.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"5874b0a8910897fd"}},{"code_sha256_prefix":"5df8b525aada9853","entry":"remove_citations","repo":"hcy123902/atg-w-fg-rw","repo_kind":"official","path":"evaluation/eval_utils.py","file_url":"https://github.com/hcy123902/atg-w-fg-rw/blob/HEAD/evaluation/eval_utils.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"5df8b525aada9853"}},{"code_sha256_prefix":"d36629ddac8ee6aa","entry":"split_qampari_text","repo":"hcy123902/atg-w-fg-rw","repo_kind":"official","path":"fgrlhf/reward_utils.py","file_url":"https://github.com/hcy123902/atg-w-fg-rw/blob/HEAD/fgrlhf/reward_utils.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":"d36629ddac8ee6aa"}},{"code_sha256_prefix":"031d4bfddac2dbef","entry":"get_rouge_scores","repo":"hcy123902/atg-w-fg-rw","repo_kind":"official","path":"fgrlhf/evaluators.py","file_url":"https://github.com/hcy123902/atg-w-fg-rw/blob/HEAD/fgrlhf/evaluators.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":"031d4bfddac2dbef"}},{"code_sha256_prefix":"46fb11d38baff4e2","entry":"get_single_rouge_score","repo":"hcy123902/atg-w-fg-rw","repo_kind":"official","path":"fgrlhf/evaluators.py","file_url":"https://github.com/hcy123902/atg-w-fg-rw/blob/HEAD/fgrlhf/evaluators.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":"46fb11d38baff4e2"}},{"code_sha256_prefix":"94a55f838c975848","entry":"postprocess_text","repo":"hcy123902/atg-w-fg-rw","repo_kind":"official","path":"fgrlhf/evaluators.py","file_url":"https://github.com/hcy123902/atg-w-fg-rw/blob/HEAD/fgrlhf/evaluators.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":"94a55f838c975848"}},{"code_sha256_prefix":"e7f95d91543ac720","entry":"split_text_to_sentences","repo":"hcy123902/atg-w-fg-rw","repo_kind":"official","path":"fgrlhf/reward_utils.py","file_url":"https://github.com/hcy123902/atg-w-fg-rw/blob/HEAD/fgrlhf/reward_utils.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":"e7f95d91543ac720"}},{"code_sha256_prefix":"11589c4018cfc261","entry":"split_text_to_subsentences","repo":"hcy123902/atg-w-fg-rw","repo_kind":"official","path":"fgrlhf/reward_utils.py","file_url":"https://github.com/hcy123902/atg-w-fg-rw/blob/HEAD/fgrlhf/reward_utils.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":"11589c4018cfc261"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}