Instructions to use dream-machine-ai/Dream-Machine-08-09 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use dream-machine-ai/Dream-Machine-08-09 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="dream-machine-ai/Dream-Machine-08-09", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("dream-machine-ai/Dream-Machine-08-09", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Dream-Machine ยท Billion-Item Neural Recommendation Sorcerer
Multi-Hash Transformer Dual-Tower ยท RAG-Enhanced Recall ยท Production-Grade
"Even a 4-year-old can understand why the Magic Shop knows exactly what toy you want next."
๐ Paper ยท ๐ Quick Start ยท ๐ Benchmarks ยท ๐๏ธ Architecture ยท โ๏ธ Scaling Laws
โจ What Makes Dream-Machine-08-09 Different
โฆ 10ยนโฐ-item scale โ Multi-Hash Embedding eliminates ID explosion, zero OOM
โฆ โค100 ms latency โ RAG multi-channel recall + FAISS ANN, production-ready
โฆ One codebase โ runs identically from RTX 3060 laptop to 250รA100 cluster
โฆ 7 novel contributions โ not a wrapper, a full research-grade system
โฆ Closed-form scaling โ predict the right config before you train a single step
๐ Benchmarks
Evaluated on 1,000 simulated e-commerce items (JD/Taobao schema). Numbers reflect real checkpoint
hf_model/model.safetensors.
| Metric | Value | Context |
|---|---|---|
| AUC | 0.4849 | 1K simulated items, cold-start |
| HR@10 | 1.0 | Perfect recall within top-10 |
| NDCG@10 | 0.537 | Ranking quality at top-10 |
| Latency (single GPU) | < 5 ms | Item + user tower forward pass |
| Serving latency (FastAPI) | โค 100 ms | End-to-end including FAISS ANN |
| Max item catalogue | 10ยนโฐ | Via Multi-Hash, B=100M buckets |
๐ Scaling Laws โ See Before You Train
The four charts below are taken directly from the Dream-Machine-08-09 technical report. They encode closed-form scaling laws that let you pick the right model config before writing a single training line.
Parameter Scaling Overview
Reading guide: Each curve is a scale tier (10ยฒ โ 10ยนโฐ items). The x-axis is total trainable parameters; y-axis is validation NDCG@10. Dashed vertical lines mark the paper's 9 recommended operating points.
Batch Size vs. Performance
Reading guide: Training with too-small batches leads to noisy InfoNCE gradients; too-large batches waste GPU memory. The sweet spot for each scale tier is marked with a โ .
Hash Bucket Size Scaling
Reading guide: Collision rate ฮต_eff = (1 โ e^{โN/2B})^K. As bucket count B grows, collision drops sharply โ but returns diminish past B โ 3รN. The chart shows the optimal B/N ratio for K = 3 hash tables.
Dual-Parameter Scaling Surface
Reading guide: A 2-D surface over (d_model, L) pairs. The colour encodes NDCG@10. Deeper blue = better. The white ridge is the Pareto frontier: maximum quality per parameter budget.
๐๏ธ Architecture
Input JSON
โ
โโโโโโโโโโโผโโโโโโโโโโโ
โ DreamMachineFeature โ
โ Extractor โ
โโโโฌโโโโโโโโโโโโโโโฌโโโ
โ โ
โโโโโโโโโโโโโโผโโโโ โโโโโโโผโโโโโโโโโโโโโ
โ Item Tower โ โ User Tower โ
โ โ โ โ
โ item_hash_ids โ โ user_hash_ids โ
โ category_l* โ โ demographics โ
โ brand_hash_ids โ โ city_hash_ids โ
โ numeric [29] โ โ numeric [57] โ
โ โ โ โ
โ L=2 Transformerโ โ L=2 Transformer โ
โ H=8 heads โ โ H=8 heads โ
โ d_model=128 โ โ d_model=128 โ
โ L2-normalised โ โ L2-normalised โ
โโโโโโโโโโฌโโโโโโโโ โโโโโโโโโโฌโโโโโโโโโโโ
โ v โ S^{d-1} โ u โ S^{d-1}
โโโโโโโโโโโโฌโโโโโโโโโโโ
โ
s(u,i) = uยทv / ฯ (ฯ = 0.07)
Seven Original Contributions
| # | Contribution | Key Formula / Mechanism |
|---|---|---|
| 1 | Multi-Hash Transformer Dual-Tower (MHTDT) | ฮต_eff = (1 โ e^{โN/2B})^K |
| 2 | Hierarchical Feature Architecture | Typed token sequence: ID โ sparse categorical โ dense numeric |
| 3 | RAG-Enhanced Multi-Channel Recall | FAISS IVF-PQ + CF + popularity + rules |
| 4 | Cross-Attention Listwise Re-ranker | Simultaneous CTR / CVR / dwell-time prediction |
| 5 | Uncertainty-Weighted InfoNCE Multi-Task | Learnable log-variance weights ฯ_kยฒ per task |
| 6 | Closed-Form Parameter Scaling Laws | 9 breakpoints from 10ยฒ to 10ยนโฐ items |
| 7 | Production Serving Stack | FastAPI + ONNX + INT8 + A/B testing, โค100 ms |
๐ Quick Start
Installation
pip install transformers torch numpy
Load the Model
from transformers import AutoConfig, AutoModel
config = AutoConfig.from_pretrained(
"dream-machine-ai/Dream-Machine-08-09",
trust_remote_code=True,
)
model = AutoModel.from_pretrained(
"dream-machine-ai/Dream-Machine-08-09",
trust_remote_code=True,
).eval()
End-to-End Inference
import torch
from transformers import AutoModel, AutoFeatureExtractor
model = AutoModel.from_pretrained(
"dream-machine-ai/Dream-Machine-08-09", trust_remote_code=True
).eval()
fe = AutoFeatureExtractor.from_pretrained(
"dream-machine-ai/Dream-Machine-08-09", trust_remote_code=True
)
# โโ Product dict (JD / Taobao schema) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
product = {
"sku_id": "AJ-RETRO1-OG-BRED-2026",
"category": {
"level1_name": "่ฟๅจ",
"level2_name": "้้ด",
"level3_name": "็ฏฎ็้",
},
"brand": {"brand_name": "Nike"},
"price": {"current_price": 1499, "original_price": 1999, "discount": 7.5},
"sales": {"total_sales": 320000, "monthly_sales": 18000},
"rating": {"overall": 4.95, "quality": 4.97},
"rec_features": {"ctr_7d": 0.21, "cvr_7d": 0.09},
}
# โโ User dict โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
user = {
"user_id": "U001",
"demographics": {
"gender": "male",
"age_group": "25-30",
"income_level": "10000-20000",
},
"location": {"city": "ๅไบฌ", "city_tier": "ไธ็บฟ"},
"interests": {"interest_categories": ["ๆฐ็ ็งๆ", "่ฟๅจๅฅ่บซ"]},
}
# โโ Extract features & score โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
item_feat = {k: v.unsqueeze(0) for k, v in fe.extract_item(product).items()}
user_feat = {k: v.unsqueeze(0) for k, v in fe.extract_user(user).items()}
with torch.no_grad():
outputs = model(user_feat, item_feat)
print(f"Matching score s(u,i) = {outputs.similarity.item():.4f}")
print(f"User embedding shape = {outputs.user_vector.shape}") # [1, 128]
print(f"Item embedding shape = {outputs.item_vector.shape}") # [1, 128]
Production: Separate Tower Inference
# โโ Offline: build FAISS index with item embeddings โโโโโโโโโโโโโโโโโโโ
item_embedding = model.get_item_embedding(item_feat) # [1, 128]
# โโ Online: user query in real time โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
user_embedding = model.get_user_embedding(user_feat) # [1, 128]
# Inner product == cosine similarity (both L2-normalised)
score = (user_embedding * item_embedding).sum(dim=-1)
Tokenizer (Multi-Hash ID Mapping)
from transformers import AutoTokenizer
tok = AutoTokenizer.from_pretrained(
"dream-machine-ai/Dream-Machine-08-09", trust_remote_code=True
)
# Single ID โ K hash bucket indices
result = tok(item_id="SKU12345678")
# โ {"input_ids": tensor([[12345, 67890, 34567]])}
# Batch
result = tok(item_ids=["SKU001", "SKU002", "SKU003"])
# โ {"input_ids": tensor([[...], [...], [...]])}
โ๏ธ Scaling Laws
Use DreamMachineConfig.from_scale_tier(n_items) to get the paper-optimal config for any catalogue size โ no tuning required.
from configuration_dreammachine import DreamMachineConfig
cfg_1m = DreamMachineConfig.from_scale_tier(1_000_000)
# โ d=256, L=6, K=3, B=3_000_000
cfg_1b = DreamMachineConfig.from_scale_tier(1_000_000_000)
# โ d=768, L=8, K=5, B=50_000_000
| Scale (N items) | d_model | L | K | B (buckets) | Params |
|---|---|---|---|---|---|
| 10ยฒ | 64 | 2 | 3 | 5 K | ~38.6 M |
| 10ยณ (this model) | 128 | 2 | 3 | 50 K | ~77.6 M |
| 10โถ | 256 | 6 | 3 | 3 M | ~9.2 B |
| 10โน | 768 | 8 | 5 | 50 M | ~768 B |
| 10ยนโฐ | 768 | 12 | 7 | 100 M | ~10.2 T |
๐ง Training Details
| Hyperparameter | Value |
|---|---|
| Scale tier | N = 10ยณ items |
| d_model | 128 |
| Transformer layers L | 2 |
| Attention heads H | 8 |
| Hash tables K | 3 |
| Hash buckets B | 50,000 |
| Temperature ฯ | 0.07 |
| Batch size | 32 |
| Training steps | 2,000 |
| Learning rate | 1e-4 (OneCycleLR) |
| Negative ratio ฯ | 4 |
| FP16 AMP | โ |
| Loss | Uncertainty-Weighted BCE + InfoNCE + Engagement MSE |
๐ Repository Layout
paper_hf_model/
โโโ README.md โ This file (Model Card)
โโโ config.json โ DreamMachineConfig (auto_map)
โโโ tokenizer_config.json โ DreamMachineTokenizer config
โโโ preprocessor_config.json โ DreamMachineFeatureExtractor config
โโโ configuration_dreammachine.py โ Config class (trust_remote_code)
โโโ modeling_dreammachine.py โ Model class (trust_remote_code)
โโโ tokenization_dreammachine.py โ Tokenizer class (trust_remote_code)
โโโ feature_extraction_dreammachine.py โ Feature extractor (trust_remote_code)
โโโ hf_model/
โโโ config.json โ Exported config
โโโ model.safetensors โ Weights (safetensors)
โโโ legacy_config.json โ Original checkpoint config
โโโ README.md โ Auto-generated card
๐ Citation
@techreport{wen2026dreammachine,
title = {Magic Shop at Scale: Dream-Machine --- A Billion-Item
Real-Time Neural Recommendation Sorcerer},
author = {Wen, Fangjun},
year = {2026},
institution = {DreamMachine Research Team},
doi = {10.5281/zenodo.21906715},
url = {https://doi.org/10.5281/zenodo.21906715},
note = {Technical Report, August 2026. arXiv cs.IR / cs.LG}
}
โ๏ธ License
This project is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License (CC BY-NC 4.0).
| โ Permitted | โ Prohibited |
|---|---|
| Academic research & publication | Commercial products or services |
| Personal learning & experimentation | Revenue-generating deployments |
| Non-commercial derivative works | Sublicensing for profit |
| Citing in papers with attribution | Any business use without written permission |
Commercial use of any kind โ including integrating model weights, code, or outputs into a product or service โ requires explicit prior written consent from the author (Fangjun Wen).
See LICENSE for the full license text.
Paper: Magic Shop at Scale: Dream-Machine-08-09 ยท Authors: Fangjun Wen ยท DreamMachine Research Team ยท August 2026
// built with focus ยท DreamMachine Research
- Downloads last month
- -
Evaluation results
- AUC (1K simulated items)self-reported0.485
- HR@10self-reported1.000
- NDCG@10self-reported0.537



