C o G enesis: A Framework Collaborating Large and Small Language Models for Secure Context-Aware Instruction Following (2024)

Abstract: With the advancement of language models (LMs), their exposure to private data is increasingly inevitable, and their deployment (especially for smaller ones) on personal devices, such as PCs and smartphones, has become a prevailing trend. In contexts laden with user information, enabling models to both safeguard user privacy and execute commands efficiently emerges as an essential research imperative. In this paper, we propose CoGenesis, a collaborative generation framework integrating large (hosted on cloud infrastructure) and small models (deployed on local devices) to address privacy concerns logically. Initially, we design a pipeline to create personalized writing instruction datasets enriched with extensive context details as the testbed of this research issue. Subsequently, we introduce two variants of CoGenesis based on sketch and logits respectively. Our experimental findings, based on our synthesized dataset and two additional open-source datasets, indicate that: 1) Large-scale models perform well when provided with user context but struggle in the absence of such context. 2) While specialized smaller models fine-tuned on the synthetic dataset show promise, they still lag behind their larger counterparts. 3) Our CoGenesis framework, utilizing mixed-scale models, showcases competitive performance, providing a feasible solution to privacy issues.

## introduction large language models (llms) 1 have demonstrated significant potential in advancing artificial intelligence, exhibiting exceptional ability in instruction following and achieving superior performance in various tasks such as writing, coding, despite their advancements, the most sophisticated llms, including gpt-4, claude, and gemini, are primarily commercialized and deployed on cloud services. this api-based deployment ensures the privacy of the llms but potentially compromises user privacy @xcite . although more powerful llms are being open-sourced, like llama-2 @xcite , qwen @xcite , and mistral @xcite , their stable deployment on local devices with limited resource remains challenging. recent advancements in smaller lms (slms) equipped with billions of parameters now enable their deployment on consumer desktops and smartphones, achieving satisfactory performance @xcite @xcite . the balance between performance and privacy in llms and slms raises three critical questions: (1) how effectively can llms operate without stringent user privacy contexts? ( 2 ) to what extent can specialized models, boasting billions of parameters, excel in context-aware instruction following? (3) is it possible to navigate the trade-off between performance and privacy through collaborations between large and small models? as indicated in figure 1 , considering the following scenario in ➍: smaller, personalized lms are deployed on user devices with limited resources. these slms can access private data and activity logs on the devices while processing instructions. in contrast, the more advanced general llms operate on cloud services and receive only general instructions. in this setup, the llms provide high-level knowledge like deeper planning, superior outlines, and even "dark knowledge". meanwhile, the slms utilize the context information and knowledge provided by the llms to collaboratively generate personalized content. current privacy protection methods for api-based services are limited @xcite ; they are either capable of handling only simple classification tasks with text sanitization @xcite or require encryption or noise addition @xcite , which still pose a risk of data leakage. in contrast, the collaborative generation approach involving slms and llms can logically prevent privacy breaches without the need to upload context information. overall, we highlight our contributions as follows: (1) we introduce the context-aware instruction-following task that incorporates extensive user privacy context information. to support this, we design a four-step data construction process and synthesize a modest amount of instructional data for experimental validation. (2) we investigate the performance of llms and slms on this task. our findings indicate that slms, when provided with context, can outperform llms lacking context but lag behind the performance of llms equipped with context. (3) for contextaware instruction generation, we present the co-genesis framework. cogenesis comprises sketchbased and logit-based variants to facilitate collaboration between large and small language models. this approach not only safeguards context privacy but also ensures performance gains. ## discussion although our experiments have been limited to models of the same family using identical tokenizers, these methods could potentially be expanded through a tokenizer alignment strategy @xcite . this principle aligns with other logits-based decoding techniques such as speculative decoding, contrastive decoding. by aligning the tokens and probabilities of models with different tokenizers, it is feasible to facilitate knowledge transfer across various llms and slms. recent studies have demonstrated the potential to reconstruct prompts based on the distribution of next token tokens @xcite . however, the accuracy of extraction, particularly the exact match scores, remains discouragingly low. furthermore, since only the top-k logits for each token are utilized in our experimental, the cost of reconstruction is prohibitively high. therefore, logits-based collaboration remains sufficiently secure, and can be further enhanced with the implementation of encryption and noise addition algorithms. as shown in ## related works the advent of llms has revolutionized the field of instruction following, with models being trained on diverse and complex instruction sets, enabling them to perform a wide array of tasks from creative writing @xcite to coding @xcite and debugging @xcite . the push towards collecting highquality instruction data @xcite @xcite has allowed for the development of both proprietary and open-source medium-scale language models adept at following instructions. however, the reliance on cloudbased proprietary models like chatgpt and gpt-4 for instruction execution raises significant privacy concerns due to the potential risks associated with uploading sensitive data @xcite @xcite . to mitigate these risks, various privacy-preserving techniques have been employed, albeit with limitations in completely securing user data @xcite @xcite . furthermore, there is a notable gap in instruction datasets, particularly in the inclusion of contextual information @xcite , highlighting an area for further exploration in context-aware instruction formulation to enhance privacy and personalization. in parallel, the exploration of mixed-scale model collaboration emerges as a promising avenue to address the scalability, efficiency @xcite , and privacy @xcite challenges inherent to llms. while larger models benefit from increased capabilities, their high inference costs and privacy concerns contrast with the lower costs and greater accessibility of smaller models @xcite @xcite @xcite . research in this domain is bifurcated into collaborative training and inference strategies, including offsite-tuning @xcite and speculative decoding @xcite , aiming to leverage the strengths of both large and small models @xcite . this paper specifically investigates collaborative inference methods, including sketch-based and logit-based approaches, to enhance the efficiency and privacy of llms, suggesting a promising direction in utilizing mixed-scale models for instruction following tasks. ## conclusion this paper investigates context-aware instruction following, enriching prompts with detailed user privacy information. we outline a pipeline for creating context-aware instructions. to mitigate privacy issues, we introduce cogenesis, a collaborative framework between slms and llms utilizing sketches and logits. our results highlight the advantages of mixed-scale model collaboration, suggesting fruitful directions for future research.