This project demonstrates how to rewrite emails using a Language Learning Model (LLM) directly in the browser without requiring any network calls or external API interactions. The entire process runs locally on the client side, leveraging the power of modern JavaScript, WebAssembly, or Web Workers to run a lightweight, pre-trained LLM in the browser.
This approach ensures that all data remains local, providing increased privacy and security since no information is sent to a server.
- Local Model Execution: The entire rewriting process happens within the user's browser, using a compact version of an LLM that fits within the memory and processing capabilities of modern browsers.
- No Network or API Calls: Since the model operates locally, no external network requests are made, ensuring data privacy.
- Email Rewriting: Users can input a rough email draft, and the LLM will generate a more polished, professional, or customized version based on the context.
- Customizable Outputs: Users can tweak the output to change tone, formality, or style according to their needs.
- JavaScript: Core scripting language used to manage interactions, user input, and control the LLM execution.
- WebAssembly (Wasm): The model is compiled to WebAssembly for efficient execution within the browser.
- Web Workers: Optional, for running the model in the background without blocking the main thread, ensuring smooth user interaction.
The application is built on the following architecture:
- Input Area: A simple textarea for the user to write or paste their email draft.
- LLM Processor: A locally-hosted, compact version of an LLM loaded via WebAssembly or JavaScript.
- Rewrite Action: A button or event triggers the email rewriting process.
- Output Area: The rewritten email is displayed in a new text area, where users can copy or edit the generated content.
- Client-Side Execution: All computations, including tokenization, language generation, and rewriting, are performed client-side without any need for external APIs.
- Data Remains Local: All processing occurs on the user's machine. No data is transmitted over the network, ensuring privacy and security.
- No External Dependencies: Since no APIs or cloud-based services are used, the entire process is self-contained and independent of external servers.
- Model Size: Due to memory and processing constraints, the model may be significantly smaller than those used in cloud-based solutions. The local version is optimized for client-side execution but may not have the same accuracy as larger models.
- Performance: Running a full language model in the browser can be resource-intensive, and performance may vary depending on the user's device.
- Model Optimization: Further optimization of the LLM for reduced size and faster execution in the browser.
- Custom Tone and Style: Allow users to specify the tone (e.g., formal, casual, polite) or the purpose of the email (e.g., job application, complaint).
- Localization/Multilingual Support: Extend the model to support multiple languages for email rewriting.