File size: 3,988 Bytes
fce36e0
 
 
 
 
 
 
 
 
 
d04ed9a
fce36e0
 
 
 
d04ed9a
 
fce36e0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213beb6
 
 
 
 
 
 
fce36e0
 
 
 
 
 
 
 
213beb6
fce36e0
 
 
 
213beb6
 
 
 
 
fce36e0
 
 
28dd597
 
 
 
 
 
 
fce36e0
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
---
license: apache-2.0
tags:
  - behavioral-ai
  - user-embeddings
  - sequence-modeling
  - e-commerce
  - churn-prediction
  - personalization
pipeline_tag: feature-extraction
demo: https://huggingface.co/spaces/bdhanani/beat-demo
---

# BEAT: Behavioral Encoder for Action Trajectories

๐ŸŽฎ **[Try the Live Demo โ†’](https://huggingface.co/spaces/bdhanani/beat-demo)**

A foundation transformer model that encodes sequences of human behavioral events into dense, reusable embeddings.

## What is BEAT?

Every company predicting churn, recommending products, or segmenting users starts by manually engineering features from behavioral data (RFM scores, click counts, session metrics). This feature engineering is where most prediction quality is lost.

**BEAT eliminates that step.** Feed it raw event sequences โ€” page views, purchases, searches, support tickets โ€” and get a rich 768-dimensional embedding that captures the user's behavioral state.

## Key Innovation

Unlike text transformers (BERT, GPT) that encode language, BEAT is designed specifically for **action sequences with temporal dynamics**:

- **Temporal encoding**: Learns from time gaps between events (a purchase 1 day after browsing means something different than 30 days after)
- **Action vocabulary**: Encodes event types, not words
- **Behavioral context**: Understands that the same action means different things in different sequences

## Usage

```python
from transformers import AutoModel
import torch

# Load model
model = AutoModel.from_pretrained("your-org/beat-encoder")

# Encode a behavioral sequence
action_ids = torch.tensor([[1, 2, 3, 5, 1, 6, 2, 5]])  # page_view, product_view, cart, purchase...
property_ids = torch.tensor([[12, 45, 45, 45, 8, 3, 22, 22]])  # category/property context
time_gaps = torch.tensor([[0.0, 0.1, 0.5, 1.2, 3.0, 3.1, 7.0, 7.5]])  # days between events

outputs = model(action_ids, property_ids, time_gaps)
embedding = outputs["embedding"]  # [1, 768] โ€” user behavioral state
```

## Pre-training Objectives

1. **Masked Event Prediction**: Randomly mask 15% of events, predict the action type (like MLM in BERT)
2. **Next Event Prediction**: Given a sequence, predict what action comes next
3. **Contrastive Learning**: Different time windows of the same user should produce similar embeddings

## Downstream Tasks

BEAT embeddings can be used for:

| Task | Method | Expected Improvement |
|------|--------|---------------------|
| Churn prediction | Linear probe on embedding | +8-15% AUC vs. manual features |
| User segmentation | Cluster embeddings | More stable, interpretable clusters |
| Next-best-action | Fine-tune prediction head | Captures temporal patterns manual features miss |
| Personalization | Nearest-neighbor in embedding space | Real behavioral similarity, not just demographics |

## Training Data

Pre-trained on the REES46 e-commerce behavioral dataset (20M+ events from a multi-category online store):
- **50,000 users**, 18,401 behavioral sequences
- **10,350 training steps** across 10 epochs
- Training loss converged from 0.83 โ†’ 0.42
- Hardware: 2ร— NVIDIA T4 GPU (~27 minutes)

The model generalizes to other behavioral domains through fine-tuning.

## Architecture

| Parameter | Value |
|-----------|-------|
| Hidden size | 768 |
| Layers | 12 |
| Attention heads | 12 |
| Parameters | 86.4M |
| Embedding output | 768-dim |
| Max sequence length | 256 events |
| Temporal encoding | Learned + sinusoidal (90-day window) |

## Paper

๐Ÿ“„ **[BEAT: A Foundation Model for Human Behavioral Sequences](https://doi.org/10.5281/zenodo.20774886)**
Published on Zenodo โ€” DOI: `10.5281/zenodo.20774886`

## Citation

```bibtex
@article{dhanani2026beat,
  title     = {BEAT: A Foundation Model for Human Behavioral Sequences},
  author    = {Dhanani, Brijesh},
  year      = {2026},
  doi       = {10.5281/zenodo.20774886},
  url       = {https://doi.org/10.5281/zenodo.20774886},
  publisher = {Zenodo}
}
```

## License

Apache 2.0