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:
- Gets all articles from all sources and fits a vectorizer.
- Pickles the vectorizer.
- Vectorizes all the articles and pickles the huge matrix to
tfidf_global.pkl.
- 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:
- We don't have to re-run the update too often.
- 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.
The goal is to implement Vectorizer module that handles everything concerning tf-idf vector representations of article texts.
How stuff works now
Comand
fetch_articlescallsArticle.objects.download_from(source)and puts articles into the database.Comand
cache_matrices:tfidf_global.pkl.tfidf_<source_id>.pklAs 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:
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_matricesupon 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.