The RWKV Language Model
Project description
The RWKV Language Model
https://github.com/BlinkDL/ChatRWKV
https://github.com/BlinkDL/RWKV-LM
# set these before import RWKV
os.environ['RWKV_JIT_ON'] = '1'
os.environ["RWKV_CUDA_ON"] = '0' # if '1' then compile CUDA kernel for seq mode (much faster)
from rwkv.model import RWKV
from rwkv.utils import PIPELINE, PIPELINE_ARGS
pipeline = PIPELINE(model, "20B_tokenizer.json")
model = RWKV(model='/fsx/BlinkDL/HF-MODEL/rwkv-4-pile-169m/RWKV-4-Pile-169M-20220807-8023', strategy='cpu fp32')
ctx = "\nIn a shocking finding, scientist discovered a herd of dragons living in a remote, previously unexplored valley, in Tibet. Even more surprising to the researchers was the fact that the dragons spoke perfect Chinese."
print(ctx, end='')
def my_print(s):
print(s, end='', flush=True)
# For alpha_frequency and alpha_presence, see "Frequency and presence penalties":
# https://platform.openai.com/docs/api-reference/parameter-details
args = PIPELINE_ARGS(temperature = 1.0, top_p = 0.7,
alpha_frequency = 0.25,
alpha_presence = 0.25,
token_ban = [0], # ban the generation of some tokens
token_stop = []) # stop generation whenever you see any token here
pipeline.generate(ctx, token_count=512, args=args, callback=my_print)
print('\n')
out, state = model.forward([187, 510, 1563, 310, 247], None)
print(out.detach().cpu().numpy()) # get logits
out, state = model.forward([187, 510], None)
out, state = model.forward([1563], state) # RNN has state (use deepcopy if you want to clone it)
out, state = model.forward([310, 247], state)
print(out.detach().cpu().numpy()) # same result as above
print('\n')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
rwkv-0.0.3.tar.gz
(12.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
rwkv-0.0.3-py3-none-any.whl
(13.0 kB
view details)
File details
Details for the file rwkv-0.0.3.tar.gz.
File metadata
- Download URL: rwkv-0.0.3.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d02f9b3d5e602ae9aece89a6b2207d044f1bc949b843570e19b3f3f803497d58
|
|
| MD5 |
edc68dc3a8f6de2cc6ee266b8b362191
|
|
| BLAKE2b-256 |
a15339a55ca89321e8cd3238ed1386d371d6522dcbc1ded5f368ebdde91a59d6
|
File details
Details for the file rwkv-0.0.3-py3-none-any.whl.
File metadata
- Download URL: rwkv-0.0.3-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
470ecc4221cd5b9ecf82642f170180f5c62c92ede9f14dfb6367fb2242406471
|
|
| MD5 |
d2b78ef56855f215293fb3af71e36fcd
|
|
| BLAKE2b-256 |
98197bbc2c3d7fdc56e823872f8f49a3cb12b0dad4641eed2a1bfaf4615f9ac8
|