Giter VIP home page Giter VIP logo

promptgentf's Introduction

PromptGenTF

A Simple and Efficient PromptGen Inference Implementation In TensorFlow 2.

Super easy to use

    from gpt2 import GPT2
    from gpt2_tokenizer import GPT2Tokenizer
    from gpt2_causal_lm import GPT2CausalLMPreprocessor, GPT2CausalLM
    sequence_length = 128
    max_length = 1024
    seed = 123
    tokenizer = GPT2Tokenizer()
    preprocessor = GPT2CausalLMPreprocessor(tokenizer=tokenizer, sequence_length=sequence_length)
    gpt2_backbone = GPT2(vocabulary_size=50257, num_layers=6, num_heads=12, hidden_dim=768, intermediate_dim=3072,
                         max_sequence_length=1024)
    # download form:
    # https://huggingface.co/AUTOMATIC/promptgen-lexart/blob/main/pytorch_model.bin
    pytorch_model = "pytorch_model.bin"
    gpt2_backbone.load_weights_from_ckpt(pytorch_model)
    gpt2_lm = GPT2CausalLM(
        backbone=gpt2_backbone,
        preprocessor=preprocessor, seed=seed)
    z = gpt2_lm.generate(["a girl.", "a cat."], max_length=max_length)
    print(z)

Credits

Licenses for borrowed code can be found in following link:

Donating

If this project useful for you, please consider buying me a cup of coffee or sponsoring me!

Buy Me A Coffee

promptgentf's People

Contributors

cpuimage avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

xiusdk

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.