Giter VIP home page Giter VIP logo

ernie's Introduction

The concept of bidirectional expansion in this script refers to the method of growing the generated text both forward (rightward) and backward (leftward) from the initial seed point, using masked language modeling. This technique is implemented to enhance the contextuality and richness of the generated text by allowing the model to add relevant content on both sides of the initial input.

Implementation of Bidirectional Expansion

  1. Initial Seed Processing:

    • The process begins with a seed word or phrase which is first preprocessed to fit the model's requirements, including replacing special placeholders with actual model tokens (like replacing [MASK] with BERT’s mask token).
  2. Adding Mask Tokens:

    • At each iteration of the text generation cycle, mask tokens are added at both the beginning and the end of the current text sequence. This is done to prompt the model to consider expanding the text in both directions.
    • For example, if your current text is "today is a beautiful", the script might modify it to "[MASK] today is a beautiful [MASK]". This encourages the model to predict suitable words to add before "today" and after "beautiful".
  3. Prediction and Replacement of Mask Tokens:

    • With the newly added mask tokens, the sequence is fed into the BERT model. BERT predicts the most probable replacements for the mask tokens based on the surrounding context.
    • The script selects top candidates for each masked position, and these candidates are then evaluated for how well they fit into the overall sentence, maintaining grammatical and contextual coherence.
  4. Iterative Refinement:

    • This expansion process is not done in a single step but rather iteratively over several cycles, allowing for gradual development of the text. Each cycle can introduce new masked tokens at the edges of the text, continuously prompting the model to expand further.
    • During each iteration, the model’s predictions are refined based on the feedback from both the BERT and GPT-2 models, where BERT suggests possible word choices and GPT-2 evaluates the coherence of the resulting sentences.
  5. Dynamic Adjustment:

    • The process dynamically adjusts the length and direction of expansion based on various factors, such as reaching a maximum length limit or achieving satisfactory coherence in the generated text, at which point no new mask tokens might be added.

ernie's People

Contributors

everyoneisgross avatar

Watchers

 avatar  avatar

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.