Thanks a lot. I will try the subsampling trick you mentioned. Also posting the Stan code if that gives any insights
P = 5 # Number of super topics
K = 25 # Number of topics
V = 100000 # Number of words
R = 1 # Number of roles
U = 90000 # Number of users
N = 264166617
data {
int<lower=1> U; // num users
int<lower=2> P; // num super topics
int<lower=2> K; // num topics
int<lower=2> V; // vocabulary size
int<lower=1> N; // total word instances
int<lower=1> R; // total number of roles
int<lower=1,upper=V> words[N]; // word n
int<lower=1,upper=U> userids[N]; // User ID for word n
int<lower=1,upper=R> roleids[N]; // Role ID for word n
vector<lower=0>[P] alpha; // super-topics prior
vector<lower=0>[V] beta; // word prior
vector<lower=0>[K] gamma; // topic prior
}
parameters {
simplex[P] theta[U]; // super-topic dist for user u
simplex[K] psi[P, R]; // topic dist for supertopic p
simplex[V] phi[K]; // word dist for topic k
}
model {
for (u in 1:U)
theta[u] ~ dirichlet(alpha); // prior
for (p in 1:P) {
for (r in 1:R) {
psi[p,r] ~ dirichlet(gamma); // prior
}
}
for (k in 1:K)
phi[k] ~ dirichlet(beta); // prior
for (n in 1:N) {
matrix[P,K] probs;
for (p in 1:P) {
for (z in 1:K) {
probs[p,z] <- log(theta[userids[n], p]) + log(psi[p, roleids[n], z]) + log(phi[z,words[n]]);
}
}
increment_log_prob(log_sum_exp(probs)); // likelihood
}
}