class_docstr: Model for `Latent Semantic Indexing
  <https://en.wikipedia.org/wiki/Latent_semantic_analysis#Latent_semantic_indexing>`_.
  
  The decomposition algorithm is described in `"Fast and Faster: A Comparison of Two Streamed
  Matrix Decomposition Algorithms" <https://arxiv.org/pdf/1102.5597.pdf>`_.
  
  Notes
  -----
  * :attr:`gensim.models.lsimodel.LsiModel.projection.u` - left singular vectors,
  * :attr:`gensim.models.lsimodel.LsiModel.projection.s` - singular values,
  * ``model[training_corpus]`` - right singular vectors (can be reconstructed if needed).
  
  See Also
  --------
  `FAQ about LSI matrices
  <https://github.com/RaRe-Technologies/gensim/wiki/Recipes-&-FAQ#q4-how-do-you-output-the-u-s-vt-matrices-of-lsi>`_.
  
  Examples
  --------
  .. sourcecode:: pycon
  
      >>> from gensim.test.utils import common_corpus, common_dictionary, get_tmpfile
      >>> from gensim.models import LsiModel
      >>>
      >>> model = LsiModel(common_corpus[:3], id2word=common_dictionary)  # train model
      >>> vector = model[common_corpus[4]]  # apply model to BoW document
      >>> model.add_documents(common_corpus[4:])  # update model with new documents
      >>> tmp_fname = get_tmpfile("lsi.model")
      >>> model.save(tmp_fname)  # save model
      >>> loaded_model = LsiModel.load(tmp_fname)  # load model
class_docstr_tok: ["Model","for","`","Latent","Semantic","Indexing","<","https",":","\/\/en.wikipedia.org\/wiki\/Latent_semantic_analysis","#","Latent_semantic_indexing",">","`","_",".","The","decomposition","algorithm","is","described","in","`","``","Fast","and","Faster",":","A","Comparison","of","Two","Streamed","Matrix","Decomposition","Algorithms","''","<","https",":","\/\/arxiv.org\/pdf\/1102.5597.pdf",">","`","_",".","Notes","--","--","-","*",":","attr",":","`","gensim.models.lsimodel.LsiModel.projection.u","`","-","left","singular","vectors",",","*",":","attr",":","`","gensim.models.lsimodel.LsiModel.projection.s","`","-","singular","values",",","*","``","model","[","training_corpus","]","``","-","right","singular","vectors","(","can","be","reconstructed","if","needed",")",".","See","Also","--","--","--","--","`","FAQ","about","LSI","matrices","<","https",":","\/\/github.com\/RaRe-Technologies\/gensim\/wiki\/Recipes-","&","-FAQ","#","q4-how-do-you-output-the-u-s-vt-matrices-of-lsi",">","`","_",".","Examples","--","--","--","--","..","sourcecode",":",":","pycon",">",">",">","from","gensim.test.utils","import","common_corpus",",","common_dictionary",",","get_tmpfile",">",">",">","from","gensim.models","import","LsiModel",">",">",">",">",">",">","model","=","LsiModel","(","common_corpus","[",":3","]",",","id2word=common_dictionary",")","#","train","model",">",">",">","vector","=","model","[","common_corpus","[","4","]","]","#","apply","model","to","BoW","document",">",">",">","model.add_documents","(","common_corpus","[","4",":","]",")","#","update","model","with","new","documents",">",">",">","tmp_fname","=","get_tmpfile","(","``","lsi.model","''",")",">",">",">","model.save","(","tmp_fname",")","#","save","model",">",">",">","loaded_model","=","LsiModel.load","(","tmp_fname",")","#","load","model"]
docstr: Update model with new `corpus`.
  
  Parameters
  ----------
  corpus : {iterable of list of (int, float), scipy.sparse.csc}
      Stream of document vectors or sparse matrix of shape (`num_terms`, num_documents).
  chunksize : int, optional
      Number of documents to be used in each training chunk, will use `self.chunksize` if not specified.
  decay : float, optional
      Weight of existing observations relatively to new ones,  will use `self.decay` if not specified.
  
  Notes
  -----
  Training proceeds in chunks of `chunksize` documents at a time. The size of `chunksize` is a tradeoff
  between increased speed (bigger `chunksize`) vs. lower memory footprint (smaller `chunksize`).
  If the distributed mode is on, each chunk is sent to a different worker/computer.
