Saving LDA object

41 views
Skip to first unread message

Jasneet Sabharwal

unread,
Dec 16, 2015, 5:39:35 PM12/16/15
to Factorie
Hi, I was trying to create the topic model in Java using the LDA class. I ran LDA.inferTopics to train the model. Now, what is the best way to persist the LDA object so that I can use it later to infer the thetas for any new document without training the model again?

namrata ghadi

unread,
Jul 10, 2017, 2:54:14 PM7/10/17
to Factorie
Any reply to this question will be appreciated. I am trying to train a Linear Chain CRF and would like to find a way to persist the weights of the model somehow. 

eli...@hotmail.com

unread,
Jul 10, 2017, 3:14:47 PM7/10/17
to Factorie
Disclosure: I have not tried LDA or Linear Chain CRF on factorie.

I save weights by serializing and deserializing.
After training step:
    BinarySerializer.serialize(model, file.path)

For prediction, I make sure that the model and variables are initialised the same way and then run the following to insert the weights:
    BinarySerializer.deserialize(model, file.path)

I usually print out the weights to make sure they are the same. This might not be the best way but it works for me.

Eric

Emma Strubell

unread,
Jul 10, 2017, 3:45:36 PM7/10/17
to Factorie
You also need to make sure you serialize any domains. See serialization/deserialization in e.g. https://github.com/factorie/factorie/blob/master/src/main/scala/cc/factorie/app/nlp/pos/ChainPosTagger.scala

To check that the serialized weights are the same as the deserialized, I usually print out the norm of the weights (a bit  more readable than all of the weights). 

--
--
Factorie Discuss group.
To post, email: dis...@factorie.cs.umass.edu
To unsubscribe, email: discuss+u...@factorie.cs.umass.edu

namrata ghadi

unread,
Jul 10, 2017, 6:12:09 PM7/10/17
to dis...@factorie.cs.umass.edu
Thank you, all.
Thank you Emma for pointing me to the example.


--
--
Factorie Discuss group.
To post, email: dis...@factorie.cs.umass.edu
To unsubscribe, email: discuss+unsubscribe@factorie.cs.umass.edu

---
You received this message because you are subscribed to the Google Groups "Factorie" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss+unsubscribe@factorie.cs.umass.edu.



--
It is only impossible until it’s done.
-Nelson Mandela
Reply all
Reply to author
Forward
0 new messages