schauh11 commited on
Commit
bdb2dd7
·
verified ·
1 Parent(s): bb8bc81

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +171 -3
README.md CHANGED
@@ -1,3 +1,171 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ tags:
6
+ - revit
7
+ - bim
8
+ - architecture
9
+ - code-generation
10
+ - fine-tuned
11
+ - gguf
12
+ - construction
13
+ - aec
14
+ - autodesk
15
+ base_model: Qwen/Qwen3-14B
16
+ library_name: gguf
17
+ pipeline_tag: text-generation
18
+ ---
19
+
20
+ # revit-coder-14b
21
+
22
+ A domain-adapted 14B parameter language model fine-tuned for Autodesk Revit 2025+ API development. Generates production-grade C# code with correct transaction management, thread safety patterns, and crash-resistant architecture.
23
+
24
+ Built on Qwen3-14B using QLoRA. Available in F16 (full precision) and Q4_K_M (quantized) GGUF formats.
25
+
26
+ ## What This Model Does
27
+
28
+ This model is specialized for Revit API code generation and validation. It understands:
29
+
30
+ - Transaction hierarchy (Transaction, TransactionGroup, SubTransaction) and when to use each
31
+ - Thread safety with IExternalEventHandler and ExternalEvent patterns
32
+ - IFailuresPreprocessor for agentic/automated execution without modal dialog popups
33
+ - FilteredElementCollector efficiency patterns and filter chaining
34
+ - Batch APIs (NewFamilyInstances2, Delete(ICollection)) for high-performance operations
35
+ - Element lifecycle management and stale reference prevention
36
+ - Revit 2025+ specifics: .NET 8, C# 12, ElementId.Value (long), net8.0-windows targeting
37
+ - Worksharing safety checks and checkout patterns
38
+ - Electrical systems, PanelScheduleView handling, and unit conversion
39
+
40
+ ## Quick Start (Ollama)
41
+
42
+ Download the Q4_K_M GGUF (recommended for most hardware):
43
+
44
+ ```bash
45
+ # Create a Modelfile
46
+ cat > Modelfile << 'EOF'
47
+ FROM ./revit-coder-14b-Q4_K_M.gguf
48
+
49
+ TEMPLATE """{{- if .System }}<|im_start|>system
50
+ {{ .System }}<|im_end|>
51
+ {{ end }}<|im_start|>user
52
+ {{ .Prompt }}<|im_end|>
53
+ <|im_start|>assistant
54
+ <think>
55
+
56
+ </think>
57
+
58
+ """
59
+
60
+ SYSTEM "You are a Revit API specialist for Autodesk Revit 2025+ (.NET 8, C# 12). You generate production-grade C# code that is crash-resistant, transaction-safe, and optimized for agentic execution."
61
+
62
+ PARAMETER temperature 0.7
63
+ PARAMETER num_ctx 16384
64
+ PARAMETER stop "<|im_end|>"
65
+ PARAMETER repeat_penalty 1.1
66
+ EOF
67
+
68
+ # Create and run
69
+ ollama create revit-coder-14b -f Modelfile
70
+ ollama run revit-coder-14b "Write code to create 100 structural columns at specified coordinates"
71
+ ```
72
+
73
+ ## Available Files
74
+
75
+ | File | Size | Precision | VRAM Required | Use Case |
76
+ |------|------|-----------|---------------|----------|
77
+ | `revit-coder-14b-Q4_K_M.gguf` | 9 GB | 4-bit quantized | ~12 GB | Recommended for local use |
78
+ | `revit-coder-14b-f16.gguf` | 26 GB | Full FP16 | ~28 GB | Maximum quality, requires 32GB+ RAM |
79
+
80
+ ## Example Outputs
81
+
82
+ ### Transaction Safety
83
+
84
+ **Prompt:** "What's wrong with this code?"
85
+ ```csharp
86
+ for (int i = 0; i < walls.Count; i++)
87
+ {
88
+ var t = new Transaction(doc);
89
+ t.Start("Delete");
90
+ doc.Delete(walls[i].Id);
91
+ t.Commit();
92
+ }
93
+ ```
94
+
95
+ **Model response identifies:**
96
+ - Anti-pattern: Transaction per loop iteration causes N regenerations instead of 1
97
+ - Missing `using` block (resource leak if exception thrown)
98
+ - Should use batch API: `doc.Delete(wallIds)` in a single Transaction
99
+ - Missing IFailuresPreprocessor (modal dialogs will block execution)
100
+
101
+ ### Batch API Knowledge
102
+
103
+ **Prompt:** "Create 100 structural columns at XYZ coordinates in Revit 2025"
104
+
105
+ The model generates code using `doc.Create.NewFamilyInstances2()` (the batch API) rather than looping with individual `NewFamilyInstance()` calls, resulting in 5-15x faster execution with a single regeneration.
106
+
107
+ ### Thread Safety
108
+
109
+ **Prompt:** "How do I call the Revit API from a background thread?"
110
+
111
+ The model correctly explains that Revit API is single-threaded and provides the IExternalEventHandler + ConcurrentQueue pattern, warning against Task.Run() or ThreadPool approaches that cause crashes.
112
+
113
+ ## Training Details
114
+
115
+ - **Base model:** Qwen3-14B
116
+ - **Method:** QLoRA (rank 64, alpha 128)
117
+ - **Training data:** Curated Revit API documentation, code patterns, and domain knowledge
118
+ - **Domains:** Revit C# API, IFC reasoning, APS/Forge schemas
119
+ - **Epochs:** 3
120
+ - **Validation loss:** 0.1586
121
+ - **Hardware:** RunPod GPU cluster
122
+
123
+ ## Recommended System Prompt
124
+
125
+ For best results, use a system prompt that encodes Revit transaction rules. A comprehensive system prompt is available in the [companion repository](https://github.com/schauh11/revit-trained-llm) under `docs/`.
126
+
127
+ Key rules to include:
128
+ - Transaction decision tree (dependent ops -> TransactionGroup, batch available -> batch API, otherwise -> single Transaction)
129
+ - Batch size limits (max 50 elements per Transaction, max 10 Transactions per TransactionGroup)
130
+ - Thread safety (IExternalEventHandler only, never background threads)
131
+ - Element lifecycle (store ElementId, never Element; re-fetch after commit)
132
+ - Always include IFailuresPreprocessor for agentic execution
133
+
134
+ ## Hardware Requirements
135
+
136
+ | Format | Minimum RAM | Recommended | Inference Speed (M1 Max 64GB) |
137
+ |--------|-------------|-------------|-------------------------------|
138
+ | Q4_K_M | 16 GB | 32 GB | ~11 tok/s |
139
+ | F16 | 32 GB | 64 GB | ~7 tok/s |
140
+
141
+ ## Use Cases
142
+
143
+ - **Revit plugin development:** Generate boilerplate with correct transaction patterns
144
+ - **Code review:** Validate existing Revit API code against best practices
145
+ - **Agentic AI:** Serve as the code generation/validation layer in a Revit automation pipeline
146
+ - **Learning:** Understand Revit API patterns through conversational Q&A
147
+
148
+ ## Limitations
149
+
150
+ - Specialized for Revit 2025+ (.NET 8). May generate outdated patterns for Revit 2023/2024 (.NET Framework 4.8)
151
+ - Code generation, not execution. Generated code should be reviewed before running in production
152
+ - 14B parameter model. For complex multi-file architectural decisions, pair with a frontier model
153
+
154
+ ## License
155
+
156
+ Apache 2.0. Based on [Qwen3-14B](https://huggingface.co/Qwen/Qwen3-14B) (Apache 2.0).
157
+
158
+ ## Author
159
+
160
+ Sanjay Chauhan -- [GitHub](https://github.com/schauh11) | [LinkedIn](https://linkedin.com/in/schauh11)
161
+
162
+ ## Citation
163
+
164
+ ```bibtex
165
+ @misc{chauhan2026revitcoder,
166
+ title={revit-coder-14b: A Domain-Adapted LLM for Revit API Development},
167
+ author={Chauhan, Sanjay},
168
+ year={2026},
169
+ url={https://huggingface.co/schauh11/revit-coder-14b}
170
+ }
171
+ ```