Skip to content

Commit 53109fa

Browse files
committed
Refactor links to Hoffman paper
and use latex symbols for original parameter names
1 parent c3bc1b8 commit 53109fa

File tree

3 files changed

+58
-50
lines changed

3 files changed

+58
-50
lines changed

gensim/models/atmodel.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
<https://arxiv.org/abs/1207.4169>`_. The model correlates the authorship information with the topics to give a better
2424
insight on the subject knowledge of an author.
2525
26+
.. _'Online Learning for LDA' by Hoffman et al.: online-lda_
27+
.. _online-lda: https://papers.neurips.cc/paper/2010/file/71f6278d140af599e06ad9bf1ba03cb0-Paper.pdf
28+
2629
Example
2730
-------
2831
.. sourcecode:: pycon
@@ -185,9 +188,12 @@ def __init__(self, corpus=None, num_topics=100, id2word=None, author2doc=None, d
185188
iterations : int, optional
186189
Maximum number of times the model loops over each document.
187190
decay : float, optional
188-
Controls how old documents are forgotten.
191+
A number between (0.5, 1] to weight what percentage of the previous lambda value is forgotten
192+
when each new document is examined. Corresponds to :math:`\\kappa` from
193+
`'Online Learning for LDA' by Hoffman et al.`_
189194
offset : float, optional
190-
Controls down-weighting of iterations.
195+
Hyper-parameter that controls how much we will slow down the first steps the first few iterations.
196+
Corresponds to :math:`\\tau_0` from `'Online Learning for LDA' by Hoffman et al.`_
191197
alpha : {float, numpy.ndarray of float, list of float, str}, optional
192198
A-priori belief on document-topic distribution, this can be:
193199
* scalar for a symmetric prior over document-topic distribution,
@@ -618,15 +624,14 @@ def update(self, corpus=None, author2doc=None, doc2author=None, chunksize=None,
618624
619625
Notes
620626
-----
621-
This update also supports updating an already trained model (self)
622-
with new documents from `corpus`: the two models are then merged in proportion to the number of old vs. new
623-
documents. This feature is still experimental for non-stationary input streams.
627+
This update also supports updating an already trained model (`self`) with new documents from `corpus`;
628+
the two models are then merged in proportion to the number of old vs. new documents.
629+
This feature is still experimental for non-stationary input streams.
624630
625-
For stationary input (no topic drift in new documents), on the other hand, this equals the online update of
626-
`Hoffman et al. Stochastic Variational Inference
627-
<http://www.jmlr.org/papers/volume14/hoffman13a/hoffman13a.pdf>`_ and is guaranteed to converge for any `decay`
628-
in (0.5, 1.0>. Additionally, for smaller `corpus` sizes, an increasing `offset` may be beneficial (see
629-
Table 1 in Hoffman et al.)
631+
For stationary input (no topic drift in new documents), on the other hand, this equals the
632+
online update of `'Online Learning for LDA' by Hoffman et al.`_
633+
and is guaranteed to converge for any `decay` in (0.5, 1]. Additionally, for smaller corpus sizes, an
634+
increasing `offset` may be beneficial (see Table 1 in the same paper).
630635
631636
If update is called with authors that already exist in the model, it will resume training on not only new
632637
documents for that author, but also the previously seen documents. This is necessary for those authors' topic
@@ -653,9 +658,12 @@ def update(self, corpus=None, author2doc=None, doc2author=None, chunksize=None,
653658
chunksize : int, optional
654659
Controls the size of the mini-batches.
655660
decay : float, optional
656-
Controls how old documents are forgotten.
661+
A number between (0.5, 1] to weight what percentage of the previous lambda value is forgotten
662+
when each new document is examined. Corresponds to :math:`\\kappa` from
663+
`'Online Learning for LDA' by Hoffman et al.`_
657664
offset : float, optional
658-
Controls down-weighting of iterations.
665+
Hyper-parameter that controls how much we will slow down the first steps the first few iterations.
666+
Corresponds to :math:`\\tau_0` from `'Online Learning for LDA' by Hoffman et al.`_
659667
passes : int, optional
660668
Number of times the model makes a pass over the entire training data.
661669
update_every : int, optional

gensim/models/ldamodel.py

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414
1515
The core estimation code is based on the `onlineldavb.py script
1616
<https://github.com/blei-lab/onlineldavb/blob/master/onlineldavb.py>`_, by
17-
`Matthew D. Hoffman, David M. Blei, Francis Bach:
18-
Online Learning for Latent Dirichlet Allocation, NIPS 2010
19-
<https://papers.neurips.cc/paper/2010/file/71f6278d140af599e06ad9bf1ba03cb0-Paper.pdf>`_.
17+
Matthew D. Hoffman, David M. Blei, Francis Bach:
18+
`'Online Learning for Latent Dirichlet Allocation', NIPS 2010`_.
19+
20+
.. _'Online Learning for Latent Dirichlet Allocation', NIPS 2010: online-lda_
21+
.. _'Online Learning for LDA' by Hoffman et al.: online-lda_
22+
.. _online-lda: https://papers.neurips.cc/paper/2010/file/71f6278d140af599e06ad9bf1ba03cb0-Paper.pdf
2023
2124
The algorithm:
2225
@@ -199,8 +202,7 @@ def blend(self, rhot, other, targetsize=None):
199202
200203
The number of documents is stretched in both state objects, so that they are of comparable magnitude.
201204
This procedure corresponds to the stochastic gradient update from
202-
`Hoffman et al. :"Online Learning for Latent Dirichlet Allocation"
203-
<https://papers.neurips.cc/paper/2010/file/71f6278d140af599e06ad9bf1ba03cb0-Paper.pdf>`_, see equations (5) and (9).
205+
`'Online Learning for LDA' by Hoffman et al.`_, see equations (5) and (9).
204206
205207
Parameters
206208
----------
@@ -312,9 +314,7 @@ def load(cls, fname, *args, **kwargs):
312314

313315

314316
class LdaModel(interfaces.TransformationABC, basemodel.BaseTopicModel):
315-
"""Train and use Online Latent Dirichlet Allocation models as presented in
316-
`Hoffman et al. :"Online Learning for Latent Dirichlet Allocation"
317-
<https://papers.neurips.cc/paper/2010/file/71f6278d140af599e06ad9bf1ba03cb0-Paper.pdf>`_.
317+
"""Train and use Online Latent Dirichlet Allocation models as presented in `'Online Learning for LDA' by Hoffman et al.`_
318318
319319
Examples
320320
-------
@@ -396,13 +396,11 @@ def __init__(self, corpus=None, num_topics=100, id2word=None,
396396
* 'auto': Learns an asymmetric prior from the corpus.
397397
decay : float, optional
398398
A number between (0.5, 1] to weight what percentage of the previous lambda value is forgotten
399-
when each new document is examined. Corresponds to Kappa from
400-
`Hoffman et al. :"Online Learning for Latent Dirichlet Allocation"
401-
<https://papers.neurips.cc/paper/2010/file/71f6278d140af599e06ad9bf1ba03cb0-Paper.pdf>`_.
399+
when each new document is examined.
400+
Corresponds to :math:`\\kappa` from `'Online Learning for LDA' by Hoffman et al.`_
402401
offset : float, optional
403402
Hyper-parameter that controls how much we will slow down the first steps the first few iterations.
404-
Corresponds to Tau_0 from `Hoffman et al. :"Online Learning for Latent Dirichlet Allocation"
405-
<https://papers.neurips.cc/paper/2010/file/71f6278d140af599e06ad9bf1ba03cb0-Paper.pdf>`_.
403+
Corresponds to :math:`\\tau_0` from `'Online Learning for LDA' by Hoffman et al.`_
406404
eval_every : int, optional
407405
Log perplexity is estimated every that many updates. Setting this to one slows down training by ~2x.
408406
iterations : int, optional
@@ -862,13 +860,15 @@ def update(self, corpus, chunksize=None, decay=None, offset=None,
862860
863861
Notes
864862
-----
865-
This update also supports updating an already trained model with new documents; the two models are then merged
866-
in proportion to the number of old vs. new documents. This feature is still experimental for non-stationary
867-
input streams. For stationary input (no topic drift in new documents), on the other hand, this equals the
868-
online update of `Hoffman et al. :"Online Learning for Latent Dirichlet Allocation"
869-
<https://papers.neurips.cc/paper/2010/file/71f6278d140af599e06ad9bf1ba03cb0-Paper.pdf>`_
870-
and is guaranteed to converge for any `decay` in (0.5, 1.0). Additionally, for smaller corpus sizes, an
871-
increasing `offset` may be beneficial (see Table 1 in the same paper).
863+
This update also supports updating an already trained model (`self`) with new documents from `corpus`;
864+
the two models are then merged in proportion to the number of old vs. new documents.
865+
This feature is still experimental for non-stationary input streams.
866+
867+
For stationary input (no topic drift in new documents), on the other hand,
868+
this equals the online update of `'Online Learning for LDA' by Hoffman et al.`_
869+
and is guaranteed to converge for any `decay` in (0.5, 1].
870+
Additionally, for smaller corpus sizes,
871+
an increasing `offset` may be beneficial (see Table 1 in the same paper).
872872
873873
Parameters
874874
----------
@@ -879,13 +879,11 @@ def update(self, corpus, chunksize=None, decay=None, offset=None,
879879
Number of documents to be used in each training chunk.
880880
decay : float, optional
881881
A number between (0.5, 1] to weight what percentage of the previous lambda value is forgotten
882-
when each new document is examined. Corresponds to Kappa from
883-
`Hoffman et al. :"Online Learning for Latent Dirichlet Allocation"
884-
<https://papers.neurips.cc/paper/2010/file/71f6278d140af599e06ad9bf1ba03cb0-Paper.pdf>`_.
882+
when each new document is examined. Corresponds to :math:`\\kappa` from
883+
`'Online Learning for LDA' by Hoffman et al.`_
885884
offset : float, optional
886885
Hyper-parameter that controls how much we will slow down the first steps the first few iterations.
887-
Corresponds to Tau_0 from `Hoffman et al. :"Online Learning for Latent Dirichlet Allocation"
888-
<https://papers.neurips.cc/paper/2010/file/71f6278d140af599e06ad9bf1ba03cb0-Paper.pdf>`_.
886+
Corresponds to :math:`\\tau_0` from `'Online Learning for LDA' by Hoffman et al.`_
889887
passes : int, optional
890888
Number of passes through the corpus during training.
891889
update_every : int, optional

gensim/models/ldamulticore.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,13 @@
3838
unseen documents. The model can also be updated with new documents for online training.
3939
4040
The core estimation code is based on the `onlineldavb.py script
41-
<https://github.com/blei-lab/onlineldavb/blob/master/onlineldavb.py>`_, by `Hoffman, Blei, Bach:
42-
Online Learning for Latent Dirichlet Allocation, NIPS 2010 <http://www.cs.princeton.edu/~mdhoffma>`_.
41+
<https://github.com/blei-lab/onlineldavb/blob/master/onlineldavb.py>`_, by
42+
Matthew D. Hoffman, David M. Blei, Francis Bach:
43+
`'Online Learning for Latent Dirichlet Allocation', NIPS 2010`_.
44+
45+
.. _'Online Learning for Latent Dirichlet Allocation', NIPS 2010: online-lda_
46+
.. _'Online Learning for LDA' by Hoffman et al.: online-lda_
47+
.. _online-lda: https://papers.neurips.cc/paper/2010/file/71f6278d140af599e06ad9bf1ba03cb0-Paper.pdf
4348
4449
Usage examples
4550
--------------
@@ -147,13 +152,11 @@ def __init__(self, corpus=None, num_topics=100, id2word=None, workers=None,
147152
* 'auto': Learns an asymmetric prior from the corpus.
148153
decay : float, optional
149154
A number between (0.5, 1] to weight what percentage of the previous lambda value is forgotten
150-
when each new document is examined. Corresponds to Kappa from
151-
`Matthew D. Hoffman, David M. Blei, Francis Bach:
152-
"Online Learning for Latent Dirichlet Allocation NIPS'10" <https://www.di.ens.fr/~fbach/mdhnips2010.pdf>`_.
155+
when each new document is examined. Corresponds to :math:`\\kappa` from
156+
`'Online Learning for LDA' by Hoffman et al.`_
153157
offset : float, optional
154158
Hyper-parameter that controls how much we will slow down the first steps the first few iterations.
155-
Corresponds to Tau_0 from `Matthew D. Hoffman, David M. Blei, Francis Bach:
156-
"Online Learning for Latent Dirichlet Allocation NIPS'10" <https://www.di.ens.fr/~fbach/mdhnips2010.pdf>`_.
159+
Corresponds to :math:`\\tau_0` from `'Online Learning for LDA' by Hoffman et al.`_
157160
eval_every : int, optional
158161
Log perplexity is estimated every that many updates. Setting this to one slows down training by ~2x.
159162
iterations : int, optional
@@ -198,14 +201,13 @@ def update(self, corpus, chunks_as_numpy=False):
198201
199202
Notes
200203
-----
201-
This update also supports updating an already trained model (`self`)
202-
with new documents from `corpus`; the two models are then merged in
203-
proportion to the number of old vs. new documents. This feature is still
204-
experimental for non-stationary input streams.
204+
This update also supports updating an already trained model (`self`) with new documents from `corpus`;
205+
the two models are then merged in proportion to the number of old vs. new documents.
206+
This feature is still experimental for non-stationary input streams.
205207
206208
For stationary input (no topic drift in new documents), on the other hand,
207-
this equals the online update of Hoffman et al. and is guaranteed to
208-
converge for any `decay` in (0.5, 1.0>.
209+
this equals the online update of `'Online Learning for LDA' by Hoffman et al.`_
210+
and is guaranteed to converge for any `decay` in (0.5, 1].
209211
210212
Parameters
211213
----------

0 commit comments

Comments
 (0)