Skip to content

Separate TF-IDF matrix update into a Vectorizer module to be run from a different machine #2

Description

@martinthenext

The goal is to implement Vectorizer module that handles everything concerning tf-idf vector representations of article texts.

How stuff works now

Comand fetch_articles calls Article.objects.download_from(source) and puts articles into the database.

Comand cache_matrices:

  1. Gets all articles from all sources and fits a vectorizer.
  2. Pickles the vectorizer.
  3. Vectorizes all the articles and pickles the huge matrix to tfidf_global.pkl.
  4. For every source vectorizes the articles from this source separately and pickles vectors to tfidf_<source_id>.pkl

As new articles will always contain new terms we need to include into the TF-IDF representation, re-fitting the vectorizer and re-computing vectors for all sources is necessary (at this stage, tickets on sklearn-related optimizations will follow). Luckily:

  1. We don't have to re-run the update too often.
  2. The frequency of updates will not be influenced by the amount of users.

So before we start caring about the opportunity to optimize vectorization, it is important to isolate vectorization into a different module.

Plan

Vectorizer can be a module running on Goldshtein HQ megaframe. It has an access to the database through vpn and runs cache_matrices upon request. The resulting matrices are then available to the django application.

In the conversation with Kirill I thought something more beutiful would work but now I think it's only possible if we find a way to incorporate new terms without re-vectorizing all articles.

Please discuss.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions