Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize performance of Author-Topic model #2978

Merged
merged 5 commits into from
May 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Changes
- [#3115](https://github.com/RaRe-Technologies/gensim/pull/3115): Make LSI dispatcher CLI param for number of jobs optional, by [@robguinness](https://github.com/robguinness))
- Update link to Hoffman paper (online VB LDA) (PR [#3133](https://github.com/RaRe-Technologies/gensim/pull/3133), [@jonaschn](https://github.com/jonaschn))
- fix bug when loading saved Phrases model (PR [#3116](https://github.com/RaRe-Technologies/gensim/pull/3116), [@aloknayak29](https://github.com/aloknayak29))
- Optimize performance of Author-Topic model (PR [#2978](https://github.com/RaRe-Technologies/gensim/pull/2978), [@horpto](https://github.com/horpto))

### :+1: Improvements

### Documentation

Expand Down
7 changes: 5 additions & 2 deletions gensim/models/atmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,12 @@ def inference(self, chunk, author2doc, doc2author, rhot, collect_sstats=False, c

# Update gamma.
# phi is computed implicitly below,
dot = np.dot(cts / phinorm, expElogbetad.T)
for ai, a in enumerate(authors_d):
tilde_gamma[ai, :] = self.alpha + len(self.author2doc[self.id2author[a]])\
* expElogthetad[ai, :] * np.dot(cts / phinorm, expElogbetad.T)
tilde_gamma[ai, :] = (
self.alpha
+ len(self.author2doc[self.id2author[a]]) * expElogthetad[ai, :] * dot
)

# Update gamma.
# Interpolation between document d's "local" gamma (tilde_gamma),
Expand Down