# context = "\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."
context="\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."
context="\n深圳是"# test Chinese
# context = "\n深圳是" # test Chinese
context="\n東京は"# test Japanese
# context = "\n東京は" # test Japanese
# context = ''' # A good prompt for chatbot
###### A good prompt for chatbot ######
# context = '''
# The following is a conversation between a highly knowledgeable and intelligent AI assistant, called RWKV, and a human user, called User. In the following interactions, User and RWKV will converse in natural language, and RWKV will do its best to answer User’s questions. RWKV was built to be respectful, polite and inclusive. It knows a lot, and always tells the truth. The conversation begins.
# The following is a conversation between a highly knowledgeable and intelligent AI assistant, called RWKV, and a human user, called User. In the following interactions, User and RWKV will converse in natural language, and RWKV will do its best to answer User’s questions. RWKV was built to be respectful, polite and inclusive. It knows a lot, and always tells the truth. The conversation begins.
# User: OK RWKV, I’m going to start by quizzing you with a few warm-up questions. Who is currently the president of the USA?
# User: OK RWKV, I’m going to start by quizzing you with a few warm-up questions. Who is currently the president of the USA?
print("\nYour prompt has "+str(src_len)+" tokens.")
print("Your prompt has "+str(src_len)+" tokens.")
print(
print(
"\n--> Currently the first run takes a while if your prompt is long, as we are using RNN to process the prompt. Use GPT to build the hidden state for better speed. <--\n"
"\nNote: currently the first run takes a while if your prompt is long, as we are using RNN to preprocess the prompt. Use GPT to build the hidden state for better speed.\n"
)
)
# time_slot = {}
time_slot={}
# time_ref = time.time_ns()
time_ref=time.time_ns()
# def record_time(name):
defrecord_time(name):
# if name not in time_slot:
if name not in time_slot:
# time_slot[name] = 1e20
time_slot[name] = 1e20
# tt = (time.time_ns() - time_ref) / 1e9
tt = (time.time_ns() - time_ref) / 1e9
# if tt < time_slot[name]:
iftt<time_slot[name]:
# time_slot[name] = tt
time_slot[name] = tt
forTRIALinrange(1ifDEBUG_DEBUGelseNUM_TRIALS):
forTRIALinrange(1ifDEBUG_DEBUGelseNUM_TRIALS):
# time_ref = time.time_ns()
print(("-"*50)+'\n'+context,end="")
print(("-"*50)+context,end="")
time_ref=time.time_ns()
ctx=src_ctx.copy()
ctx=src_ctx.copy()
model.clear()
model.clear()
@ -172,11 +173,9 @@ for TRIAL in range(1 if DEBUG_DEBUG else NUM_TRIALS):