Code Monkey home page Code Monkey logo

Comments (2)

martin-gorner avatar martin-gorner commented on August 17, 2024

Hi

Yes, you are correct, argmax+accuracy is a very bad metric. Fortunately, it is not used anywhere during training other than for display, to give you an indication the something good is happening because some metric is going up. A better metric to use here would be "perplexity".

During inference, "sampling from probabilities" is a critical step. If you just use argmax (top probability) you get a sequence of the most probable words in english. Something like "the a for the is the...". That is not what you want. Sampling from probabilities indeed introduces randomness, which opens up the vocabulary of words and generates much more english-sounding sentences.

An even better approach would be to use an algorithm like "beam search" to generate the most probable sequence of n characters instead of just the most probable next character. For example, after "for" the most probable next char is " " (space) because "for" is such a frequent word. However, based on prior context, the most probable sequence could be "form" or "fortran" or indeed "for_". Beam search takes multiple paths through the sequence of probabilities and selects the most probable sequences. In a way, sampling from probabilities implements a weak form of beam search, one that will consider the most probable sequences by chance: there is a chance it picks "form" rather than "for " even though the most probable char after "for" is " " (space). If " " space had 50% probability and "m" was at 35%, sampling from probabilities can still take the "m".

from tensorflow-rnn-shakespeare.

jammygrams avatar jammygrams commented on August 17, 2024

Thanks for the prompt answer - very helpful!

from tensorflow-rnn-shakespeare.

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.