harshal15122003 commited on
Commit
d0f008e
Β·
verified Β·
1 Parent(s): 3ad39e3

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +137 -4
README.md CHANGED
@@ -2,13 +2,146 @@
2
  title: Email Sorting Openenv
3
  emoji: πŸ“§
4
  colorFrom: blue
5
- colorTo: purple
6
  sdk: docker
7
  pinned: false
 
 
8
  ---
9
 
10
- # Email Sorting OpenEnv
11
 
12
- An AI environment where an agent classifies emails as spam, important, or promotion.
 
 
13
 
14
- Built for the Meta x PyTorch OpenEnv Hackathon.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  title: Email Sorting Openenv
3
  emoji: πŸ“§
4
  colorFrom: blue
5
+ colorTo: red
6
  sdk: docker
7
  pinned: false
8
+ tags:
9
+ - openenv
10
  ---
11
 
12
+ # Email Sorting OpenEnv πŸ“§
13
 
14
+ A real-world OpenEnv environment where an AI agent learns to classify
15
+ emails as **spam**, **important**, or **promotion**.
16
+ Built for the Meta x PyTorch OpenEnv Hackathon.
17
 
18
+ ---
19
+
20
+ ## What This Project Does
21
+
22
+ In today's world, people receive hundreds of emails daily.
23
+ This environment trains an AI agent to automatically sort emails
24
+ by reading the subject, body, and sender β€” just like a smart inbox.
25
+
26
+ The agent learns:
27
+ - Correct classification = **reward**
28
+ - Wrong classification = **penalty**
29
+ - Harder emails = **higher reward** (to encourage learning)
30
+
31
+ ---
32
+
33
+ ## Environment Details
34
+
35
+ | Property | Value |
36
+ |----------|-------|
37
+ | Task Type | Email Classification |
38
+ | Action Space | spam / important / promotion |
39
+ | Max Steps | 10 per episode |
40
+ | Reward Range | -0.5 to +1.0 |
41
+ | Difficulty Levels | Easy / Medium / Hard |
42
+
43
+ ---
44
+
45
+ ## Action Space
46
+
47
+ The agent can take exactly one of these actions per step:
48
+
49
+ | Action | Meaning |
50
+ |--------|---------|
51
+ | `spam` | Email is unwanted, scam, or phishing |
52
+ | `important` | Email needs attention (work, orders, real alerts) |
53
+ | `promotion` | Genuine sale or discount from real shops |
54
+
55
+ ---
56
+
57
+ ## Observation Space
58
+
59
+ Each step the agent receives:
60
+ ```json
61
+ {
62
+ "email": {
63
+ "subject": "You won $1,000,000!",
64
+ "body": "Click here to claim your prize.",
65
+ "sender": "prize@randomsite.xyz"
66
+ },
67
+ "step": 1,
68
+ "max_steps": 10,
69
+ "total_reward": 0.0,
70
+ "done": false,
71
+ "valid_actions": ["spam", "important", "promotion"]
72
+ }
73
+ ```
74
+
75
+ ---
76
+
77
+ ## Tasks
78
+
79
+ | Task | Difficulty | Description | Expected Score |
80
+ |------|------------|-------------|----------------|
81
+ | `easy_sorting` | Easy | Classify obvious spam vs important emails | 0.6 – 0.8 |
82
+ | `medium_sorting` | Medium | Distinguish spam, promotion, and important | 0.5 – 0.7 |
83
+ | `hard_sorting` | Hard | Detect subtle phishing and tricky promotions | 0.4 – 0.6 |
84
+
85
+ ---
86
+
87
+ ## Reward Function
88
+
89
+ | Event | Reward |
90
+ |-------|--------|
91
+ | Easy correct | +0.5 |
92
+ | Medium correct | +0.75 |
93
+ | Hard correct | +1.0 |
94
+ | Easy wrong | -0.5 |
95
+ | Medium wrong | -0.3 |
96
+ | Hard wrong | -0.1 |
97
+ | Invalid action | -0.2 |
98
+
99
+ ---
100
+
101
+ ## Baseline Scores
102
+
103
+ Scores achieved by the rule-based baseline agent (`baseline_agent` in `graders.py`):
104
+
105
+ | Task | Score |
106
+ |------|-------|
107
+ | easy_sorting | 0.8 |
108
+ | medium_sorting | 0.67 |
109
+ | hard_sorting | 0.5 |
110
+ | **Average** | **0.657** |
111
+
112
+ ---
113
+
114
+ ## Setup & Usage
115
+
116
+ ### Local
117
+
118
+ ```bash
119
+ pip install -r requirements.txt
120
+ python server.py # starts server at http://localhost:7860
121
+ python graders.py # run graders with baseline agent
122
+ python inference.py # run inference loop
123
+ ```
124
+
125
+ ### Docker
126
+
127
+ ```bash
128
+ docker build -t email-sorting-openenv .
129
+ docker run -p 7860:7860 email-sorting-openenv
130
+ ```
131
+
132
+ ### API
133
+
134
+ ```bash
135
+ curl -X POST http://localhost:7860/reset
136
+ curl -X POST http://localhost:7860/step -H "Content-Type: application/json" -d '{"action":"spam"}'
137
+ curl http://localhost:7860/state
138
+ curl http://localhost:7860/graders
139
+ ```
140
+
141
+ ### Environment Variables
142
+
143
+ | Variable | Description | Default |
144
+ |----------|-------------|---------|
145
+ | `API_BASE_URL` | LLM API base URL | `https://api.openai.com/v1` |
146
+ | `MODEL_NAME` | Model to use | `gpt-4o-mini` |
147
+ | `HF_TOKEN` | HuggingFace / API token | β€” |