How Developers are Using Offline AI Tools for Air-Gapped Security
Tags: chatgpt, ai, security, devtool
Published: 2023-12-07 18:30:32

Artificial Intelligence has experienced a remarkable surge recently, marked by the emergence of platforms such as OpenAI's ChatGPT, Google Bard, and others. It is no surprise, these platforms have gained significant attention, captivating billions of users worldwide. In a 2023 survey sponsored by GitHub, it was found that 92% of developers are already using coding tools.

AI assists developers by automating tasks, improving code quality through bug detection and optimization, enhancing collaboration, and providing personalized development experiences/ While we can say that AI makes our lives as developers easier, we also need to consider the data and [code security](https://code.pieces.app/blog/code-security-best-practices-protecting-projects-when-using-ai) issues with these cloud-based models.

## Code and Data Security Concerns Regarding Cloud-Based Models

ChatGPT, developed by OpenAI, is an example of a cloud-based model. Instead of running on an individual's computer, ChatGPT operates on powerful servers hosted on the cloud. Users interact with the model via the [ChatGPT API](https://code.pieces.app/blog/guide-to-chatgpt-api-implementation-for-developers) (Application Programming Interface) over the internet. When a user sends a prompt or query, it is transmitted to the cloud servers where the model processes the input, generates a response, and sends it back to the user.

**Unfortunately, using cloud-based models like ChatGPT endangers your data and code privacy as a developer.**

According to the Open AI [privacy policy](https://openai.com/policies/privacy-policy), collected data includes a long list, but these two are our strongest concerns in this article:

- **Usage data**: This includes how you use and engage with the service. Your software version, connection information, and so on.
- **User content**: Every conversation that you have with ChatGPT is stored by Open AI.


[Open AI says that ChatGPT is also trained using data it receives](https://help.openai.com/en/articles/5722486-how-your-data-is-used-to-improve-model-performance), including potentially sensitive code, data confidential to your company, or intellectual property that you may wish to keep private. There is a possibility that ChatGPT could potentially share such information with vendors, service providers, legal entities, and so on upon request, unless users opt out of sharing personal information. But then how does it define ‘personal’? Is it a risk worth taking?

In a recent occurrence, [three Samsung employees leaked sensitive data to ChatGPT](https://www.engadget.com/three-samsung-employees-reportedly-leaked-sensitive-data-to-chatgpt-190221114.html). Consider the significant repercussions a major company could encounter by entrusting sensitive information to a model that isn’t air-gapped. Samsung has allegedly restricted the usage of ChatGPT on company devices to the bare minimum, and is working on building its own chatbot to minimize these risks. Other companies like Amazon, Verizon, and JP Morgan have also restricted the use of ChatGPT in their daily operations due to security concerns.

An earlier incident occurred when individuals on social media platforms such as [Twitter](https://twitter.com/iamvarung/status/1637849552941375488) and [Reddit](https://www.reddit.com/r/ChatGPT/comments/11wkw5z/has_chatgpt_or_me_been_hacked_ive_never_had_these/) reported instances of viewing chat histories that did not belong to them. These occurrences raised significant concerns regarding the sharing of sensitive data with cloud-based models.

Even as recent as Tuesday, [ChatGPT was found to have revealed](https://www.businessinsider.com/chatgpt-ai-refuse-to-respond-prompt-asking-repeat-word-forever-2023-12) a real email address and phone number after researchers asked it to repeat the word "poem" forever."

Think about your chat history showing up on someone else's device, along with a sensitive code or important company info. Sounds risky, doesn't it? Italy, France, and Spain have also expressed their concerns regarding data privacy issues. So is the problem with this particular set of models? Or are all cloud-based LLMs at risk?

## Introducing Offline AI as a Solution

Offline AI, also known as on-device AI or [Local LLMs (LLLMs)](https://code.pieces.app/blog/local-large-language-models-lllms-and-copilot-integrations), refers to artificial intelligence systems that operate locally on a device without the need for a continuous internet connection. Unlike cloud-based AI models that require internet access to process data on remote servers, offline AI functions independently on the device where it is installed.

### What are the Challenges of Cloud-Based Models?

The need for solutions beyond cloud-based models in terms of data and code privacy arise from several critical considerations:

1. **Enhanced Security:** Cloud-based models involve transmitting data to external servers for processing, which raises security concerns. Storing and processing sensitive information locally, as in on-device solutions, can significantly reduce the risk of unauthorized access and potential data breaches.
1. **Regulatory Compliance**: Different regions and industries have varying data protection regulations. Some regulatory frameworks require certain data to be stored and processed within specific geographic boundaries. On-device solutions provide a way to comply with these regulations without relying on external cloud infrastructure.
1. **User Privacy and Control**: Storing and processing data locally gives users more control over their information. With on-device solutions, users can have increased confidence that their data remains on their own devices, addressing concerns related to privacy and the potential misuse of personal information.
1. **Protection of Intellectual Property**: For organizations dealing with proprietary code and intellectual property, on-device solutions provide an additional layer of protection. Keeping sensitive code and algorithms within the organization's control helps mitigate the risk of unauthorized access or intellectual property theft.
1. **Customization and Adaptability**: On-device solutions offer more flexibility for customization. Organizations can tailor models and algorithms to specific needs without relying on third-party cloud services, allowing for greater adaptability to unique requirements and use cases.


Solutions beyond cloud-based models are essential to address diverse needs related to security, compliance, user privacy, and operational efficiency, providing organizations with more comprehensive options to protect sensitive data and code.

### How Do Offline AI Tools Solve Code Security Issues?

Using AI offline resolves code and data privacy concerns by prioritizing local processing on the user's device, mitigating the need for external data transmission and dependence on cloud-based services. This approach ensures that sensitive code and data remain within the confines of the device, minimizing the risk of unauthorized access during data transmission.

With limited exposure to external networks, offline AI software enhances overall security, grants users greater control over their data, and aids in compliance with data protection regulations.

## Introducing Pieces as a Solution for Code Security

In the tech space driven by data and code privacy concerns, we recognize the need for a robust solution that operates independently on developers' devices. Our free offline AI features tackle these issues head-on by ensuring local processing, reducing exposure to external networks, and fostering greater control over sensitive code and data.

Elevate your development workflow with Pieces for Developers, where innovation meets security, providing a seamless and private coding experience for developers.

### How does Pieces achieve this?

Pieces has some technologies and infrastructure that enable offline AI functionality, and we are going to look at the most important factors that you should know about.

#### Local Large Language Models

Large language models are artificial intelligence models trained on a vast amount of data and parameters to enable natural language processing. Local large language models are ones that, despite robust complexity similar to other popular large language models, can operate within a local environment.

[Meta has introduced local large language models](https://arstechnica.com/information-technology/2023/02/chatgpt-on-your-pc-meta-unveils-new-ai-model-that-can-run-on-a-single-gpu/) like Llama 2 and CodeLlama (Large language Model Meta AI) that can run on a single GPU with smaller weights and fewer parameters, enabling them to operate on local devices, PCs, and smartphones.

[Llama2](https://ai.meta.com/llama/), which is one of Meta's most recent models, is open source, pre-trained, and fine-tuned with parameters ranging from 7B to 70B. [Compared to GPT-3,](https://macpaw.tech/research/local-gpt-models/) this model is relatively lighter in weight by parameters but is more efficient on most benchmarks and also outperforms other open-source models.

[Pieces uses Local LLMs like Llama 2](https://code.pieces.app/blog/local-large-language-models-lllms-and-copilot-integrations) to power its on-device usage of the [Pieces Copilot](https://code.pieces.app/blog/introducing-pieces-copilot) which offers unique features extending beyond mere code generation or question and answering. It revolves around comprehending your workflow with [retrieval augmented generation](https://code.pieces.app/blog/retrieval-augmented-generation-for-curation), understanding team dynamics with related-people metadata, and connecting your toolchain with various integrations.

This involves capturing and accessing the context, allowing the copilot to deliver information in a natural conversational format, all while upholding code and data privacy which is demonstrated through the execution of large language models locally with Pieces, directly on the device.

#### Small Language Models for Enterprises

[Small language models](https://code.pieces.app/blog/small-language-models-outshine-large-language-models-enterprise-users) refer to artificial intelligence models designed with fewer parameters and less computational complexity compared to their larger counterparts. These diluted models offer a solution to the limitations of large language models, including their size, computational requirements, and high operational costs.

Small language models are easier to train, as they consume less data and fewer parameters, resulting in lower hardware consumption costs and more effective expense management for enterprises. Due to their relative size, they are easily customizable to the organization's needs through targeted training, enhancing accuracy and reducing bias.

Edge learning machine models, also known as small language models, can run on-device due to their compact size, ensuring the data and code security of your organization are prioritized and maintained.

## On-Device Pieces Copilot Features

The models discussed earlier make Pieces able to do a lot of helpful things for developers locally on-device, boosting their productivity in their work and maintaining privacy. Some of these include:

1. [On-Device Auto-Enrichment](https://docs.pieces.app/features/auto-enrichment)**:** When you save code snippet to Pieces, we use fine-tuned models to instantly detect the language, add syntax highlighting, and augment your code snippet with useful context and metadata such as a title, description, tags, related links, and related people. This helps developer’s stay more organized, streamlining sharing and reuse.
1. [Optional Character Recognition (OCR) Technology](https://code.pieces.app/blog/how-we-made-our-optical-character-recognition-ocr-code-more-accurate)**:** It involves recognizing printed or handwritten texts from digital images or printed documents. This technology is used to convert code snippets or text from screenshots instantly. For example, you could take a screenshot of code from YouTube and decide to extract the code text. Not only are we doing OCR, but we have on-device ML models to auto-correct any potential defects in the code.
1. **On-Device features on Pieces desktop app, VS Code and Obsidian:** Whether you’re chatting with Pieces Copilot on the desktop app, VS Code, IntelliJ, Obsidian, or another tool, [you can now choose](https://code.pieces.app/updates/on-device-llms-pieces-for-developers-270-pieces-os-620) to opt-in to on-device LLMs for code generation and other features. With this option, you can make the right choice according to your environment.


## Benefits of Offline Generative AI for Developers

1. **Enhanced Privacy**: Using an AI chatbot offline contributes to enhanced privacy. By processing sensitive data locally, it eliminates the need to transmit information over the internet. This not only mitigates concerns about potential data breaches or unauthorized access, but also empowers users with greater control over their personal information.
1. **Reduced Latency**: Offline AI softwares typically exhibit reduced latency as they don't rely on a constant internet connection for computations. Processing data locally leads to quicker response times.
1. **Operability in Limited Connectivity Environments**: One of the significant advantages of offline AI tools is the ability to operate in environments with limited or no internet connectivity. This ensures the continuity of AI-driven services in remote areas or situations where establishing a stable internet connection is challenging.


## Conclusion

We've explored the implications of cloud-based models on our data and code privacy, underscoring the significant role offline AI plays as a remedy to these vulnerabilities. To experience the benefits firsthand, [download the Pieces desktop app](https://docs.pieces.app/installation-getting-started/what-am-i-installing) and leverage its features to mitigate risks, ensuring enhanced data and code security. By doing so, you not only safeguard your privacy, but also cultivate a personalized and optimized development environment tailored to your unique needs and preferences.