{"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/tag-llm-repurposing-general-purpose-llms-for","title":"Tag-LLM: Repurposing General-Purpose LLMs for Specialized Domains","arxiv_id":"2402.05140","date":"2024-02-06","proceeding":null,"authors":["Junhong Shen","Neil Tenenholtz","James Brian Hall","David Alvarez-Melis","Nicolo Fusi"],"abstract":"Large Language Models (LLMs) have demonstrated remarkable proficiency in understanding and generating natural language. However, their capabilities wane in highly specialized domains underrepresented in the pretraining corpus, such as physical and biomedical sciences. This work explores how to repurpose general LLMs into effective task solvers for specialized domains. We introduce a novel, model-agnostic framework for learning custom input tags, which are parameterized as continuous vectors appended to the LLM's embedding layer, to condition the LLM. We design two types of input tags: domain tags are used to delimit specialized representations (e.g., chemical formulas) and provide domain-relevant context; function tags are used to represent specific functions (e.g., predicting molecular properties) and compress function-solving instructions. We develop a three-stage protocol to learn these tags using auxiliary data and domain knowledge. By explicitly disentangling task domains from task functions, our method enables zero-shot generalization to unseen problems through diverse combinations of the input tags. It also boosts LLM's performance in various specialized domains, such as predicting protein or chemical properties and modeling drug-target interactions, outperforming expert models tailored to these tasks.","url_abs":"https://arxiv.org/abs/2402.05140v3","url_pdf":"https://arxiv.org/pdf/2402.05140v3.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":"tag-llm-repurposing-general-purpose-llms-for","repo_url":"https://github.com/sjunhongshen/tag-llm","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"tag","task_name":"TAG"},{"task_slug":"zero-shot-generalization","task_name":"Zero-shot Generalization"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2402.05140","atlas_url":"https://app.syntology.ai/?focus=2402.05140","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2402.05140"}},"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":"deterministic:regex_extraction","url":"https://github.com/sjunhongshen/Tag-LLM","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/sjunhongshen/tag-llm","reach":{"status":"ok"}}],"summary":{"ran":6,"ran_draft_wrong":1,"ran_fixture":1,"unverified":4},"by_repo_kind":{"official":{"samples":12,"ran":8,"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":12,"samples":[{"code_sha256_prefix":"e518de1c5154e4de","entry":"AugmentedTokenEncoder","repo":"sjunhongshen/tag-llm","repo_kind":"official","path":"src/tag_llama.py","file_url":"https://github.com/sjunhongshen/tag-llm/blob/HEAD/src/tag_llama.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"e518de1c5154e4de"}},{"code_sha256_prefix":"28d8cd93b790eb3b","entry":"TagLlamaRotaryEmbedding","repo":"sjunhongshen/tag-llm","repo_kind":"official","path":"src/tag_llama.py","file_url":"https://github.com/sjunhongshen/tag-llm/blob/HEAD/src/tag_llama.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"28d8cd93b790eb3b"}},{"code_sha256_prefix":"a85227444bd04c75","entry":"_expand_mask","repo":"sjunhongshen/tag-llm","repo_kind":"official","path":"src/tag_llama.py","file_url":"https://github.com/sjunhongshen/tag-llm/blob/HEAD/src/tag_llama.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"a85227444bd04c75"}},{"code_sha256_prefix":"c0290d783d0faae8","entry":"_make_causal_mask","repo":"sjunhongshen/tag-llm","repo_kind":"official","path":"src/tag_llama.py","file_url":"https://github.com/sjunhongshen/tag-llm/blob/HEAD/src/tag_llama.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c0290d783d0faae8"}},{"code_sha256_prefix":"e45a97b52b823610","entry":"drug_target_collate_fn","repo":"sjunhongshen/Tag-LLM","repo_kind":"official","path":"src/TDCdata.py","file_url":"https://github.com/sjunhongshen/Tag-LLM/blob/HEAD/src/TDCdata.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"e45a97b52b823610"}},{"code_sha256_prefix":"330bcd19fcdb2147","entry":"nested_select","repo":"sjunhongshen/Tag-LLM","repo_kind":"official","path":"src/metrics.py","file_url":"https://github.com/sjunhongshen/Tag-LLM/blob/HEAD/src/metrics.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"330bcd19fcdb2147"}},{"code_sha256_prefix":"d73f2cdc8a6da456","entry":"simple_basename","repo":"sjunhongshen/Tag-LLM","repo_kind":"official","path":"src/arguments.py","file_url":"https://github.com/sjunhongshen/Tag-LLM/blob/HEAD/src/arguments.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"d73f2cdc8a6da456"}},{"code_sha256_prefix":"a76b500245a3c895","entry":"strip_special_tokens","repo":"sjunhongshen/Tag-LLM","repo_kind":"official","path":"src/metrics.py","file_url":"https://github.com/sjunhongshen/Tag-LLM/blob/HEAD/src/metrics.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"a76b500245a3c895"}},{"code_sha256_prefix":"ac1f13679668276b","entry":"TagLlamaAttention","repo":"sjunhongshen/tag-llm","repo_kind":"official","path":"src/tag_llama.py","file_url":"https://github.com/sjunhongshen/tag-llm/blob/HEAD/src/tag_llama.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"ac1f13679668276b"}},{"code_sha256_prefix":"cd0950c94372a4e4","entry":"TagLlamaDecoderLayer","repo":"sjunhongshen/tag-llm","repo_kind":"official","path":"src/tag_llama.py","file_url":"https://github.com/sjunhongshen/tag-llm/blob/HEAD/src/tag_llama.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"cd0950c94372a4e4"}},{"code_sha256_prefix":"6bfbe95e48d141a0","entry":"TagLlamaModel","repo":"sjunhongshen/tag-llm","repo_kind":"official","path":"src/tag_llama.py","file_url":"https://github.com/sjunhongshen/tag-llm/blob/HEAD/src/tag_llama.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"6bfbe95e48d141a0"}},{"code_sha256_prefix":"85f31f5811b9b51a","entry":"postprocess_text","repo":"sjunhongshen/Tag-LLM","repo_kind":"official","path":"src/metrics.py","file_url":"https://github.com/sjunhongshen/Tag-LLM/blob/HEAD/src/metrics.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"85f31f5811b9b51a"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}