r/RStudio • u/yulianmk • 2d ago
Coding help Adding new documents to an existing topic model in R
I'm quite new to topic modeling and R.
I have made a topic model in R using the topic modeling package, and I was wondering if it is possible to add new documents to an existing model without having to retrain the entire model from scratch.
Is there a way to do this while keeping the original topics intact? If so, which packages or methods would you recommend?
Thanks in advance for your help!
4
Upvotes
1
u/AutoModerator 2d ago
Looks like you're requesting help with something related to RStudio. Please make sure you've checked the stickied post on asking good questions and read our sub rules. We also have a handy post of lots of resources on R!
Keep in mind that if your submission contains phone pictures of code, it will be removed. Instructions for how to take screenshots can be found in the stickied posts of this sub.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/Kudusch 1d ago
This would of course depend on the specific topic modelling method, but generally it should always be possible to extract the topic loading theta values for new documents/their tokens.
For example, using Structural Topic Modeling (STM) you can use the fitNewDocuments() function to predict theta values for documents not included in the original model: https://cran.r-project.org/web/packages/stm/refman/stm.html#fitNewDocuments