Nishan30 commited on
Commit
0ce67b7
Β·
verified Β·
1 Parent(s): 6a55028

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +212 -97
README.md CHANGED
@@ -8,37 +8,77 @@ tags:
8
  - code-generation
9
  - qwen2.5
10
  - lora
 
 
11
  base_model: Qwen/Qwen2.5-Coder-1.5B-Instruct
12
  pipeline_tag: text-generation
13
- library_name: peft
 
 
 
 
 
 
 
 
 
14
  ---
15
 
16
- # n8n Workflow Generator πŸš€
17
 
18
- A fine-tuned **Qwen2.5-Coder-1.5B** model for generating n8n workflows using TypeScript DSL.
19
 
20
- ## 🎯 Performance
21
 
22
- - **Overall Test Score:** 92.4%
23
- - **Training Examples:** 247 curated workflows
24
- - **Validation Examples:** 44
25
 
26
- ## πŸ“Š Test Results by Category
27
-
28
- | Category | Score | Grade |
29
  |----------|-------|-------|
30
- | Basic Workflows | 100% | A |
31
- | Complexity | 96% | A |
32
- | Error Handling | 80% | B |
33
- | Data Aggregation | 96% | A |
34
- | Scheduled Tasks | 96% | A |
35
- | Form Processing | 92% | A |
36
- | Loops | 67% | C |
37
- | Branching | 67% | C |
38
- | **Overall** | **92.4%** | **A** |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
  ## πŸš€ Quick Start
41
 
 
 
42
  ```python
43
  from transformers import AutoModelForCausalLM, AutoTokenizer
44
  from peft import PeftModel
@@ -51,7 +91,7 @@ base_model = AutoModelForCausalLM.from_pretrained(
51
  device_map="auto"
52
  )
53
 
54
- # Load LoRA adapter
55
  model = PeftModel.from_pretrained(base_model, "Nishan30/n8n-workflow-generator")
56
  tokenizer = AutoTokenizer.from_pretrained("Nishan30/n8n-workflow-generator")
57
 
@@ -65,11 +105,11 @@ Your output should:
65
  - Use .to() or workflow.connect() for connections
66
  - Be ready to compile directly to n8n JSON"""
67
 
68
- # Generate workflow
69
- user_prompt = "Create a webhook that sends data to Slack"
70
  messages = [
71
- {"role": "system", "content": system_prompt},
72
- {"role": "user", "content": user_prompt}
73
  ]
74
 
75
  text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
@@ -80,114 +120,189 @@ outputs = model.generate(
80
  max_new_tokens=512,
81
  temperature=0.3,
82
  do_sample=True,
83
- top_p=0.9
 
84
  )
85
 
86
  result = tokenizer.decode(outputs[0], skip_special_tokens=True)
87
  print(result)
88
  ```
89
 
90
- ## 🌐 Try it Online
91
 
