icashwave commited on
Commit
8a3d33f
1 Parent(s): 30f7265

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -15
app.py CHANGED
@@ -9,8 +9,11 @@ HAS_GPU = False
9
 
10
  # Model title and context size limit
11
  ctx_limit = 2000
12
- title = "RWKV-5-World-1B5-v2-20231025-ctx4096"
13
- model_file = "RWKV-5-World-1B5-v2-20231025-ctx4096"
 
 
 
14
 
15
  # Get the GPU count
16
  try:
@@ -42,23 +45,34 @@ from rwkv.utils import PIPELINE, PIPELINE_ARGS
42
  pipeline = PIPELINE(model, "rwkv_vocab_v20230424")
43
 
44
  # Prompt generation
45
- def generate_prompt(instruction, input=""):
46
- instruction = instruction.strip().replace('\r\n','\n').replace('\n\n','\n')
47
- input = input.strip().replace('\r\n','\n').replace('\n\n','\n')
48
- if input:
49
- return f"""Instruction: {instruction}
50
 
51
- Input: {input}
52
 
53
- Response:"""
54
- else:
55
- return f"""User: hi
56
 
57
- Assistant: Hi. I am your assistant and I will provide expert full response in full details. Please feel free to ask any question and I will always answer it.
58
 
59
- User: {instruction}
60
 
61
- Assistant:"""
 
 
 
 
 
 
 
 
 
 
 
62
 
63
  # Evaluation logic
64
  def evaluate(
@@ -147,7 +161,11 @@ with gr.Blocks(title=title) as demo:
147
  gr.Markdown(f"This is [RWKV-5 World v2](https://huggingface.co/BlinkDL/rwkv-5-world) with 1.5B params - a 100% attention-free RNN [RWKV-LM](https://github.com/BlinkDL/RWKV-LM). Supports all 100+ world languages and code. And we have [200+ Github RWKV projects](https://github.com/search?o=desc&p=1&q=rwkv&s=updated&type=Repositories). *** Please try examples first (bottom of page) *** (edit them to use your question). Demo limited to ctxlen {ctx_limit}.")
148
  with gr.Row():
149
  with gr.Column():
150
- prompt = gr.Textbox(lines=2, label="Prompt", value="Assistant: Sure! Here is a very detailed plan to create flying pigs:")
 
 
 
 
151
  token_count = gr.Slider(10, 333, label="Max Tokens", step=10, value=333)
152
  temperature = gr.Slider(0.2, 2.0, label="Temperature", step=0.1, value=1.0)
153
  top_p = gr.Slider(0.0, 1.0, label="Top P", step=0.05, value=0.3)
 
9
 
10
  # Model title and context size limit
11
  ctx_limit = 2000
12
+ #title = "RWKV-5-World-1B5-v2-20231025-ctx4096"
13
+ #model_file = "RWKV-5-World-1B5-v2-20231025-ctx4096"
14
+
15
+ title = "RWKV-4-World"
16
+ model_file = "RWKV-4-World-7B-v1-20230626-ctx4096"
17
 
18
  # Get the GPU count
19
  try:
 
45
  pipeline = PIPELINE(model, "rwkv_vocab_v20230424")
46
 
47
  # Prompt generation
48
+ #def generate_prompt(instruction, input=""):
49
+ #instruction = instruction.strip().replace('\r\n','\n').replace('\n\n','\n')
50
+ #input = input.strip().replace('\r\n','\n').replace('\n\n','\n')
51
+ #if input:
52
+ #return f"""Instruction: {instruction}
53
 
54
+ #Input: {input}
55
 
56
+ #Response:"""
57
+ #else:
58
+ #return f"""User: hi
59
 
60
+ #Assistant: Hi. I am your assistant and I will provide expert full response in full details. Please feel free to ask any question and I will always answer it.
61
 
62
+ #User: {instruction}
63
 
64
+ #Assistant:"""
65
+
66
+ def generate_prompt(instruction, input=None):
67
+ instruction = instruction.strip().replace('\r\n','\n').replace('\n\n','\n').replace('\n\n','\n')
68
+ input = input.strip().replace('\r\n','\n').replace('\n\n','\n').replace('\n\n','\n')
69
+ if input:
70
+ return f"""Instruction: {instruction}
71
+ Input: {input}
72
+ Response:"""
73
+ else:
74
+ return f"""Question: {instruction}
75
+ Answer:"""
76
 
77
  # Evaluation logic
78
  def evaluate(
 
161
  gr.Markdown(f"This is [RWKV-5 World v2](https://huggingface.co/BlinkDL/rwkv-5-world) with 1.5B params - a 100% attention-free RNN [RWKV-LM](https://github.com/BlinkDL/RWKV-LM). Supports all 100+ world languages and code. And we have [200+ Github RWKV projects](https://github.com/search?o=desc&p=1&q=rwkv&s=updated&type=Repositories). *** Please try examples first (bottom of page) *** (edit them to use your question). Demo limited to ctxlen {ctx_limit}.")
162
  with gr.Row():
163
  with gr.Column():
164
+ #prompt = gr.Textbox(lines=2, label="Prompt", value="Assistant: Sure! Here is a very detailed plan to create flying pigs:")
165
+
166
+ instruction = gr.Textbox(lines=2, label="Instruction", value='東京で訪れるべき素晴らしい場所とその紹介をいくつか挙げてください。')
167
+ input = gr.Textbox(lines=2, label="Input", placeholder="none")
168
+
169
  token_count = gr.Slider(10, 333, label="Max Tokens", step=10, value=333)
170
  temperature = gr.Slider(0.2, 2.0, label="Temperature", step=0.1, value=1.0)
171
  top_p = gr.Slider(0.0, 1.0, label="Top P", step=0.05, value=0.3)