HackerTrans
TopNewTrendsCommentsPastAskShowJobs

mkmccjr

no profile record

Submissions

Hypernetworks: Neural Networks for Hierarchical Data

blog.sturdystatistics.com
97 points·by mkmccjr·5 เดือนที่ผ่านมา·10 comments

comments

mkmccjr
·4 เดือนที่ผ่านมา·discuss
These are both great points. When I wrote the post, it didn't occur to me that I could inspect the emitted bytecode. In hindsight, including that would have made the explanation much stronger.

To be honest, this is my first time really digging into performance on a JIT runtime. I learned to code as an astronomy researcher and the training I received from my mentors was "write Python when possible, and C or Fortran when it needs to be fast." Therefore I spent a lot of time writing C, and I didn't appreciate how aggressively something like HotSpot can optimize.

(I don't mean that as a dig against Python; it's simply the mental model I absorbed.)

The realization that I can have really good performance in a high-level language like Clojure is revolutionary for me.

I'm learning a ton from the comments here. Thanks to everyone sharing their knowledge -- it's genuinely appreciated.
mkmccjr
·4 เดือนที่ผ่านมา·discuss
Aha, I think I better understand your point: since the generated bytecode includes a cast, my explanation about the optimization is too simplistic.

I haven't actually inspected the emitted bytecode, so I was only reasoning from the observed speedup.

Your point about branch prediction is really interesting; it would explain how the cast becomes almost free once the type is stable in the hot path.

I'm learning a lot from this thread -- thank you for pushing on the details!
mkmccjr
·4 เดือนที่ผ่านมา·discuss
Thank you for this! On the second point, you are absolutely correct; that was sloppy writing on my part. I will correct that in the post.

I'm not certain I understand your first point. When I add the type hint, it's me asserting the type, not the compiler proving anything. If the value at runtime isn't actually a byte array, I would expect a ClassCastException.

But I am new to Clojure, and I may well be mistaken about what the compiler is doing.
mkmccjr
·4 เดือนที่ผ่านมา·discuss
Author of the blog post here. That explanation sounds very plausible to me!

If the whole enclosing function became inlinable after the reflective call path disappeared, that could explain why the end-to-end speedup under load was even larger than the isolated microbench.

I admit that I don't understand the JIT optimization deeply enough to say that confidently... as I mentioned in the blog post, I was quite flummoxed by the results. I’d genuinely love to learn more.
mkmccjr
·5 เดือนที่ผ่านมา·discuss
I appreciate the optimism! This specific example is just a pedagogical toy designed to be simple enough to analyze fully.

That said, I do agree with the intuition that static networks have a ceiling. If we want systems that can truly adapt to new contexts (like different hospitals or different physical laws) without retraining, we likely need dynamic architectures.
mkmccjr
·5 เดือนที่ผ่านมา·discuss
You are absolutely right about the code: I haven't worked with neural networks in a while and I guess my post outs me!

That said, I do like Keras's functional API, and in this case I think it maps nicely to the "math" of the hypernetwork.

I really appreciate your suggestion of more popular libraries, and I'll look into JAX.
mkmccjr
·5 เดือนที่ผ่านมา·discuss
Thank you for your comment, and I sincerely apologize for my slow response! "Rediscovering structure" is exactly the inefficiency I was trying to highlight.

In the physics/science cases I work with, the factorization is usually between the physical law (shared structure) and the experimental conditions (dataset-specific structure). If you don't separate them, the model wastes capacity trying to memorize the noise of the experimental conditions. (It's ineffective as well as wasteful.)

The analogy to code generation makes a lot of sense: flattening a tree into a sequence forces the model to infer syntax that was already explicit. Thank you for the link; I look forward to diving into it!
mkmccjr
·5 เดือนที่ผ่านมา·discuss
Thank you for reading my post, and for your thoughtful critique. And I sincerely apologize for my slow response! You are right that there are other ways to inject latent structure, and FiLM is a great example.

I admit the "static embedding" baseline is a bit of a strawman, but I used it to illustrate the specific failure mode of models that can't adapt at inference time.

I then used the Hypernetwork specifically to demonstrate a "dataset-adaptive" architecture as a stepping stone toward the next post in the series. My goal was to show how even a flexible parameter-generating model eventually hits a wall with out-of-sample stability; this sets the stage for the Bayesian Hierarchical approach I cover later on.

I wasn't familiar with the FiLM literature before your comment, but looking at it now, the connection is spot on. Functionally, it seems similar to what I did here: conditioning the network on an external variable. In my case, I wanted to explicitly model the mapping E->θ to see if the network could learn the underlying physics (Planck's law) purely from data.

As for stability, you are right that Hypernetworks can be tricky in high dimensions, but for this low-dimensional scalar problem (4D embedding), I found it converged reliably.
mkmccjr
·5 เดือนที่ผ่านมา·discuss
Hello. I am the author of the post. The goal of this was to provide a pedagogical example of applying Bayesian hierarchical modeling principles to real world datasets. These datasets often contain inherent structure that is important to explicitly model (eg clinical trials across multiple hospitals). Oftentimes a single model cannot capture this over-dispersion but there is not enough data to split out the results (nor should you).

The idea behind hypernetworks is that they enable Gelman-style partial pooling to explicitly modeling the data generation process while leveraging the flexibility of neural network tooling. I’m curious to read more about your recommendations: their connection to the described problems is not immediately obvious to me but I would be curious to dig a bit deeper.

I agree that hypernetworks have some challenges associated with them due to the fragility of maximum likelihood estimates. In the follow-up post, I dug into how explicit Bayesian sampling addresses these issues.
mkmccjr
·8 เดือนที่ผ่านมา·discuss
Original author here -- thank you for your thoughtful comment.

You're absolutely right that saying "SQL is useful" isn't exactly novel. My goal with the blog post was to describe the practical impact of leaning into SQL (and DuckDB) at our company.

I'm not the SQL expert on our team (that's my colleague Kian) but I've seen the difference he's made with his expertise. A lot of the work we migrated into SQL was originally implemented as the kind of multi-step pipelines you described: we used multiple libraries, wrote intermediate files, and had to translate data between different formats.

Kian recently rewrote a large stage of our pipeline so it runs entirely inside a single SQL script. It's a complicated script to be sure, but that's because the logic it implements is complex. And with CTEs, temp tables, and DuckDB's higher-order functions, it ended up being dramatically clearer than the original sprawl of code. More importantly, it's self-contained, and easy to inspect. Consolidating the logic into one place made a big difference for us.

And thank you for catching my error about the CPU type. We recently moved from an M2 Ultra servers to M4 machines, and I mistakenly conflated the two when I wrote "M4 Ultra." I've corrected the post.
mkmccjr
·9 เดือนที่ผ่านมา·discuss
Just tried this out, and my mind is blown: https://platform.sturdystatistics.com/deepdive?fast=0&q=camp...

I did a google search for "camping with dogs" and it organized the results into a set of about ~30 results which span everything I'd want to know on the topic: from safety and policies to products and travel logistics.

Does this work on any type of data?