{"id":90,"date":"2025-11-06T15:45:17","date_gmt":"2025-11-06T20:45:17","guid":{"rendered":"https:\/\/wp.stgeorges.bc.ca\/connork\/?p=90"},"modified":"2025-11-30T19:24:40","modified_gmt":"2025-12-01T00:24:40","slug":"neural-gear-network-in-onshape","status":"publish","type":"post","link":"https:\/\/wp.stgeorges.bc.ca\/connork\/2025\/11\/06\/neural-gear-network-in-onshape\/","title":{"rendered":"Neural Gear Network in Onshape"},"content":{"rendered":"\n<p>For this assignment, I took the learning-focused path instead of creating a full model from scratch. I wanted to understand the core workflow of CAD (how sketches, extrusions, assemblies, and drawings all connect) before I tried to make something ambitious. I followed the Onshape learning pathway and built a series of small, symbolic parts that relate to the structure of a transformer model. It became a way to understand both design principles and the way complex systems are built from simple, well-defined pieces.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Sketching and Constraints<\/h4>\n\n\n\n<p>The first part I made was a simple 30\u00d730 mm square. It represented a single <em>token<\/em>, the smallest building block in a transformer. I drew the square from the origin, added equal and horizontal\/vertical constraints, and made sure the lines turned black, meaning fully defined. This was my introduction to precision: the sketch only behaves predictably when every relationship is constrained.<\/p>\n\n\n\n<p>After finishing the sketch, I extruded the square by 4 mm and added a 1 mm fillet on the edges. That small step turned a flat, two-dimensional idea into something tangible. It felt like an \u201cembedding,\u201d a basic analogy for how data gets transformed from a sequence of numbers into something with depth and geometry.<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"884\" data-id=\"100\" src=\"https:\/\/wp.stgeorges.bc.ca\/connork\/wp-content\/uploads\/sites\/21\/2025\/10\/Screenshot-2025-10-13-at-2.46.19-PM-1-1024x884.png\" alt=\"\" class=\"wp-image-100\" srcset=\"https:\/\/wp.stgeorges.bc.ca\/connork\/wp-content\/uploads\/sites\/21\/2025\/10\/Screenshot-2025-10-13-at-2.46.19-PM-1-1024x884.png 1024w, https:\/\/wp.stgeorges.bc.ca\/connork\/wp-content\/uploads\/sites\/21\/2025\/10\/Screenshot-2025-10-13-at-2.46.19-PM-1-300x259.png 300w, https:\/\/wp.stgeorges.bc.ca\/connork\/wp-content\/uploads\/sites\/21\/2025\/10\/Screenshot-2025-10-13-at-2.46.19-PM-1-768x663.png 768w, https:\/\/wp.stgeorges.bc.ca\/connork\/wp-content\/uploads\/sites\/21\/2025\/10\/Screenshot-2025-10-13-at-2.46.19-PM-1.png 1154w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Token tile before extrusion<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"654\" data-id=\"97\" src=\"https:\/\/wp.stgeorges.bc.ca\/connork\/wp-content\/uploads\/sites\/21\/2025\/10\/Screenshot-2025-10-13-at-2.48.11-PM-2-1024x654.png\" alt=\"\" class=\"wp-image-97\" srcset=\"https:\/\/wp.stgeorges.bc.ca\/connork\/wp-content\/uploads\/sites\/21\/2025\/10\/Screenshot-2025-10-13-at-2.48.11-PM-2-1024x654.png 1024w, https:\/\/wp.stgeorges.bc.ca\/connork\/wp-content\/uploads\/sites\/21\/2025\/10\/Screenshot-2025-10-13-at-2.48.11-PM-2-300x192.png 300w, https:\/\/wp.stgeorges.bc.ca\/connork\/wp-content\/uploads\/sites\/21\/2025\/10\/Screenshot-2025-10-13-at-2.48.11-PM-2-768x490.png 768w, https:\/\/wp.stgeorges.bc.ca\/connork\/wp-content\/uploads\/sites\/21\/2025\/10\/Screenshot-2025-10-13-at-2.48.11-PM-2-1536x981.png 1536w, https:\/\/wp.stgeorges.bc.ca\/connork\/wp-content\/uploads\/sites\/21\/2025\/10\/Screenshot-2025-10-13-at-2.48.11-PM-2.png 1892w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Token tile after extrusion and filleting<\/figcaption><\/figure>\n<\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Modeling the Attention Dial<\/h4>\n\n\n\n<p>Next, I learned to revolve and extrude circular shapes. I created a simple dial:<\/p>\n\n\n\n<p>A 24 mm diameter cylinder, 8 mm thick, with a 4 mm hole through its center. This part symbolized an <em>attention head<\/em>. The hole became the pivot point for rotation, which I\u2019d later use in the assembly to experiment with motion.<\/p>\n\n\n\n<p>The process introduced me to more complex geometry, including concentric constraints and the use of reference dimensions to keep everything parametric. This part also made me appreciate how small design decisions (like leaving the center hole) make the assembly process smoother later on.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"552\" height=\"686\" src=\"https:\/\/wp.stgeorges.bc.ca\/connork\/wp-content\/uploads\/sites\/21\/2025\/10\/Screenshot-2025-10-13-at-3.05.44-PM-edited.png\" alt=\"\" class=\"wp-image-102\" style=\"width:650px;height:auto\" srcset=\"https:\/\/wp.stgeorges.bc.ca\/connork\/wp-content\/uploads\/sites\/21\/2025\/10\/Screenshot-2025-10-13-at-3.05.44-PM-edited.png 552w, https:\/\/wp.stgeorges.bc.ca\/connork\/wp-content\/uploads\/sites\/21\/2025\/10\/Screenshot-2025-10-13-at-3.05.44-PM-edited-241x300.png 241w\" sizes=\"auto, (max-width: 552px) 100vw, 552px\" \/><figcaption class=\"wp-element-caption\"><em>Attention dial with central bore.<\/em><\/figcaption><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Assembly and Mate<\/h4>\n\n\n\n<p>Once I had a few small parts, I opened a new Assembly workspace. I added a flat base plate, fastened it to the world, and attached the dial using a revolute mate. That simple mate allowed the dial to spin freely while staying aligned with its axis.<\/p>\n\n\n\n<p>Seeing the dial rotate felt like the moment the whole process clicked. The revolute mate represents controlled movement; one degree of freedom. It perfectly mirrors the idea of an attention mechanism adjusting its focus. The difference between a <em>fastened<\/em> mate (no movement) and a <em>revolute<\/em> mate (single rotation) also helped me understand how constraints define motion in CAD.<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"600\" style=\"aspect-ratio: 600 \/ 600;\" width=\"600\" controls src=\"https:\/\/wp.stgeorges.bc.ca\/connork\/wp-content\/uploads\/sites\/21\/2025\/10\/Adobe-Express-Adobe-Express-Screen-Recording-2025-10-13-at-2.58.17-PM.mp4\"><\/video><figcaption class=\"wp-element-caption\"><em>Dial rotating in Onshape assembly<\/em><\/figcaption><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Drawings and the Bill of Materials<\/h4>\n\n\n\n<p>Following the feedback to include my mechanical drawings, I realized I could go one step further. Since a Transformer model is just math, and CAD is just geometry defined by math, I built a &#8220;Digital Twin&#8221; of my assembly to test the mechanical logic before &#8220;manufacturing.&#8221;<\/p>\n\n\n\n<p><strong>First off, the Hardware Dependencies (BOM)<\/strong>.I cleaned up the dimensions to ensure standard sizing for the input tokens and defined the specific gear ratio in the Bill of Materials (BOM).<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"797\" src=\"https:\/\/wp.stgeorges.bc.ca\/connork\/wp-content\/uploads\/sites\/21\/2025\/11\/Screenshot-2025-11-30-at-3.26.02-PM-1024x797.png\" alt=\"\" class=\"wp-image-144\" srcset=\"https:\/\/wp.stgeorges.bc.ca\/connork\/wp-content\/uploads\/sites\/21\/2025\/11\/Screenshot-2025-11-30-at-3.26.02-PM-1024x797.png 1024w, https:\/\/wp.stgeorges.bc.ca\/connork\/wp-content\/uploads\/sites\/21\/2025\/11\/Screenshot-2025-11-30-at-3.26.02-PM-300x233.png 300w, https:\/\/wp.stgeorges.bc.ca\/connork\/wp-content\/uploads\/sites\/21\/2025\/11\/Screenshot-2025-11-30-at-3.26.02-PM-768x598.png 768w, https:\/\/wp.stgeorges.bc.ca\/connork\/wp-content\/uploads\/sites\/21\/2025\/11\/Screenshot-2025-11-30-at-3.26.02-PM-1536x1195.png 1536w, https:\/\/wp.stgeorges.bc.ca\/connork\/wp-content\/uploads\/sites\/21\/2025\/11\/Screenshot-2025-11-30-at-3.26.02-PM.png 1822w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>This is where I wanted to push the project further. In software engineering, it&#8217;s know that you never ship code without running tests to verify the logic. I realized that since CAD is parametric (defined by math and relationships), I could &#8220;unit test&#8221; my mechanical assembly using code.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Demo<\/h4>\n\n\n\n<p>I built a digital replica of the assembly using React. I instantiated the specific rows from my Bill of Materials into the JavaScript runtime to verify the system&#8217;s behavior.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The grey container represents the Base Plate (<code>BASE-SYS-01<\/code>). Just like in the CAD assembly, this is the fixed substrate that holds the system static.<\/li>\n\n\n\n<li>The blue dial corresponds to the Token Embedding (<code>TOKEN_EMB-01<\/code>). In Onshape, this part has a rotational degree of freedom. In the demo, it is mapped to the user input state.<\/li>\n\n\n\n<li>The red gears are the Attention Mechanism (<code>ATTN-GEAR-01<\/code>). I programmed them with the exact physical constraints from the drawing: an 18-tooth design and a 1:1 gear ratio relative to the input.<\/li>\n<\/ul>\n\n\n\n<p>This is where I wanted to push the project further. I wanted to explain how a piece of plastic could actually select words and formulate sentences. So, I built this demo:<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"1646\" style=\"aspect-ratio: 2268 \/ 1646;\" width=\"2268\" controls src=\"https:\/\/wp.stgeorges.bc.ca\/connork\/wp-content\/uploads\/sites\/21\/2025\/11\/demos-online-video-cutter.com-1-1.mp4\"><\/video><\/figure>\n\n\n\n<h5 class=\"wp-block-heading\">How the Demo Works<\/h5>\n\n\n\n<p>In the dashboard above, I gave the model a &#8220;sentence&#8221; of 5 words. I divided the 360 degree circle of the gear into 5 equal &#8220;zones&#8221; (like slices of a pizza).<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><strong>Zone 1 (0-72 degrees):<\/strong> &#8220;THE&#8221;<\/li>\n\n\n\n<li><strong>Zone 2 (72-144 degrees):<\/strong> &#8220;ROBOT&#8221;<\/li>\n\n\n\n<li><strong>Zone 3 (144-216 degrees):<\/strong> &#8220;LEARNS&#8221;&#8230; and so on.<\/li>\n<\/ol>\n\n\n\n<p>As you rotate the Blue Input Token, it physically drives the Red Attention Gear. The gear acts as a pointer. Whatever &#8220;zone&#8221; the gear lands in, that data gets activated.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">The &#8220;Radio Dial&#8221; Analogy<\/h5>\n\n\n\n<p>Think of the Attention Gear (Item 3) like the tuner on an old radio.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The radio has access to every station at once, but it only plays one at a time.<\/li>\n\n\n\n<li>To pick a station, you turn the dial.<\/li>\n\n\n\n<li>When the dial points to 98.5, you hear jazz. When it points to 101.1, you hear rock.<\/li>\n<\/ul>\n\n\n\n<h5 class=\"wp-block-heading\">The Conclusion<\/h5>\n\n\n\n<p>This proves that the movement isn&#8217;t random. By rotating the gear to a specific angle, we are physically addressing a specific piece of memory. Just like a combination lock needs to be in the right position to open, the gear needs to be in the right position to &#8220;think&#8221; the right word.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Lessons Learned<\/h4>\n\n\n\n<p>Working through the tutorials taught me that sketches are the foundation of everything. Getting them fully defined is the difference between a stable model and one that behaves unpredictably. Extrusions are just geometry built on those rules. Assemblies are where motion and interaction come in, and drawings are how you prove your design works for someone else.<\/p>\n\n\n\n<p>Each part (tile, dial, and base) taught me something about constraints, motion, or communication. Together they formed a small but complete system. And by using transformer concepts as metaphors, I could think about each step not just mechanically but conceptually:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Tokens become tiles.<\/li>\n\n\n\n<li>Embeddings become extrusions.<\/li>\n\n\n\n<li>Attention becomes rotation.<\/li>\n\n\n\n<li>Feed-forward layers become fixed stages.<\/li>\n\n\n\n<li>Residual paths become links between parts.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Next Steps<\/h4>\n\n\n\n<p>If I revisit this later, I\u2019d add a slider to represent shifting focus or connect two dials with a thin linkage arm to show a residual path. For now, this small collection of parts is enough to show that I understand the tools and the workflow, and that I can connect the logic of CAD to the structure of machine learning.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">References<\/h4>\n\n\n\n<p>Here is a link to my demo: <a href=\"https:\/\/codesandbox.io\/p\/sandbox\/trusting-buck-k8vr59\">https:\/\/codesandbox.io\/p\/sandbox\/trusting-buck-k8vr59<\/a><\/p>\n\n\n\n<p>Here is my final CAD design (cannot share past St. George&#8217;s school): <a href=\"https:\/\/sgs.onshape.com\/documents\/4cef7508a5ce180e9427bc43\/w\/5aafeed653c6c9899b8833dd\/e\/c7e96911e28cc8f9f39a18f7\">https:\/\/sgs.onshape.com\/documents\/4cef7508a5ce180e9427bc43\/w\/5aafeed653c6c9899b8833dd\/e\/c7e96911e28cc8f9f39a18f7<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>For this assignment, I took the learning-focused path instead of creating a full model from scratch. I wanted to understand the core workflow of CAD (how sketches, extrusions, assemblies, and drawings all connect) before I tried to make something ambitious. I followed the Onshape learning pathway and built a series of small, symbolic parts that [&hellip;]<\/p>\n","protected":false},"author":19,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-90","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/wp.stgeorges.bc.ca\/connork\/wp-json\/wp\/v2\/posts\/90","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.stgeorges.bc.ca\/connork\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.stgeorges.bc.ca\/connork\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.stgeorges.bc.ca\/connork\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.stgeorges.bc.ca\/connork\/wp-json\/wp\/v2\/comments?post=90"}],"version-history":[{"count":5,"href":"https:\/\/wp.stgeorges.bc.ca\/connork\/wp-json\/wp\/v2\/posts\/90\/revisions"}],"predecessor-version":[{"id":147,"href":"https:\/\/wp.stgeorges.bc.ca\/connork\/wp-json\/wp\/v2\/posts\/90\/revisions\/147"}],"wp:attachment":[{"href":"https:\/\/wp.stgeorges.bc.ca\/connork\/wp-json\/wp\/v2\/media?parent=90"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.stgeorges.bc.ca\/connork\/wp-json\/wp\/v2\/categories?post=90"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.stgeorges.bc.ca\/connork\/wp-json\/wp\/v2\/tags?post=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}