You need to agree to share your contact information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

Model Card for Model ID

duo-mate is a fine-tuned version of the google/gemma-2b-it model, designed for generating professional email replies and extracting structured information from emails. It can process email data (including to, from, subject, and body) to extract metadata such as event titles, dates, times, urgency levels, and keywords, and generate concise, professional reply emails. The model is optimized for text generation tasks in English and uses the PEFT (Parameter-Efficient Fine-Tuning) library with LoRA (Low-Rank Adaptation) for efficient fine-tuning.

Model Description

duo-mate is a causal language model fine-tuned from google/gemma-2b-it using LoRA for efficient adaptation. It is designed to assist with email-related tasks, specifically:

  • Extracting structured information from emails, such as event titles, dates, times, urgency levels, and keywords.

  • Generating professional reply emails with fields like Reply-To, Reply-From, Reply-Subject, and Reply-Body.

  • The model was fine-tuned on a custom dataset of email data, enabling it to understand email contexts and produce relevant, professional responses. It leverages 4-bit quantization for efficient inference on resource-constrained hardware.

    • Developed by: [Chintakrindi Kumar Kartik and Kanak Raj Arora]
    • Model type: [Causal Language Model (fine-tuned with LoRA)]
    • Language(s) (NLP): [English (en)]
    • License: [MIT]
    • Finetuned from model: [google/gemma-2b-it]

Uses

Direct Use

Hackcrux-Gemma can be used directly for:

  • Extracting structured metadata (e.g., event title, date, time, urgency, keywords) from emails.
  • Generating professional reply emails based on the input email's context.
  • It is intended for users who need automated email processing, such as individuals, businesses, or organizations managing email correspondence.

Downstream Use

The model can be further fine-tuned or integrated into larger applications, such as:

  • Email management systems for automated reply generation.
  • Customer support tools to assist with drafting responses.
  • Event management platforms to extract event details from email invitations.

Out-of-Scope Use

The model is not suitable for:

  • Generating replies in languages other than English.
  • Handling highly sensitive or confidential email content without proper security measures.
  • Tasks requiring factual accuracy beyond the email context (e.g., answering general knowledge questions).
  • Processing emails with complex formatting (e.g., HTML emails) without preprocessing.

Bias, Risks, and Limitations

Bias and Risks:

  • Bias in Training Data: The model was fine-tuned on a custom dataset of emails, which may contain biases present in the data (e.g., tone, formality, or cultural norms). This could lead to biased or inappropriate replies if the training data is not diverse.
  • Hallucination Risk: The model may generate incorrect or irrelevant information (e.g., wrong dates, events, or keywords) if the email content is ambiguous or outside the training distribution.
  • Privacy Concerns: If used on real email data, the model may process sensitive information. Users must ensure proper data handling and compliance with privacy regulations (e.g., GDPR).

Limitations:

  • The model is limited to English-language emails and may not perform well on other languages.
  • It may struggle with emails that lack clear structure or contain ambiguous information.
  • The generated replies may occasionally repeat content or include hallucinations, requiring post-processing.
  • The modelโ€™s performance depends on the quality and diversity of the fine-tuning dataset, which is not publicly available.

Recommendations:

  • Bias Mitigation: Users should review the generated replies and extracted information for appropriateness, especially in professional or sensitive contexts.
  • Privacy: Ensure that email data processed by the model is anonymized or handled securely to protect user privacy.
  • Post-Processing: Implement post-processing to filter out repetitions or hallucinations in the generated output.
  • Testing: Test the model on a diverse set of emails to identify and address any biases or limitations.

How to Get Started with the Model

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
from peft import PeftModel

# Load tokenizer and model
model_name = "ch-kumar-kartik/duo-mate"
tokenizer = AutoTokenizer.from_pretrained(model_name)
tokenizer.pad_token = tokenizer.eos_token

# Define quantization config for efficient inference
bnb_config = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_compute_dtype=torch.float16,
    bnb_4bit_use_double_quant=True,
    bnb_4bit_quant_type="nf4"
)

# Load the base model with quantization
base_model = AutoModelForCausalLM.from_pretrained("google/gemma-2b-it", quantization_config=bnb_config)

# Load the fine-tuned LoRA adapters
model = PeftModel.from_pretrained(base_model, model_name)
model.eval()
model.to("cuda")  # Move to GPU if available

