Giter VIP home page Giter VIP logo

web-rwkv-py's Introduction

Web-RWKV-Py

Python binding for web-rwkv.

Todos

  • Basic V5 inference support
  • Support V4, V5 and V6
  • Batched inference

Usage

  1. Install python and rust.

  2. Install maturin by

    $ pip install maturin
  3. Build and install:

    $ maturin develop --release
  4. Try using web-rwkv in python:

    import web_rwkv_py as wrp
    
    model = wrp.Model(
       "/path/to/model.st", # model path
       quant=0,             # int8 quantization layers
       quant_nf4=0,         # nf4 quantization layers
    )
    model.clear_state()
    logits = model.run([114, 514])

Advanced Usage

  1. Get, clone and load current state:

    logits = model.run([114, 514])
    state = model.back_state(wrp.StateDevice.Gpu)
    # state = model.back_state(wrp.StateDevice.Cpu)
    state_cloned = state.deep_clone()
    
    model.load_state(state_cloned)
    logits = model.run([1919, 810])
  2. Return predictions of all tokens (not only the last's):

    logits, state = model.run_full([114, 514, 1919, 810], state=None)
    assert(len(logits) == 4)

web-rwkv-py's People

Contributors

cryscan avatar josstorer avatar

Stargazers

 avatar OpenMOSE avatar WuTianyi avatar Jonathan Gonzalez avatar Murugurugan avatar  avatar Jade avatar Rolex avatar PJ568 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.