This is a Retrieval-Augmented Generation (RAG) project that automates the creation of personalized cold emails for prospective Master's or PhD students reaching out to professors. It leverages vector search and large language models to craft highly tailored emails based on both the applicantβs and professorβs information.
- Generates emails based on:
- Applicant's profile and academic background
- Professor's research interests and works
- Papers read (or smart matching if no papers are read)
- Smart fallback:
If no papers have been read, the system automatically matches professor's papers to the applicant's research experience. - Human-like personalization:
Emails are crafted to feel genuine, motivated, and thoughtful. - Auto-save:
Generated emails are saved neatly with timestamps for easy later editing.
βΌοΈ Note:
Please review and edit the email slightly before sending. While the LLM does a good job, small personal tweaks make it even better.
- Run the project locally
- Add a working mechanism with a workflow diagram
- Integrate Streamlit app support
- Extend to full-stack application support
- Core Programming Language: Python
- LLM Framework: LangChain
- Vector Database: FAISS
- Web Scraping: BeautifulSoup4
- Chat Model: llama-4-maverick-17b-128e-instruct (Groq Cloud)
- Embedding Model: jina-embeddings-v3 (Jina AI)
- Reranking Model: rerank-v3.5 (Cohere AI)
cold-mail-generator/
βββ composer/
β βββ draft_mail.py # Generates and formats the email draft
β βββ prompts.py # Contains prompt templates for the LLM
β
βββ configs/
β βββ model_config.py # Configuration settings for the models (language, embedding, reranking)
β
βββ env/ # Virtual environment directory
β
βββ outputs/ # Stores generated emails with timestamps
β
βββ processing/
β βββ data_cleaning.py # Cleans and preprocesses scraped data and features
β βββ database.py # Handles data storage and embeddings
β βββ retrieval.py # Extracts relevant information from database
β
βββ scraping/
β βββ scrape_prof.py # Scrapes professor's information
β βββ scrape_user.py # Processes applicant's information
β
βββ .env # Environment variables (e.g., API keys)
βββ .gitignore # Specifies files and folders to ignore in Git
βββ README.md # Project documentation
βββ main.py # Main script to run the application
βββ requirements.txt # Dependencies
- Python 3.9
- Git installed on your system
-
Clone the repository
git clone https://github.com/arpon-kapuria/cold-mail-generator.git cd cold-email-generator -
Create and activate a virtual environment
python3.9 -m venv env source env/bin/activate # On Windows: env\Scripts\activate
-
Install project dependencies
pip3.9 install -r requirements.txt # If the above doesn't work, try: pip install -r requirements.txt -
Set up environment variables
Create a
.envfile in the root directory and add necessary environment variables:GROQ_API_KEY="groq_api_key" JINA_API_TOKEN="jina_api_token" COHERE_API_KEY="cohere_api_key"
-
Launch the Streamlit app
streamlit run main.py
-
Result
- Your generated cold email will be printed on the screen AND saved automatically as a .txt file with the current date and time inside the
outputs/folder. - The email file will be named like:
Email_YYYY-MM-DD_HH-MM-SS.txt
- Your generated cold email will be printed on the screen AND saved automatically as a .txt file with the current date and time inside the
-
Prompt Template
Customize the tone, structure, and content of the generated emails by editingcomposer/prompts.py. -
Model Settings
Adjust LLM parameters such as model name, temperature, and others inconfigs/model_config.py. -
Data Cleaning & Retrieval
Improve or modify the data processing logic inside theprocessing/directory. -
Reranking
Reranker support is available inprocessing/retrieval.pyto retrieve more relevant information.
(Note: Reranking is currently optional and not enabled by default.)
.envmust be configured properly with the required keys.- Internet connection is required for scraping professor data and calling the language model API.
- Use responsibly and ethically while contacting professors.
Contributions are always welcome. Potential areas to work on -
-
Data Formatting & Chunking:
Enhance how data is preprocessed before storing it into the database for better retrieval efficiency. -
Improved Retrieval:
Implement smarter techniques to fetch more relevant and similar information from the vector database. -
Advanced Reranking:
Integrate reranker models more effectively to prioritize the most contextually relevant results. -
Prompt Engineering:
Design even better prompts to guide the LLM into generating more precise, context-aware, and impactful emails.
This project is licensed under the MIT License.