ETM
ETM copied to clipboard
Example Code for Use
I'm having some trouble figuring out the appropriate input and output for the model after it is created. Is there any example you can provide for the use and what I can expect to have returned? As I understand it, it should return the predicted topics, with the embedding of the document being passed, correct?
Agreed, it's opaque how to use this for new documents after training, which went great. Any chance of some more insight into how to apply it?
Same question !
That would be Very helpful, I hope you can provide us with such functions
Same question
any update ? I have the same question
Same question!
I am on the same issue - there are various places where you can get a return value which is the size of your topics, which is what you want, from looking at the eval script I have this:
NUM_TOPICS = 128
def predict(normd_bow):
thetaAvg = torch.zeros(1, NUM_TOPICS)
sums = normd_bow.sum(1).unsqueeze(1)
thetaWeightedAvg = torch.zeros(1, NUM_TOPICS)
theta, _ = model.get_theta(normd_bow)
thetaAvg += theta.sum(0).unsqueeze(0) / normd_bow.shape[0]
weighed_theta = sums * theta
thetaWeightedAvg += weighed_theta.sum(0).unsqueeze(0)
return thetaWeightedAvg
Created from this code.
EDIT: I have no idea if this is correct!