BlinkDL commited on
Commit
e692a01
·
verified ·
1 Parent(s): 848abf2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -7
app.py CHANGED
@@ -77,12 +77,22 @@ def evaluate(
77
  state = None
78
  for i in range(int(token_count)):
79
 
80
- input_ids = pipeline.encode(ctx)[-ctx_limit:] if i == 0 else [token]
81
- out, state = model.forward(input_ids, state)
 
 
 
 
 
 
 
 
 
 
82
  for n in occurrence:
83
- out[n] -= (args.alpha_presence + occurrence[n] * args.alpha_frequency)
84
 
85
- token = pipeline.sample_logits(out, temperature=args.temperature, top_p=args.top_p)
86
  if token in args.token_stop:
87
  break
88
  all_tokens += [token]
@@ -91,8 +101,8 @@ def evaluate(
91
 
92
  ttt = pipeline.decode([token])
93
  www = 1
94
- if ttt in ' \t0123456789':
95
- www = 0
96
  #elif ttt in '\r\n,.;?!"\':+-*/=#@$%^&_`~|<>\\()[]{},。;“”:?!()【】':
97
  # www = 0.5
98
  if token not in occurrence:
@@ -138,7 +148,7 @@ with gr.Blocks(title=title, theme=gr.themes.Base()) as demo:
138
  gr.HTML(f"<div style=\"text-align: center;\">\n<h1>{title}</h1>\n</div>")
139
 
140
  with gr.Tab("=== Base Model (Raw Generation) ==="):
141
- gr.Markdown(f'This is [RWKV7 G-series](https://huggingface.co/BlinkDL/rwkv7-g1) 2.9B reasoning base LM - an attention-free pure RNN [RWKV-LM](https://github.com/BlinkDL/RWKV-LM). Try topp0 penalty0 for math/code/translation. Supports 100+ world languages and code. Check [400+ Github RWKV projects](https://github.com/search?o=desc&p=1&q=rwkv&s=updated&type=Repositories). *** Can try examples (bottom of page) *** (can edit them). Demo limited to ctxlen {ctx_limit}.')
142
  with gr.Row():
143
  with gr.Column():
144
  prompt = gr.Textbox(lines=6, label="Prompt", value="User: simulate SpaceX mars landing using python\n\nAssistant: <think")
 
77
  state = None
78
  for i in range(int(token_count)):
79
 
80
+ if i == 0:
81
+ input_ids = pipeline.encode(ctx)[-ctx_limit:]
82
+ out, state = model.forward(input_ids, state)
83
+ for j in range(len(state)):
84
+ static_state_in[j].copy_(state[j])
85
+ static_output.copy_(out)
86
+ else:
87
+ static_input.copy_(model.z['emb.weight'][token])
88
+ graph.replay()
89
+ for j in range(len(state)):
90
+ static_state_in[j].copy_(static_state_out[j])
91
+
92
  for n in occurrence:
93
+ static_output[n] -= (args.alpha_presence + occurrence[n] * args.alpha_frequency)
94
 
95
+ token = pipeline.sample_logits(static_output, temperature=args.temperature, top_p=args.top_p)
96
  if token in args.token_stop:
97
  break
98
  all_tokens += [token]
 
101
 
102
  ttt = pipeline.decode([token])
103
  www = 1
104
+ #if ttt in ' \t0123456789':
105
+ # www = 0
106
  #elif ttt in '\r\n,.;?!"\':+-*/=#@$%^&_`~|<>\\()[]{},。;“”:?!()【】':
107
  # www = 0.5
108
  if token not in occurrence:
 
148
  gr.HTML(f"<div style=\"text-align: center;\">\n<h1>{title}</h1>\n</div>")
149
 
150
  with gr.Tab("=== Base Model (Raw Generation) ==="):
151
+ gr.Markdown(f'This is [RWKV7 G-series](https://huggingface.co/BlinkDL/rwkv7-g1) 2.9B reasoning base LM - an attention-free pure RNN [RWKV-LM](https://github.com/BlinkDL/RWKV-LM). Try topp0 penalty0 for math/code/translation. Supports 100+ world languages and code. Check [600+ Github RWKV projects](https://github.com/search?o=desc&p=1&q=rwkv&s=updated&type=Repositories). *** Can try examples (bottom of page) *** (can edit them). Demo limited to ctxlen {ctx_limit}.')
152
  with gr.Row():
153
  with gr.Column():
154
  prompt = gr.Textbox(lines=6, label="Prompt", value="User: simulate SpaceX mars landing using python\n\nAssistant: <think")