# Function to extract structured information from an email
def generate_info(email):
    prompt = (
        f"Extract structured information from the following email:\n\n"
        f"Email Details:\n"
        f"To: {email['to']}\n"
        f"From: {email['from']}\n"
        f"Subject: {email['subject']}\n"
        f"Body: {email['body']}\n\n"
        f"Extract the following information and provide the actual values:\n"
        f"- Event Title: The title of the event\n"
        f"- Urgency: The urgency level (e.g., Low, Medium, High)\n"
        f"- Event Date: The date of the event\n"
        f"- Event Time: The time of the event\n"
        f"- Keyword(s): Relevant keywords from the email\n"
        f"Ensure the extracted information is accurate and relevant to the email."
    )

    inputs = tokenizer(prompt, return_tensors="pt", truncation=True, max_length=512).to("cuda")
    output = model.generate(
        **inputs,
        max_length=450,
        num_beams=4,
        no_repeat_ngram_size=2,
        temperature=0.7,
        top_k=50
    )
    generated_text = tokenizer.decode(output[0], skip_special_tokens=True)

    # Post-process to extract structured fields
    extracted_info = {
        "event_title": "Not specified",
        "urgency": "Not specified",
        "date": "Not specified",
        "time": "Not specified",
        "keyword": "Not specified"
    }
    lines = generated_text.split("\n")
    for line in lines:
        if line.startswith("- Event Title:"):
            extracted_info["event_title"] = line.replace("- Event Title:", "").strip()
        elif line.startswith("- Urgency:"):
            extracted_info["urgency"] = line.replace("- Urgency:", "").strip()
        elif line.startswith("- Event Date:"):
            extracted_info["date"] = line.replace("- Event Date:", "").strip()
        elif line.startswith("- Event Time:"):
            extracted_info["time"] = line.replace("- Event Time:", "").strip()
        elif line.startswith("- Keyword(s):"):
            extracted_info["keyword"] = line.replace("- Keyword(s):", "").strip()

    return extracted_info

# Function to generate a professional reply email
def generate_reply(email):
    prompt = (
        f"Generate a professionally worded reply email based on the following details:\n\n"
        f"Original Email:\n"
        f"To: {email['to']}\n"
        f"From: {email['from']}\n"
        f"Subject: {email['subject']}\n"
        f"Body: {email['body']}\n\n"
        f"Reply Email Format (provide the actual values):\n"
        f"Reply-To: The recipient's email address\n"
        f"Reply-From: The sender's email address\n"
        f"Reply-Subject: The subject line of the reply\n"
        f"Reply-Body: The body of the reply email\n\n"
        f"Ensure the reply is concise, professional, and relevant to the original email."
    )

    inputs = tokenizer(prompt, return_tensors="pt", truncation=True, max_length=512).to("cuda")
    output = model.generate(
        **inputs,
        max_length=450,
        num_beams=4,
        no_repeat_ngram_size=2,
        temperature=0.7,
        top_k=50
    )
    generated_text = tokenizer.decode(output[0], skip_special_tokens=True)

    # Post-process to extract reply fields
    reply_info = {
        "reply_to": "Not specified",
        "reply_from": "Not specified",
        "reply_subject": "Not specified",
        "reply_body": "Not specified"
    }
    lines = generated_text.split("\n")
    reply_body_lines = []
    in_reply_body = False
    for line in lines:
        if line.startswith("Reply-To:"):
            reply_info["reply_to"] = line.replace("Reply-To:", "").strip()
        elif line.startswith("Reply-From:"):
            reply_info["reply_from"] = line.replace("Reply-From:", "").strip()
        elif line.startswith("Reply-Subject:"):
            reply_info["reply_subject"] = line.replace("Reply-Subject:", "").strip()
        elif line.startswith("Reply-Body:"):
            if not in_reply_body:
                in_reply_body = True
                reply_body_lines.append(line.replace("Reply-Body:", "").strip())
        elif in_reply_body:
            reply_body_lines.append(line.strip())

    if reply_body_lines:
        reply_info["reply_body"] = " ".join(reply_body_lines)

    return reply_info

# Example email
email_sample = {
    "to": "relatives@smith.com",
    "from": "mike@smith.com",
    "subject": "To invite someone to a family reunion",
    "body": "Hi Everyone,\n\nJoin us for a family reunion on June 15, 2025, at 1:00 PM at Lakeview Park. RSVP by May 15!\n\nBest,\nMike",
}

# Extract information
extracted_info = generate_info(email_sample)
print("Extracted Information:")
print(f"- Event Title: {extracted_info['event_title']}")
print(f"- Urgency: {extracted_info['urgency']}")
print(f"- Event Date: {extracted_info['date']}")
print(f"- Event Time: {extracted_info['time']}")
print(f"- Keyword(s): {extracted_info['keyword']}")

# Generate reply
reply_info = generate_reply(email_sample)
print("\nGenerated Reply:")
print(f"Reply-To: {reply_info['reply_to']}")
print(f"Reply-From: {reply_info['reply_from']}")
print(f"Reply-Subject: {reply_info['reply_subject']}")
print(f"Reply-Body: {reply_info['reply_body']}")

Training Details

Training Data

The model was fine-tuned on a custom dataset (dataset.json) containing email data with the following fields:

to, from, subject, body: The email content. event_title, urgency, date, time, keyword: Structured metadata extracted from the email. reply_to, reply_from, reply_subject, reply_body: The corresponding reply email fields. The dataset is not publicly available due to privacy concerns, as it may contain sensitive email information.

