{"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/leveraging-visual-tokens-for-extended-text","title":"Leveraging Visual Tokens for Extended Text Contexts in Multi-Modal Learning","arxiv_id":"2406.02547","date":"2024-06-04","proceeding":null,"authors":["Alex Jinpeng Wang","Linjie Li","Yiqi Lin","Min Li","Lijuan Wang","Mike Zheng Shou"],"abstract":"Training models with longer in-context lengths is a significant challenge for multimodal model due to substantial GPU memory and computational costs. This exploratory study does not present state-of-the-art models; rather, it introduces an innovative method designed to increase in-context text length in multi-modality large language models (MLLMs) efficiently. We present Visualized In-Context Text Processing (VisInContext), which processes long in-context text using visual tokens. This technique significantly reduces GPU memory usage and floating point operations (FLOPs) for both training and inferenceing stage. For instance, our method expands the pre-training in-context text length from 256 to 2048 tokens with nearly same FLOPs for a 56 billion parameter MOE model. Experimental results demonstrate that model trained with VisInContext delivers superior performance on common downstream benchmarks for in-context few-shot evaluation. Additionally, VisInContext is complementary to existing methods for increasing in-context text length and enhances document understanding capabilities, showing great potential in document QA tasks and sequential document retrieval.","url_abs":"https://arxiv.org/abs/2406.02547v1","url_pdf":"https://arxiv.org/pdf/2406.02547v1.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":"leveraging-visual-tokens-for-extended-text","repo_url":"https://github.com/showlab/VisInContext","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":null,"task_name":"GPU"},{"task_slug":"retrieval","task_name":"Retrieval"},{"task_slug":"document-understanding","task_name":"document understanding"}],"methods":[{"method_slug":"moe","method_name":"MoE"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2406.02547","atlas_url":"https://app.syntology.ai/?focus=2406.02547","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2406.02547"}},"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/showlab/VisInContext","reach":{"status":"ok"}}],"summary":{"ran":7,"ran_violates":2,"unverified":5},"by_repo_kind":{"official":{"samples":14,"ran":9,"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":14,"samples":[{"code_sha256_prefix":"dd8287b62746381d","entry":"compute_metrics","repo":"showlab/VisInContext","repo_kind":"official","path":"src/main_instruction_tuning.py","file_url":"https://github.com/showlab/VisInContext/blob/HEAD/src/main_instruction_tuning.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":"dd8287b62746381d"}},{"code_sha256_prefix":"2214804f14ccb9d6","entry":"convert_to_results_file","repo":"showlab/VisInContext","repo_kind":"official","path":"src/main_eval_multiprocess.py","file_url":"https://github.com/showlab/VisInContext/blob/HEAD/src/main_eval_multiprocess.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":"2214804f14ccb9d6"}},{"code_sha256_prefix":"60fff7c3c400d7ff","entry":"default","repo":"showlab/VisInContext","repo_kind":"official","path":"src/multimodal_model/model_helper.py","file_url":"https://github.com/showlab/VisInContext/blob/HEAD/src/multimodal_model/model_helper.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"60fff7c3c400d7ff"}},{"code_sha256_prefix":"aa5486a3650902d8","entry":"exists","repo":"showlab/VisInContext","repo_kind":"official","path":"src/multimodal_model/model_helper.py","file_url":"https://github.com/showlab/VisInContext/blob/HEAD/src/multimodal_model/model_helper.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"aa5486a3650902d8"}},{"code_sha256_prefix":"0fe4cffe8835adb2","entry":"find_max_tar_index","repo":"showlab/VisInContext","repo_kind":"official","path":"src/utils/count_last_webdataset_sample.py","file_url":"https://github.com/showlab/VisInContext/blob/HEAD/src/utils/count_last_webdataset_sample.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":"0fe4cffe8835adb2"}},{"code_sha256_prefix":"a8b2a337d139e618","entry":"load_config","repo":"showlab/VisInContext","repo_kind":"official","path":"src/main_eval_multiprocess.py","file_url":"https://github.com/showlab/VisInContext/blob/HEAD/src/main_eval_multiprocess.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":"a8b2a337d139e618"}},{"code_sha256_prefix":"850f99157ddf3718","entry":"next_token_predict_accuracy","repo":"showlab/VisInContext","repo_kind":"official","path":"src/multimodal_model/utils.py","file_url":"https://github.com/showlab/VisInContext/blob/HEAD/src/multimodal_model/utils.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":"850f99157ddf3718"}},{"code_sha256_prefix":"2a9d9663f0f97436","entry":"patch_torch_distributed_new_group","repo":"showlab/VisInContext","repo_kind":"official","path":"src/multimodal_model/utils.py","file_url":"https://github.com/showlab/VisInContext/blob/HEAD/src/multimodal_model/utils.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":"2a9d9663f0f97436"}},{"code_sha256_prefix":"58aea06420896fb5","entry":"process_shared_results","repo":"showlab/VisInContext","repo_kind":"official","path":"src/main_eval_multiprocess.py","file_url":"https://github.com/showlab/VisInContext/blob/HEAD/src/main_eval_multiprocess.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":"58aea06420896fb5"}},{"code_sha256_prefix":"2690d695e4c513f9","entry":"create_fuyu","repo":"showlab/VisInContext","repo_kind":"official","path":"src/multimodal_model/load_model.py","file_url":"https://github.com/showlab/VisInContext/blob/HEAD/src/multimodal_model/load_model.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":"2690d695e4c513f9"}},{"code_sha256_prefix":"d28e72b052b5d438","entry":"gather_tensors_all_nodes","repo":"showlab/VisInContext","repo_kind":"official","path":"src/multimodal_model/model_architecture.py","file_url":"https://github.com/showlab/VisInContext/blob/HEAD/src/multimodal_model/model_architecture.py","link_basis":"plan_row","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":"d28e72b052b5d438"}},{"code_sha256_prefix":"f1f89b7214c45bbf","entry":"group_all_gather","repo":"showlab/VisInContext","repo_kind":"official","path":"src/multimodal_model/model_architecture.py","file_url":"https://github.com/showlab/VisInContext/blob/HEAD/src/multimodal_model/model_architecture.py","link_basis":"plan_row","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":"f1f89b7214c45bbf"}},{"code_sha256_prefix":"f99d0248614d77fd","entry":"load_config","repo":"showlab/VisInContext","repo_kind":"official","path":"src/main_instruction_tuning.py","file_url":"https://github.com/showlab/VisInContext/blob/HEAD/src/main_instruction_tuning.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":"f99d0248614d77fd"}},{"code_sha256_prefix":"2714f132c61ad580","entry":"torch_save_patch","repo":"showlab/VisInContext","repo_kind":"official","path":"src/multimodal_model/utils.py","file_url":"https://github.com/showlab/VisInContext/blob/HEAD/src/multimodal_model/utils.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":"2714f132c61ad580"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}