docstr_tok: ["Update","model","with","new","`","corpus","`",".","Parameters","--","--","--","--","--","corpus",":","{","iterable","of","list","of","(","int",",","float",")",",","scipy.sparse.csc","}","Stream","of","document","vectors","or","sparse","matrix","of","shape","(","`","num_terms","`",",","num_documents",")",".","chunksize",":","int",",","optional","Number","of","documents","to","be","used","in","each","training","chunk",",","will","use","`","self.chunksize","`","if","not","specified",".","decay",":","float",",","optional","Weight","of","existing","observations","relatively","to","new","ones",",","will","use","`","self.decay","`","if","not","specified",".","Notes","--","--","-","Training","proceeds","in","chunks","of","`","chunksize","`","documents","at","a","time",".","The","size","of","`","chunksize","`","is","a","tradeoff","between","increased","speed","(","bigger","`","chunksize","`",")","vs.","lower","memory","footprint","(","smaller","`","chunksize","`",")",".","If","the","distributed","mode","is","on",",","each","chunk","is","sent","to","a","different","worker\/computer","."]
code: def add_documents(self, corpus, chunksize=None, decay=None):
      """Update model with new `corpus`.
  
      Parameters
      ----------
      corpus : {iterable of list of (int, float), scipy.sparse.csc}
          Stream of document vectors or sparse matrix of shape (`num_terms`, num_documents).
      chunksize : int, optional
          Number of documents to be used in each training chunk, will use `self.chunksize` if not specified.
      decay : float, optional
          Weight of existing observations relatively to new ones,  will use `self.decay` if not specified.
  
      Notes
      -----
      Training proceeds in chunks of `chunksize` documents at a time. The size of `chunksize` is a tradeoff
      between increased speed (bigger `chunksize`) vs. lower memory footprint (smaller `chunksize`).
      If the distributed mode is on, each chunk is sent to a different worker/computer.
  
      """
      logger.info("updating model with new documents")
  
      # get computation parameters; if not specified, use the ones from constructor
      if chunksize is None:
          chunksize = self.chunksize
      if decay is None:
          decay = self.decay
      if is_empty(corpus):
          logger.warning(
              "LsiModel.add_documents() called but no documents provided, is this intended?"
          )
      if not scipy.sparse.issparse(corpus):
          if not self.onepass:
              # we are allowed multiple passes over the input => use a faster, randomized two-pass algo
              update = Projection(
                  self.num_terms,
                  self.num_topics,
                  None,
                  dtype=self.dtype,
                  random_seed=self.random_seed,
              )
              update.u, update.s = stochastic_svd(
                  corpus,
                  self.num_topics,
                  num_terms=self.num_terms,
                  chunksize=chunksize,
                  extra_dims=self.extra_samples,
                  power_iters=self.power_iters,
                  dtype=self.dtype,
                  random_seed=self.random_seed,
              )
              self.projection.merge(update, decay=decay)
              self.docs_processed += (
                  len(corpus) if hasattr(corpus, "__len__") else 0
              )
          else:
              # the one-pass algo
              doc_no = 0
              if self.dispatcher:
                  logger.info(
                      "initializing %s workers", self.numworkers
                  )
                  self.dispatcher.reset()
              for chunk_no, chunk in enumerate(
                  utils.grouper(corpus, chunksize)
              ):
                  logger.info("preparing a new chunk of documents")
                  nnz = sum(len(doc) for doc in chunk)
                  # construct the job as a sparse matrix, to minimize memory overhead
                  # definitely avoid materializing it as a dense matrix!
                  logger.debug("converting corpus to csc format")
                  job = matutils.corpus2csc(
                      chunk,
                      num_docs=len(chunk),
                      num_terms=self.num_terms,
                      num_nnz=nnz,
                      dtype=self.dtype,
                  )
                  del chunk
                  doc_no += job.shape[1]
                  if self.dispatcher:
                      # distributed version: add this job to the job queue, so workers can work on it
                      logger.debug("creating job #%i", chunk_no)
                      # put job into queue; this will eventually block, because the queue has a small finite size
                      self.dispatcher.putjob(job)
                      del job
                      logger.info(
                          "dispatched documents up to #%s", doc_no
                      )
                  else:
                      # serial version, there is only one "worker" (myself) => process the job directly
                      update = Projection(
                          self.num_terms,
                          self.num_topics,
                          job,
                          extra_dims=self.extra_samples,
                          power_iters=self.power_iters,
                          dtype=self.dtype,
                          random_seed=self.random_seed,
                      )
                      del job
                      self.projection.merge(update, decay=decay)
                      del update
                      logger.info(
                          "processed documents up to #%s", doc_no
                      )
                      self.print_topics(5)
  
              # wait for all workers to finish (distributed version only)
              if self.dispatcher:
                  logger.info(
                      "reached the end of input; now waiting for all remaining jobs to finish"
                  )
                  self.projection = self.dispatcher.getstate()
              self.docs_processed += doc_no
      else:
          assert (
              not self.dispatcher
          ), "must be in serial mode to receive jobs"
          update = Projection(
              self.num_terms,
              self.num_topics,
              corpus.tocsc(),
              extra_dims=self.extra_samples,
              power_iters=self.power_iters,
              dtype=self.dtype,
          )
          self.projection.merge(update, decay=decay)
          logger.info(
              "processed sparse job of %i documents", corpus.shape[1]
          )
          self.docs_processed += corpus.shape[1]
  
imports: import logging
  import sys
  import time
  import numpy
  import scipy.linalg
  import scipy.sparse
  from scipy.sparse import sparsetools
  from gensim import interfaces, matutils, utils
  from gensim.models import basemodel
  from gensim.utils import is_empty
label_desc: Use image node_id 2 for calling the LsiModel obj's underlying member method code with example usage: obj.add_documents(corpus, chunksize, decay) without return types