Training Procedure

Preprocessing:

The dataset was preprocessed to create input-output pairs for training:

  • Inputs: Concatenated email fields in the format To: {to} | From: {from} | Subject: {subject} | Body: {body}.
  • Outputs: Structured metadata and reply in the format Event Title: {event} | Urgency: {urgency} | Date: {date} | Time: {time} | Keyword: {keyword} | Reply-To: {reply_to} | Reply-From: {reply_from} | Reply-Subject: {reply_subject} | Reply-Body: {reply_body}.
  • The inputs and outputs were tokenized using the google/gemma-2b-it tokenizer with a maximum length of 512 tokens, applying truncation and padding as needed.

Training Hyperparameters:

  • Training regime: FP16 mixed precision
  • Batch size: 2 (per device)
  • Epochs: 10
  • Evaluation strategy: Per epoch
  • Save strategy: Per epoch
  • Logging steps: Every 10 steps
  • LoRA parameters:
    • r: 8
    • lora_alpha: 32
    • lora_dropout: 0.1
    • task_type: Causal Language Model (CAUSAL_LM)

Speeds, Sizes, Times:

  • Training duration: Approximately 1-2 hours (depending on hardware).
  • Hardware: NVIDIA RTX 4050 (laptop) with 6GB VRAM.
  • Checkpoint size: Approximately 2.5 GB (quantized model with LoRA adapters).

Evaluation

Testing Data, Factors & Metrics

Testing Data

The model was evaluated on a validation set created from a 90/10 train-validation split of the custom dataset. The validation set contained 10% of the total email data.

Factors

Evaluation was performed on the following factors:

  • Email type: Invitations, announcements, requests, etc.
  • Complexity: Emails with varying levels of detail (e.g., clear event details vs. ambiguous content)

Metrics

  • Loss: Training and evaluation loss were tracked using the transformers.Trainer API.
  • Qualitative Assessment: Manual inspection of generated replies and extracted information for relevance, professionalism, and accuracy.

Results

  • Training Loss: Decreased from 22.07 to 5.28 over 10 epochs.
  • Evaluation Loss: Decreased from 12.85 to 5.30 over 10 epochs.
  • Qualitative Results: The model successfully generated professional replies and extracted relevant metadata for most emails, though it occasionally produced repetitions or hallucinations, which were mitigated with post-processing.

Summary

The model performs well on structured email tasks but may require additional fine-tuning for more diverse or ambiguous email content. Post-processing is recommended to handle repetitions and hallucinations.

Environmental Impact

Carbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).

  • Hardware Type: [NVIDIA RTX 4050 (6GB VRAM)]
  • Hours used: [Approximately 2 hours for fine-tuning]
  • Cloud Provider: [More Information Needed]
  • Compute Region: [More Information Needed]
  • Carbon Emitted: [Estimated at 0.5-1 kg CO2eq (based on local energy grid and hardware efficiency)]

Technical Specifications

Model Architecture and Objective

  • Architecture: Gemma-2B (a transformer-based causal language model) with LoRA adapters for efficient fine-tuning.
  • Objective: To generate professional email replies and extract structured metadata from email content.

Hardware

NVIDIA RTX 4050 (6GB VRAM)

Software

  • Transformers: Hugging Face transformers library
  • PEFT: Parameter-Efficient Fine-Tuning library (version 0.15.0)
  • PyTorch: For model training and inference
  • Weights & Biases: For logging training metrics

Citation

This model does not have an associated paper or blog post. For attribution, please cite the Hugging Face model card

BibTeX:

@misc{hackcrux-gemma,
  author = {Chintakrindi Kumar Kartik and Kanak Raj Arora},
  title = {Hackcrux-Gemma: A Fine-Tuned Model for Email Reply Generation and Metadata Extraction},
  year = {2025},
  publisher = {Hugging Face},
  journal = {Hugging Face Model Hub},
  howpublished = {\url{https://huggingface.co/kanakrajarora/hackcrux-gemma}}
}

APA:

Chintakrindi Kumar Kartik, & Kanak Raj Arora. (2025). Hackcrux-Gemma: A Fine-Tuned Model for Email Reply Generation and Metadata Extraction. Hugging Face Model Hub. https://huggingface.co/https://huggingface.co/ch-kumar-kartik/duo-mate

Model Card Authors

  • Chintakrindi Kumar Kartik
  • Kanak Raj Arora

Model Card Contact

For questions or feedback, please contact Chintakrindi Kumar Kartik via the Hugging Face platform or at kartik.kumar.chintakrindi@gmail.com

Framework versions

  • PEFT 0.15.0
  • Transformers (compatible with PEFT 0.15.0)
  • PyTorch (version compatible with CUDA and the RTX 4050)
Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for ch-kumar-kartik/duo-mate

Base model

google/gemma-2b-it
Adapter
(646)
this model