| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Train Panza on your own data for free with a Lightning Studios account here:
Interact with Panza models we trained on our test datasets here:
Our datasets are also available on Huggingface:
Panza is an automated email assistant customized to your writing style and past email history.
Its main features are as follows:
For most email clients, it is possible to download a user's past emails in a machine-friendly .mbox format. For example, GMail allows you to do this via Google Takeout, whereas Thunderbird allows one to do this via various plugins.
One key part of Panza is a dataset-generation technique we call data playback: Given some of your past emails in .mbox format, we automatically create a training set for Panza by using a pretrained LLM to summarize the emails in instruction form; each email becomes a (synthetic instruction, real email) pair. Given a dataset consisting of all pairs, we use these pairs to "play back" your sent emails: the LLM receives only the instruction, and has to generate the "ground truth" email as a training target.
We find that this approach is very useful for the LLM to "learn" the user's writing style.
We then use parameter-efficient finetuning to train the LLM on this dataset, locally. We found that we get the best results with the RoSA method, which combines low-rank (LoRA) and sparse finetuning. If parameter efficiency is not a concern, that is, you have a more powerful GPU, then regular, full-rank/full-parameter finetuning can also be used. We find that a moderate amount of further training strikes the right balance between matching the writer's style without memorizing irrelevant details in past emails.
Once we have a custom user model, Panza can be run locally together with a Retrieval-Augmented Generation (RAG) module. Specifically, this functionality stores past emails in a database and provides a few relevant emails as context for each new query. This allows Panza to better insert specific details, such as a writer's contact information or frequently used Zoom links.
The overall structure of Panza is as follows:
We tested Panza using python 3.10. If you are running a different version, you can either install it directly or, for instance, using miniconda:
conda create -n panza python=3.10 -y
conda activate panzaThen, Install the required packages:
pip install .If you want to also finetune models using Panza, you will need to install additional packages:
pip install .[training]To quickly get started with building your own personalized email assistant, follow the steps bellow:
Expand for detailed download instructions.We provide a description for doing this for GMail via Google Takeout.
For Outlook accounts, we suggest doing this via a Thunderbird plugin for exporting a subset of your email as an MBOX format, such as this add-on.
At the end of this step you should have the downloaded emails placed inside data/Sent.mbox.
Panza is configured through a set of yaml configurations defined in configs/. There is a single high-level config under configs/base.yaml, and the rest are organized under the main functionalities of the code. Note that these task-specific configs can, in some cases, be used to override base configs. Specific use cases, such as hyperparameter tuning, are covered in more detail in scripts/README.md.
These scripts are described in more detail in scripts/README.md, but a few customizations need to happen immediately. :warning: Before continuing, make sure you complete the following setup:
Additionally, please perform the following login steps to be able to download the base model.
You are now ready to move to scripts.
cd scriptsRun CUDA_VISIBLE_DEVICES=X ./prepare_data.sh.
This scripts takes care of all the prerequisites before training (expand for details).- Extracts your emails in text format to `data/<username>_clean.jsonl` which you can manually inspect. - Creates synthetic prompts for your emails as described in the [data playback](#film_projector-step-1-data-playback) section. The results are stored in `data/<username>_clean_summarized.jsonl` and you can inspect the `"summary"` field. - Splits data into training and test subsets. See `data/train.jsonl` and `data/test.jsonl`. - Creates a vector database from the embeddings of the training emails which will later be used for *Retrieval-Augmented Generation (RAG)*. See `data/<username>.pkl` and `data/<username>.faiss`.
NB: if you did not change the default configuration in user/default.yaml to reflect your particulars but rather created a new file, you need to add the additional flag to the above command where you specify user=x where your config file was named x.yaml.
FAQs. When running the above script, you may encounter an OutOfMemoryError. If this is the case, you can either:We currently support LLaMA3-8B-Instruct and Mistral-Instruct-v0.2 LLMs as base models; the former is the default, but we obtained good results with either model.
[Recommended] For parameter efficient fine-tuning, run ./train_rosa.sh.
If a larger GPU is available and full-parameter fine-tuning is possible, run ./train_fft.sh.
We have prepopulated the training configs with parameter values that worked best for us. We recommend you try those first, but you can also experiment with different hyper-parameters by passing extra arguments to the training script, such as lr, lora_lr, num_epochs. All the trained models are saved in the checkpoints directory.
Examples:
CUDA_VISIBLE_DEVICES=X ./train_rosa.sh # Will use the default parameters.
CUDA_VISIBLE_DEVICES=X ./train_rosa.sh finetuning.lr=1e-6 finetuning.rosa_lr=1e-6 finetuning.max_duration=7epOn a smaller GPU, it may be necessary to further train in lower precision (QRoSA). This can be run as follows:
./train_rosa.sh finetuning.precision=amp_bf16 finetuning.model.weight_bias_dtype=4bitIn addition to the Panza package itself, we have also created a tool that will allow you to use Panza directly within your Gmail session. We have published this extension on Google Chrome here. Here is a written guide on how to get this setup below.
📧 Have fun with your new email writing assistant! 📧
If you liked our work and want to contribute to improve the system, please feel free to do so! Make a fork of our repository and once you have made your changes, submit a pull request so that we can review!
One thing to mention: we want to make sure that we all adhere to the same coding standards, so we have added Black, a code formatter, as a prehook. To ensure that all your files are formatted with Black, do the following:
pip install .[contributing]
pre-commit install
The goal of Panza is to give users full control of their data and models trained on it. As such, no part of Panza, including the Chrome/GMail plugin collects any information about its users, outside of the normal summary statistics collected by Github and Google (such as the number of stars/forks/downloads). If you choose to run any part of Panza on a hosted service, e.g., on Amazon Web Services or Google Colab, we take no responsibility for any data collection or data breaches that may occur. Additionally, running the Panza web client or the GUI interface (via Gradio) risks providing unauthorized access to the models. Please use at your own risk.
Panza was conceived by Nir Shavit and Dan Alistarh and built by the Distributed Algorithms and Systems group at IST Austria. The contributors are (in alphabetical order):
Dan Alistarh, Eugenia Iofinova, Andrej Jovanovic, Eldar Kurtic, Ilya Markov, Armand Nicolicioiu, Mahdi Nikdan, Andrei Panferov, Nir Shavit, and Sean Yang.
Contact: dan.alistarh@ist.ac.at
We thank our collaborators Michael Goin and Tony Wang at NeuralMagic and MIT for their helpful testing and feedback.
| Back | FazBrowse Home | New Git URL |