This is a fine-tuned version of
BAAI/bge-m3 optimized for email content retrieval. The model was trained on a mixed-language (English/Korean) email dataset to improve retrieval performance for various email-related queries.
1from langchain.embeddings import HuggingFaceEmbeddings
2from langchain.vectorstores import FAISS
3from langchain.docstore.document import Document
4
5# Initialize the embedding model
6embeddings = HuggingFaceEmbeddings(
7 model_name="doubleyyh/email-tuned-bge-m3",
8 model_kwargs={'device': 'cuda'},
9 encode_kwargs={'normalize_embeddings': True}
10)
11
12# Example emails
13emails = [
14 {
15 "subject": "회의 일정 변경 안내",
16 "from": [["김철수", "kim@company.com"]],
17 "to": [["이영희", "lee@company.com"]],
18 "cc": [["박지원", "park@company.com"]],
19 "date": "2024-03-26T10:00:00",
20 "text_body": "안녕하세요, 내일 예정된 프로젝트 미팅을 오후 2시로 변경하고자 합니다."
21 },
22 {
23 "subject": "Project Timeline Update",
24 "from": [["John Smith", "john@company.com"]],
25 "to": [["Team", "team@company.com"]],
26 "cc": [],
27 "date": "2024-03-26T11:30:00",
28 "text_body": "Hi team, I'm writing to update you on the Q2 project milestones."
29 }
30]
31
32# Format emails into documents
33docs = []
34for email in emails:
35 # Format email content
36 content = "\n".join([f"{k}: {v}" for k, v in email.items()])
37 docs.append(Document(page_content=content))
38
39# Create FAISS index
40db = FAISS.from_documents(docs, embeddings)
41
42# Query examples (supports both Korean and English)
43queries = [
44 "회의 시간이 언제로 변경되었나요?",
45 "When is the meeting rescheduled?",
46 "프로젝트 일정",
47 "Q2 milestones"
48]
49
50# Perform similarity search
51for query in queries:
52 print(f"\nQuery: {query}")
53 results = db.similarity_search(query, k=1)
54 print(f"Most relevant email:\n{results[0].page_content[:200]}...")
1@misc{email-tuned-bge-m3,
2 author = {doubleyyh},
3 title = {Email-tuned BGE-M3: Fine-tuned Embedding Model for Email Content},
4 year = {2024},
5 publisher = {HuggingFace}
6}
This model follows the same license as the base model (bge-m3).
For questions or feedback, please use the GitHub repository issues section or contact through HuggingFace.