Considering production boost only, in the long run, it roughs out to very close to 1:1, usually with only one more Magneto than Steamworks for optimal. In the short term, when first building them, around 4-5 Magnetos before you bother with Steamworks is appropriate.
There is a spreadsheet which will do the calculation for you, publicly shared. Adding a single building at a time, shows a single Steamworks getting more results after 4 Magnetos are built, then 2 more SW once the next M is built. Going further shows SW slowly catching up in worth as it's bonus has more Magnetos to impact, but always lagging behind because a Magneto is always worth just a little more for every SW built.
The only diminishing return that I'm aware of is the expense of the buildings. Once you get in the 20-30 of each range, they require hundreds of blueprints, and your economy in general will be focusing on harder to acquire resources that only get a partial effect (titanium, uranium, unobtanium), and power become more of a concern than production (blueprints will be fed to reactors). They are typically still worth building so you can max out older buildings, and blueprints become both easier to craft and less in demand as you max out the tech tree.