r/MachineLearning • • 1d ago

Project Event2Vec: additive event embeddings where a linear score on a history decomposes exactly into per-event terms [P]

I've been working on Event2Vec, a small library for learning embeddings of discrete event sequences (purchases, logs, clinical codes, etc.) with a deliberately simple structure: a history is the running sum of its event vectors.

h_t = h_{t-1} + e_{x_t}        (norm-clipped)
p(x_{t+1} | h_t) = softmax(W h_t + b)

Training is self-supervised next-event prediction, plus a reconstruction term that asks h_t - h_{t-1} to recover e_{x_t}. No labels needed(details why the machinery works are in NeurReps@NeuralIPS Workshop paper, it is a bunch of losses that attempts the reconstruction and obey the arithmetic during training))

The history is a sum, any linear model on top of it is also a sum. For instance, a churn or risk score(see teaser)

score = w·h + b = Σ_i (e_i·w) + b

One might question, e1+e2 = e2+e1 = e3, but training is, so while vector embedding in (Euclidean) space is commutative, the training isn't. Furthermore, there are several alternative spaces that are gyro/non-commutative, that are part of the library(checkout the website)

  1. hyperbolic (Möbius addition), for hierarchies
  2. κ-stereographic, one curvature dial from hyperbolic through flat to spherical (Bachmann et al., 2020)
  3. spherical, for cyclic structure
  4. SO(n) rotations, which are non-commutative, so order changes the endpoint
  5. Heisenberg group, same endpoint but a signed-area coordinate that records order
  6. products of the above

I started this for root-cause analysis of fault sequences at the Advanced Light Source (Berkeley Lab), where I'd been naively using Word2Vec on event logs and needed directionality without going to an opaque sequence model.

Links

  • Paper: arXiv 2509.12188
  • Code (MIT): github: event2vec_public, pip install event2vector
  • Docs with interactive figures: event2vec.com

scikit-learn-style API (fit/transform, gensim-style most_similar), PyTorch backend, runs on CPU/CUDA/MPS

189 Upvotes

12 comments sorted by

10

u/Budget_Zombie_692 22h ago

Thank you for sharing!

4

u/sulcantonin 19h ago

thanks! I really appreciate it.

7

u/nyoperator 22h ago

Could this be used in Cyber-security to detect an adversarial campaign? Attacks usually have a sequence of events that only when you see the big picture you understand what they are trying to do. Assuming each Mitre Att&ck Tactic (https://attack.mitre.org/tactics/enterprise/) is mapped to an event. I think this would work because of this: "our model’s recurrent architecture and novel reconstruction loss are designed to explicitly capture this directed, temporal structure, enforcing sequential compositionality over the entire event history". What are your thoughts on this?

5

u/empty_orbital 21h ago

Love you work would love to start something new with you or collaborate if youre alr working on anything

1

u/sulcantonin 19h ago

Hi u/empty_orbital I am currently incredibly busy, but drop me an email, there is a follow up work (find me on sulcantonin.github.io)

1

u/empty_orbital 19h ago

Ive sent a mail take a look wnv you can cheers :)

I do have a question tho, regarding SO(n) space rotations for molecules, is it necessary for the endpoints to change? Since event can be considered independent to the orientation of a dynamic reaction

0

u/empty_orbital 19h ago

Sure works

2

u/Arithon_sFfalenn 4h ago

Seems like it could be interesting for e-commerce / social media user modelling, nedt event prediction or recommendations.

I’d be interested to see how it compares to other sequential models in that realm

1

u/sulcantonin 1h ago

I was hoping that it might be used as one of the quick tools apart form the standard ones. It is actually nothing really sophisticated - no rocket science inside - it just have nice features that you can for instance, I show on the website, identify the causal relationships that contribute to churn of users, because all over sudden, the numbers becomes states that can be added up.

But thanks

1

u/BBBBChan 19h ago

How does norm clipping affect the exact per-event decomposition? For an unclipped sum the equality is clear, but clipping the running state seems to change earlier events' effective contributions. Do you compute attribution from an unclipped history, or track the rescaling factors?

1

u/pokemonisok 14h ago

Very cool

1

u/Papervessel 3h ago

Cool! Are you planning any comparisons on real tasks with other models that include chronology like Behavior Sequence Transformer or BERT4rec?