92
- **Web Interface:** [Hugging Face Space](https://huggingface.co/spaces/Nishan30/n8n-workflow-generator-app) (coming soon!)
 
93
 
94
- ## πŸ’‘ Example Prompts
 
 
 
 
95
 
96
- Try these prompts:
 
 
 
97
 
98
- - "Create a webhook that sends data to Slack"
99
- - "Schedule that runs daily and backs up database to Google Drive"
100
- - "Webhook receives form data, validates email, saves to Airtable"
101
- - "Monitor RSS feed and post new items to Twitter"
102
- - "Fetch GitHub issues, if priority is high send to Slack, else email"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
 
104
- ## πŸ“ Model Details
 
 
 
 
105
 
106
- - **Base Model:** Qwen/Qwen2.5-Coder-1.5B-Instruct (1.5B parameters)
107
- - **Fine-tuning Method:** LoRA (Low-Rank Adaptation)
108
- - Rank: 16
109
- - Alpha: 32
110
- - Target modules: q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
111
- - **Dataset:** 291 curated n8n workflows (247 train + 44 validation)
112
- - **Training Framework:** Transformers + PEFT
113
- - **Hardware:** NVIDIA Tesla T4 GPU (Kaggle)
114
 
115
- ## πŸŽ“ Training Details
 
 
 
 
116
 
117
- - **Optimizer:** AdamW with cosine learning rate schedule
118
- - **Learning Rate:** 2e-4 with warmup
119
- - **Batch Size:** 1 (effective batch size 8 with gradient accumulation)
120
- - **Training Strategy:** Early stopping with validation loss monitoring
121
- - **Best Checkpoint:** Automatically selected based on validation performance
122
- - **Total Training Time:** ~2-3 hours
123
 
124
- ## πŸ› οΈ Use Cases
125
 
126
- Perfect for:
127
 
128
- - **Automation developers** building n8n workflows
129
- - **No-code platforms** adding AI workflow generation
130
- - **Productivity tools** automating repetitive tasks
131
- - **Learning n8n** by seeing examples
 
132
 
133
- ## πŸ“– Usage Tips
134
 
135
- **For best results:**
 
 
 
 
 
 
 
136
 
137
- - Be specific in your descriptions
138
- - Use n8n terminology (webhook, HTTP Request, Slack, etc.)
139
- - Describe the complete flow from trigger to action
140
- - Lower temperature (0.1-0.3) for consistent code
141
- - Higher temperature (0.5-0.8) for creative variations
 
 
142
 
143
- ## πŸ”§ Limitations
 
 
 
144
 
145
- - Works best with common n8n patterns
146
- - May struggle with very complex branching (>5 conditions)
147
- - Advanced error handling might need manual refinement
148
- - Custom node configurations may require adjustment
149
- - Limited to TypeScript DSL format (not visual editor)
150
 
151
- ## πŸ“„ License
 
152
 
153
- Apache 2.0 - Free for commercial and personal use
 
154
 
155
- ## πŸ™ Acknowledgments
 
 
156
 
157
- Built with:
158
- - [Qwen2.5-Coder](https://huggingface.co/Qwen/Qwen2.5-Coder-1.5B-Instruct) by Alibaba Cloud
159
- - [Hugging Face Transformers](https://github.com/huggingface/transformers)
160
- - [PEFT](https://github.com/huggingface/peft) for efficient fine-tuning
161
- - [n8n](https://n8n.io) workflow automation platform
162
- - Curated dataset from [GitHub n8n workflows](https://github.com/search?q=n8n+workflows)
163
 
164
- ## πŸ“Š Comparison to General LLMs
 
 
165
 
166
- | Model | Size | n8n Workflow Score | Speed | Cost |
167
- |-------|------|-------------------|-------|------|
168
- | **This Model** | 1.5B | **92.4%** | 3-5s | Free |
169
- | GPT-4 | 175B+ | ~85-93% | 10-20s | $0.01/request |
170
- | GPT-3.5 Turbo | 175B | ~70-85% | 5-10s | $0.002/request |
171
- | Gemini Pro | Unknown | ~80-90% | 8-15s | $0.0005/request |
172
 
173
- **Why this model excels:** Domain-specific training on n8n workflows!
174
 
175
- ## πŸ”— Links
 
 
 
176
 
177
- - **Model Repository:** https://huggingface.co/Nishan30/n8n-workflow-generator
178
- - **Web Demo:** https://huggingface.co/spaces/Nishan30/n8n-workflow-generator-app
179
- - **Base Model:** https://huggingface.co/Qwen/Qwen2.5-Coder-1.5B-Instruct
180
- - **n8n Documentation:** https://docs.n8n.io
 
 
 
 
 
 
 
181
 
182
- ## πŸ“ž Contact
183
 
184
- For questions, issues, or feedback:
185
- - Open an issue on the model repository
186
- - Join the [Hugging Face Discord](https://discord.gg/huggingface)
187
- - Connect with the n8n community
188
 
189
  ---
190
 
191
- **Built with ❀️ for the n8n community**
192
 
193
  *Last updated: December 2024*
 
8
  - code-generation
9
  - qwen2.5
10
  - lora
11
+ - workflow-automation
12
+ - typescript
13
  base_model: Qwen/Qwen2.5-Coder-1.5B-Instruct
14
  pipeline_tag: text-generation
15
+ model-index:
16
+ - name: n8n-workflow-generator
17
+ results:
18
+ - task:
19
+ type: text-generation
20
+ name: Workflow Generation
21
+ metrics:
22
+ - type: accuracy
23
+ value: 91.8
24
+ name: Overall Test Score
25
  ---
26
 
27
+ # πŸš€ n8n Workflow Generator v1.0
28
 
29
+ A fine-tuned **Qwen2.5-Coder-1.5B** model that generates n8n workflows using TypeScript DSL.
30
 
31
+ ## πŸ“Š Performance (Comprehensive Testing)
32
 
33
+ **Overall Score: 91.8%** ✨ (24 diverse test cases)
 
 
34
 
35
+ ### Detailed Results by Category:
36
+ | Category | Score | Tests |
 
37
  |----------|-------|-------|
38
+ | Simple Webhook | 92.2% | 3 |
39
+ | Conditional Routing | 93.3% | 3 |
40
+ | Scheduled Tasks | 95.6% | 3 |
41
+ | Form Processing | 93.3% | 2 |
42
+ | Multi-Service Integration | 83.3% | 3 |
43
+ | Data Processing | 93.3% | 3 |
44
+ | Error Handling | 88.9% | 3 |
45
+ | Complex Multi-Step | 91.7% | 2 |
46
+ | Manual & Email Triggers | 96.7% | 2 |
47
+
48
+ ### Test Score Breakdown:
49
+ - **Basic Checks:** 98% (syntax, structure, node types)
50
+ - **Structural Checks:** 83% (connections, flow logic)
51
+ - **N8N-Specific:** 97% (valid nodes, DSL conventions)
52
+
53
+ ### Grade Distribution:
54
+ - 🟒 **A (Excellent):** 83% of test cases
55
+ - 🟑 **B (Good):** 13% of test cases
56
+ - πŸ”΄ **D (Poor):** 4% of test cases
57
+
58
+ ## 🎯 What It Does
59
+
60
+ Converts natural language descriptions into production-ready n8n workflows:
61
+
62
+ **Input:** "Create a webhook that sends data to Slack"
63
+
64
+ **Output:**
65
+ ```typescript
66
+ const workflow = new Workflow('Webhook to Slack');
67
+ const webhook = workflow.add('n8n-nodes-base.webhook', {{
68
+ path: '/data',
69
+ method: 'POST'
70
+ }});
71
+ const slack = workflow.add('n8n-nodes-base.slack', {{
72
+ channel: '#general',
73
+ text: '={{{{ $json.message }}}}'
74
+ }});
75
+ webhook.to(slack);
76
+ ```
77
 
78
  ## πŸš€ Quick Start
79
 
80
+ ### Option 1: Using LoRA Adapter (Recommended)
81
+
82
  ```python
83
  from transformers import AutoModelForCausalLM, AutoTokenizer
84
  from peft import PeftModel
 
91
  device_map="auto"
92
  )
93
 
94
+ # Load fine-tuned adapter
95
  model = PeftModel.from_pretrained(base_model, "Nishan30/n8n-workflow-generator")
96
  tokenizer = AutoTokenizer.from_pretrained("Nishan30/n8n-workflow-generator")
97
 
 
105
  - Use .to() or workflow.connect() for connections
106
  - Be ready to compile directly to n8n JSON"""
107
 
108
+ # Generate
109
+ user_request = "Create a webhook that sends data to Slack"
110
  messages = [
111
+ {{"role": "system", "content": system_prompt}},
112
+ {{"role": "user", "content": user_request}}
113
  ]
114
 
115
  text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
 
120
  max_new_tokens=512,
121
  temperature=0.3,
122
  do_sample=True,
123
+ top_p=0.9,
124
+ repetition_penalty=1.1
125
  )
126
 
127
  result = tokenizer.decode(outputs[0], skip_special_tokens=True)
128
  print(result)
129
  ```
130
 
131
+ ### Option 2: Using Transformers Pipeline
132
 
133
+ ```python
134
+ from transformers import pipeline
135
 
136
+ generator = pipeline(
137
+ "text-generation",
138
+ model="Nishan30/n8n-workflow-generator",
139
+ device_map="auto"
140
+ )
141
 
142
+ prompt = "Create a scheduled workflow that fetches data daily and sends to Slack"
143
+ result = generator(prompt, max_new_tokens=512, temperature=0.3)
144
+ print(result[0]['generated_text'])
145
+ ```
146
 
147
+ ## 🌟 Supported Workflow Patterns
148
+
149
+ ### βœ… Triggers
150
+ - `webhook` - HTTP endpoints
151
+ - `scheduleTrigger` - Cron-based scheduling
152
+ - `manualTrigger` - Manual execution
153
+ - `formTrigger` - Form submissions
154
+ - `emailTrigger` - Email-based triggers
155
+
156
+ ### βœ… Actions & Integrations
157
+ - `slack`, `discord`, `telegram` - Messaging
158
+ - `gmail`, `email` - Email sending
159
+ - `httpRequest` - API calls
160
+ - `googleSheets`, `airtable`, `notion` - Databases
161
+ - And more...
162
+
163
+ ### βœ… Data Processing
164
+ - `if`, `switch` - Conditional logic
165
+ - `set`, `filter`, `merge` - Data transformation
166
+ - `code` - Custom JavaScript/Python
167
+ - `stopAndError` - Error handling
168
+
169
+ ## πŸ“ˆ Training Details
170
+
171
+ ### Dataset
172
+ - **Total Examples:** 2,736 workflows
173
+ - **Training Set:** 2,462 examples
174
+ - **Validation Set:** 274 examples
175
+ - **Pattern Coverage:** 7 major workflow patterns
176
+ - **Quality:** Curated from production n8n workflows
177
+
178
+ ### Training Configuration
179
+ - **Base Model:** Qwen/Qwen2.5-Coder-1.5B-Instruct
180
+ - **Method:** LoRA (Low-Rank Adaptation)
181
+ - **LoRA Rank:** 16
182
+ - **LoRA Alpha:** 16
183
+ - **Learning Rate:** 2e-4
184
+ - **Batch Size:** 2 (effective: 8 with gradient accumulation)
185
+ - **Epochs:** 10
186
+ - **Hardware:** NVIDIA Tesla T4 GPU (16GB)
187
+ - **Framework:** Transformers + Unsloth
188
+
189
+ ### Optimization
190
+ - βœ… 4-bit quantization for memory efficiency
191
+ - βœ… Gradient checkpointing
192
+ - βœ… Flash Attention 2
193
+ - βœ… Early stopping based on validation loss
194
+
195
+ ## 🎨 Example Workflows
196
+
197
+ ### 1. Simple Webhook to Slack
198
+ ```
199
+ User: "Create a webhook that posts to Slack"
200
+ Model: [Generates complete TypeScript DSL code]
201
+ ```
202
 
203
+ ### 2. Scheduled Data Sync
204
+ ```
205
+ User: "Daily workflow that fetches API data and stores in database"
206
+ Model: [Generates schedule trigger + HTTP request + database storage]
207
+ ```
208
 
209
+ ### 3. Form Processing
210
+ ```
211
+ User: "Contact form that validates and sends email"
212
+ Model: [Generates form trigger + validation + email sending]
213
+ ```
 
 
 
214
 
215
+ ### 4. Conditional Routing
216
+ ```
217
+ User: "Route high-priority items to #urgent, others to #general"
218
+ Model: [Generates webhook + if condition + dual Slack outputs]
219
+ ```
220
 
221
+ ## 🌐 Try It Online
 
 
 
 
 
222
 
223
+ **Hugging Face Space:** [Coming Soon]
224
 
225
+ ## πŸ“Š Benchmark Comparison
226
 
227
+ | Model | Size | Accuracy | Speed | Use Case |
228
+ |-------|------|----------|-------|----------|
229
+ | **n8n-workflow-generator** | 1.5B | 91.8% | Fast | Production-ready |
230
+ | GPT-3.5 (baseline) | 175B | ~85% | Slow | General purpose |
231
+ | CodeLlama-7B | 7B | ~88% | Medium | Code generation |
232
 
233
+ ## πŸ”§ Advanced Usage
234
 
235
+ ### Custom System Prompt
236
+ ```python
237
+ custom_prompt = """You are a workflow expert. Generate n8n workflows with:
238
+ - Error handling for all HTTP requests
239
+ - Descriptive node names
240
+ - Production-ready configurations
241
+ """
242
+ ```
243
 
244
+ ### Batch Generation
245
+ ```python
246
+ requests = [
247
+ "webhook to slack",
248
+ "daily email report",
249
+ "form to database"
250
+ ]
251
 
252
+ for req in requests:
253
+ workflow = generate_workflow(req)
254
+ print(workflow)
255
+ ```
256
 
257
+ ### Integration with n8n
258
+ ```python
259
+ import json
260
+ from n8n_generator import compile_to_json
 
261
 
262
+ # Generate DSL
263
+ dsl_code = model.generate(prompt)
264
 
265
+ # Compile to n8n JSON
266
+ workflow_json = compile_to_json(dsl_code)
267
 
268
+ # Import to n8n
269
+ # POST to http://your-n8n-instance/api/v1/workflows
270
+ ```
271
 
272
+ ## πŸ“ Limitations
 
 
 
 
 
273
 
274
+ - **Complex Logic:** May struggle with very complex multi-branch workflows (>10 nodes)
275
+ - **Custom Nodes:** Only supports built-in n8n nodes
276
+ - **Edge Cases:** Occasionally generates invalid node names (~8% of cases)
277
 
278
+ **Mitigation:** Add post-processing validation layer (see documentation)
 
 
 
 
 
279
 
280
+ ## 🚧 Roadmap
281
 
282
+ - [ ] v1.1: Expand to 7B model for better accuracy (target: 95%+)
283
+ - [ ] v1.2: Add support for custom n8n nodes
284
+ - [ ] v1.3: Multi-language support (Python, JavaScript execution nodes)
285
+ - [ ] v2.0: Fine-tune on user feedback data
286
 
287
+ ## πŸ“„ License
288
+
289
+ Apache 2.0
290
+
291
+ ## πŸ™ Acknowledgments
292
+
293
+ Built with:
294
+ - [Qwen2.5-Coder](https://huggingface.co/Qwen/Qwen2.5-Coder-1.5B-Instruct) by Alibaba Cloud
295
+ - [Hugging Face Transformers](https://github.com/huggingface/transformers)
296
+ - [PEFT](https://github.com/huggingface/peft) for LoRA
297
+ - [Unsloth](https://github.com/unslothai/unsloth) for training optimization
298
 
299
+ ## πŸ“§ Contact
300
 
301
+ - **Issues:** [GitHub Issues](https://github.com/Nishan30/n8n-workflow-generator/issues)
302
+ - **Discussions:** [Hugging Face Discussions](https://huggingface.co/Nishan30/n8n-workflow-generator/discussions)
 
 
303
 
304
  ---
305
 
306
+ **⭐ Star this model if you find it useful!**
307
 
308
  *Last updated: December 2024*