{"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/discretized-integrated-gradients-for","title":"Discretized Integrated Gradients for Explaining Language Models","arxiv_id":"2108.13654","date":"2021-08-31","proceeding":"EMNLP 2021 11","authors":["Soumya Sanyal","Xiang Ren"],"abstract":"As a prominent attribution-based explanation algorithm, Integrated Gradients (IG) is widely adopted due to its desirable explanation axioms and the ease of gradient computation. It measures feature importance by averaging the model's output gradient interpolated along a straight-line path in the input data space. However, such straight-line interpolated points are not representative of text data due to the inherent discreteness of the word embedding space. This questions the faithfulness of the gradients computed at the interpolated points and consequently, the quality of the generated explanations. Here we propose Discretized Integrated Gradients (DIG), which allows effective attribution along non-linear interpolation paths. We develop two interpolation strategies for the discrete word embedding space that generates interpolation points that lie close to actual words in the embedding space, yielding more faithful gradient computation. We demonstrate the effectiveness of DIG over IG through experimental and human evaluations on multiple sentiment classification datasets. We provide the source code of DIG to encourage reproducible research.","url_abs":"https://arxiv.org/abs/2108.13654v1","url_pdf":"https://arxiv.org/pdf/2108.13654v1.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":"discretized-integrated-gradients-for","repo_url":"https://github.com/ink-usc/dig","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"discretized-integrated-gradients-for","repo_url":"https://github.com/g8a9/ferret","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"feature-importance","task_name":"Feature Importance"},{"task_slug":"sentiment-analysis","task_name":"Sentiment Analysis"},{"task_slug":"sentiment-classification","task_name":"Sentiment Classification"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2108.13654","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2108.13654"}},"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/g8a9/ferret","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/ink-usc/dig","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":5,"unverified":17},"by_repo_kind":{"official":{"samples":13,"ran":0,"repositories":1},"listed":{"samples":9,"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":"f815bed681b134dc","entry":"BaseTextTaskHelper","repo":"g8a9/ferret","repo_kind":"listed","path":"ferret/explainers/gradient.py","file_url":"https://github.com/g8a9/ferret/blob/HEAD/ferret/explainers/gradient.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":"f815bed681b134dc"}},{"code_sha256_prefix":"7be99d7ee78f65a2","entry":"Explanation","repo":"g8a9/ferret","repo_kind":"listed","path":"ferret/explainers/gradient.py","file_url":"https://github.com/g8a9/ferret/blob/HEAD/ferret/explainers/gradient.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":"7be99d7ee78f65a2"}},{"code_sha256_prefix":"6d7956d91e40f00a","entry":"SequenceClassificationHelper","repo":"g8a9/ferret","repo_kind":"listed","path":"ferret/explainers/gradient.py","file_url":"https://github.com/g8a9/ferret/blob/HEAD/ferret/explainers/gradient.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":"6d7956d91e40f00a"}},{"code_sha256_prefix":"51a529a9451f6518","entry":"TokenClassificationHelper","repo":"g8a9/ferret","repo_kind":"listed","path":"ferret/explainers/gradient.py","file_url":"https://github.com/g8a9/ferret/blob/HEAD/ferret/explainers/gradient.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":"51a529a9451f6518"}},{"code_sha256_prefix":"6ee6b2a8a337c1f7","entry":"ZeroShotTextClassificationHelper","repo":"g8a9/ferret","repo_kind":"listed","path":"ferret/explainers/gradient.py","file_url":"https://github.com/g8a9/ferret/blob/HEAD/ferret/explainers/gradient.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":"6ee6b2a8a337c1f7"}},{"code_sha256_prefix":"350432c068907cfc","entry":"BaseExplainer","repo":"g8a9/ferret","repo_kind":"listed","path":"ferret/explainers/gradient.py","file_url":"https://github.com/g8a9/ferret/blob/HEAD/ferret/explainers/gradient.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":"350432c068907cfc"}},{"code_sha256_prefix":"d15101324a574447","entry":"BaseTaskHelper","repo":"g8a9/ferret","repo_kind":"listed","path":"ferret/explainers/gradient.py","file_url":"https://github.com/g8a9/ferret/blob/HEAD/ferret/explainers/gradient.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":"d15101324a574447"}},{"code_sha256_prefix":"3a39393f1428fdef","entry":"IntegratedGradientExplainer","repo":"g8a9/ferret","repo_kind":"listed","path":"ferret/explainers/gradient.py","file_url":"https://github.com/g8a9/ferret/blob/HEAD/ferret/explainers/gradient.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":"3a39393f1428fdef"}},{"code_sha256_prefix":"f966d0a57a94d578","entry":"create_helper","repo":"g8a9/ferret","repo_kind":"listed","path":"ferret/explainers/gradient.py","file_url":"https://github.com/g8a9/ferret/blob/HEAD/ferret/explainers/gradient.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":"f966d0a57a94d578"}},{"code_sha256_prefix":"83a6815c4f83e018","entry":"distance","repo":"ink-usc/dig","repo_kind":"official","path":"monotonic_paths.py","file_url":"https://github.com/ink-usc/dig/blob/HEAD/monotonic_paths.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":"83a6815c4f83e018"}},{"code_sha256_prefix":"12923c362c99f77c","entry":"eval_comprehensiveness","repo":"ink-usc/dig","repo_kind":"official","path":"metrics.py","file_url":"https://github.com/ink-usc/dig/blob/HEAD/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":"12923c362c99f77c"}},{"code_sha256_prefix":"ec63ecec627f3fac","entry":"eval_log_odds","repo":"ink-usc/dig","repo_kind":"official","path":"metrics.py","file_url":"https://github.com/ink-usc/dig/blob/HEAD/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":"ec63ecec627f3fac"}},{"code_sha256_prefix":"8e63950975ae0d89","entry":"eval_sufficiency","repo":"ink-usc/dig","repo_kind":"official","path":"metrics.py","file_url":"https://github.com/ink-usc/dig/blob/HEAD/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":"8e63950975ae0d89"}},{"code_sha256_prefix":"f8bf80d1cf1649e5","entry":"make_monotonic_vec","repo":"ink-usc/dig","repo_kind":"official","path":"monotonic_paths.py","file_url":"https://github.com/ink-usc/dig/blob/HEAD/monotonic_paths.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":"f8bf80d1cf1649e5"}},{"code_sha256_prefix":"694effceefaf2cd4","entry":"monotonic","repo":"ink-usc/dig","repo_kind":"official","path":"monotonic_paths.py","file_url":"https://github.com/ink-usc/dig/blob/HEAD/monotonic_paths.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":"694effceefaf2cd4"}},{"code_sha256_prefix":"74f3fd36cd31110f","entry":"nn_forward_func","repo":"ink-usc/dig","repo_kind":"official","path":"bert_helper.py","file_url":"https://github.com/ink-usc/dig/blob/HEAD/bert_helper.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":"74f3fd36cd31110f"}},{"code_sha256_prefix":"c73850601b4bfca6","entry":"nn_forward_func","repo":"ink-usc/dig","repo_kind":"official","path":"distilbert_helper.py","file_url":"https://github.com/ink-usc/dig/blob/HEAD/distilbert_helper.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":"c73850601b4bfca6"}},{"code_sha256_prefix":"1e9c64aa330afd59","entry":"nn_init","repo":"ink-usc/dig","repo_kind":"official","path":"bert_helper.py","file_url":"https://github.com/ink-usc/dig/blob/HEAD/bert_helper.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":"1e9c64aa330afd59"}},{"code_sha256_prefix":"2301db8848f0fa1f","entry":"nn_init","repo":"ink-usc/dig","repo_kind":"official","path":"distilbert_helper.py","file_url":"https://github.com/ink-usc/dig/blob/HEAD/distilbert_helper.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":"2301db8848f0fa1f"}},{"code_sha256_prefix":"f4c1f89220f52256","entry":"predict","repo":"ink-usc/dig","repo_kind":"official","path":"bert_helper.py","file_url":"https://github.com/ink-usc/dig/blob/HEAD/bert_helper.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":"f4c1f89220f52256"}},{"code_sha256_prefix":"0f56782c71796ff7","entry":"run_dig_explanation","repo":"ink-usc/dig","repo_kind":"official","path":"attributions.py","file_url":"https://github.com/ink-usc/dig/blob/HEAD/attributions.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":"0f56782c71796ff7"}},{"code_sha256_prefix":"6fbd77010ba96ecf","entry":"summarize_attributions","repo":"ink-usc/dig","repo_kind":"official","path":"attributions.py","file_url":"https://github.com/ink-usc/dig/blob/HEAD/attributions.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":"6fbd77010ba96ecf"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}