BlinkDL commited on
Commit
1d5e556
1 Parent(s): f714b01

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -10
app.py CHANGED
@@ -6,6 +6,16 @@ from pynvml import *
6
  nvmlInit()
7
  gpu_h = nvmlDeviceGetHandleByIndex(0)
8
  ctx_limit = 1024
 
 
 
 
 
 
 
 
 
 
9
 
10
  def generate_prompt(instruction, input=None):
11
  if input:
@@ -31,9 +41,9 @@ def generate_prompt(instruction, input=None):
31
  def evaluate(
32
  instruction,
33
  input=None,
 
34
  temperature=1.0,
35
- top_p=0.75,
36
- max_new_tokens=200,
37
  **kwargs,
38
  ):
39
  prompt = generate_prompt(instruction, input)
@@ -42,15 +52,11 @@ def evaluate(
42
  g = gr.Interface(
43
  fn=evaluate,
44
  inputs=[
45
- gr.components.Textbox(
46
- lines=2, label="Instruction", placeholder="Tell me about alpacas."
47
- ),
48
  gr.components.Textbox(lines=2, label="Input", placeholder="none"),
49
- gr.components.Slider(minimum=0, maximum=1, value=1.0, label="Temperature"),
50
- gr.components.Slider(minimum=0, maximum=1, value=0.75, label="Top p"),
51
- gr.components.Slider(
52
- minimum=1, maximum=256, step=1, value=200, label="Max tokens"
53
- ),
54
  ],
55
  outputs=[
56
  gr.inputs.Textbox(
 
6
  nvmlInit()
7
  gpu_h = nvmlDeviceGetHandleByIndex(0)
8
  ctx_limit = 1024
9
+ title = "RWKV-4-Pile-7B-Instruct-test4-20230326"
10
+
11
+ os.environ["RWKV_JIT_ON"] = '1'
12
+ os.environ["RWKV_CUDA_ON"] = '1' # if '1' then use CUDA kernel for seq mode (much faster)
13
+
14
+ from rwkv.model import RWKV
15
+ model_path = hf_hub_download(repo_id="BlinkDL/rwkv-4-pile-7b", filename=f"{title}.pth")
16
+ model = RWKV(model=model_path, strategy='cuda fp16i8 *20 -> cuda fp16')
17
+ from rwkv.utils import PIPELINE, PIPELINE_ARGS
18
+ pipeline = PIPELINE(model, "20B_tokenizer.json")
19
 
20
  def generate_prompt(instruction, input=None):
21
  if input:
 
41
  def evaluate(
42
  instruction,
43
  input=None,
44
+ token_count=200,
45
  temperature=1.0,
46
+ top_p=0.7,
 
47
  **kwargs,
48
  ):
49
  prompt = generate_prompt(instruction, input)
 
52
  g = gr.Interface(
53
  fn=evaluate,
54
  inputs=[
55
+ gr.components.Textbox(lines=2, label="Instruction", value="Tell me about alpacas."),
 
 
56
  gr.components.Textbox(lines=2, label="Input", placeholder="none"),
57
+ gr.components.Slider(minimum=10, maximum=250, step=10, value=200),
58
+ gr.components.Slider(minimum=0.2, maximum=2.0, step=0.1, value=1.0),
59
+ gr.components.Slider(minimum=0, maximum=1, step=0.05, value=0.7),
 
 
60
  ],
61
  outputs=[
62
  gr.inputs.Textbox(