Gemma-2B-it Corporate Mail Assistant
This repository contains LoRA (Low-Rank Adaptation) adapters for the google/gemma-2b-it model, fine-tuned to act as a formal corporate mail assistant.
The model is trained to take a high-level intent and a dictionary of details and generate a professional, concise email suitable for a corporate environment.
Fine-tuning Procedure
This model was fine-tuned using the PEFT library on a custom dataset of prompt-completion pairs.
- Base Model:
google/gemma-2b-it - Library:
PEFT (LoRA) - Key Hyperparameters:
r(rank): 16lora_alpha: 32target_modules:["q_proj", "k_proj", "v_proj", "o_proj"]
How to Use
To use these adapters, you must load the base gemma-2b-it model and then apply the PEFT adapters on top.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
# Your HF username and the repo name you chose
repo_id = "darshandugar/Corporate-Email-Response-Generator-gemma-2b" # <-- CHANGE THIS
base_model_id = "google/gemma-2b-it"
# Load the base model (quantized for efficiency)
base_model = AutoModelForCausalLM.from_pretrained(
base_model_id,
device_map="auto",
torch_dtype=torch.bfloat16
)
tokenizer = AutoTokenizer.from_pretrained(base_model_id)
# Load the PEFT adapters
model = PeftModel.from_pretrained(base_model, repo_id)
model.eval()
# Prepare the prompt
prompt = "As a corporate assistant, write a formal email based on the following intent and details. Intent: Merger Announcement. Details: Verification API: SUCCESS. Ticket #T5821 raised for SM approval."
formatted_prompt = f"<start_of_turn>user\n{prompt}<end_of_turn>\n<start_of_turn>model\n"
# Generate the response
inputs = tokenizer(formatted_prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(**inputs, max_new_tokens=200, temperature=0.2)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
completion = response.split("<start_of_turn>model\n")[-1]
print(completion)
Input and Output Format
The model expects a structured prompt that clearly defines its role, intent, and details.
Input Format
The prompt should be structured within Gemma's turn-based format:
<start_of_turn>user\n{PROMPT}<end_of_turn>\n<start_of_turn>model\n
Where {PROMPT} is a string like:
"As a corporate assistant, write a formal email based on the following intent and details. Intent: {INTENT}. Details: {DETAILS}"
Example Input Details:
{
"INTENT": "Sustainability Initiative",
"DETAILS": "User asked for water usage metrics. RAG system found no specific data for 'water usage' in the latest report."
}
Output Format
The model will generate a complete, formal email as a string.
Example Output:
Dear Stakeholder,
Thank you for your inquiry. While our latest sustainability report details our progress in areas like carbon emissions, it does not contain specific metrics on water usage.
Your query has been forwarded to the sustainability department for more detailed information.
Sincerely,
Corporate Assistant
- Downloads last month
- 44
Model tree for darshandugar/Corporate-Email-Response-Generator-gemma-2b
Base model
google/gemma-2b-it