Giter VIP home page Giter VIP logo

Comments (4)

piskvorky avatar piskvorky commented on May 15, 2024

Ok, I added the option to initialize TfidfModel via an existing Dictionary object, commit c65b3ff .

This can help if a) we have the dictionary in the first place (the corpus was constructed through dictionary.doc2bow) and b) corpus iteration is slow, so the one extra pass that we save this way matters.

I also PEP8-fied the tfidf code while i was at it.

from gensim.

Dieterbe avatar Dieterbe commented on May 15, 2024

I find it interesting that your commit message implies this change is only beneficial "if your corpus is super slow".
I would think building your idfs from the dict dfs will almost always be faster then iterating over the corpus. even if iterating over the corpus is not i/o constrained (reading from disk, or over network, as you suggest), the corpus approach has some overhead (it retrieves full documents which may need to be converted to the BOW model, it needs to do more math, etc) whereas the dict approach has the numbers it needs right away.

Either way, I just did one testrun, and I'm not seeing a noticeable speedup yet, which suprises me...
edit: after a few more testruns, I actually think I see a speedup :) about 20-50% faster (hard to tell precisely because there is a big spread in my timings)
edit2 : oops my previous testruns were not correctly executed. I now see about x100 speedup in tfidf model building

from gensim.

piskvorky avatar piskvorky commented on May 15, 2024

Yeah it will be always faster, no question about it.

That comment meant that in a broader perspective (computing similarities, LSI, LDA, ...), the one extra pass that increments a few number is negligible. Unless the pass (corpus iteration) itself is very expensive -- then it matters. In some cases, it might matter a lot, which in my opinion outweighs the added complexity of the code; that's why I accepted this feature.

from gensim.

Dieterbe avatar Dieterbe commented on May 15, 2024

Aha. I see. Thanks.

from gensim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.