main
BlinkDL 3 years ago
parent b2a240d73d
commit b4925900e7

@ -17,12 +17,11 @@ np.set_printoptions(precision=4, suppress=True, linewidth=200)
args = types.SimpleNamespace() args = types.SimpleNamespace()
######################################################################################################## ########################################################################################################
# Step 1: set model & config # Step 1: set model & config (use v4 to run your trained-from-scratch models. v4 and v4neo are compatible)
# Do this first: pip install torchdynamo
######################################################################################################## ########################################################################################################
args.RUN_DEVICE = "cpu" # 'cpu' (already fast) // 'cuda' args.RUN_DEVICE = "cuda" # 'cuda' // 'cpu' (already fast)
args.FLOAT_MODE = "fp32" # fp32 (good for CPU) // fp16 (good for GPU, does not work for CPU) // bf16 (less accurate, but works for CPU) args.FLOAT_MODE = "fp16" # fp16 (good for GPU, does not work for CPU) // fp32 (good for CPU) // bf16 (less accurate, but works for CPU)
# if args.RUN_DEVICE == "cuda": # if args.RUN_DEVICE == "cuda":
# os.environ["RWKV_RUN_BACKEND"] = 'nvfuser' # !!!BUGGY!!! wrong output # os.environ["RWKV_RUN_BACKEND"] = 'nvfuser' # !!!BUGGY!!! wrong output
@ -87,6 +86,16 @@ context = "\nIn a shocking finding, scientist discovered a herd of dragons livin
# context = "\n深圳是" # test Chinese # context = "\n深圳是" # test Chinese
# context = "\n東京は" # test Japanese # context = "\n東京は" # test Japanese
# ###### A good prompt for Q&A ######
# context = '''
# Questions & Helpful Answers
# Ask Research Experts
# Question:
# Can penguins fly?
# Full Answer:
# '''
# ###### A good prompt for chatbot ###### # ###### A good prompt for chatbot ######
# context = ''' # context = '''
# The following is a conversation between a highly knowledgeable and intelligent AI assistant called Bot, and a human user called User. In the following interactions, User and Bot converse in natural language, and Bot always answer User's questions. Bot is very smart, polite and humorous. Bot 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 Bot, and a human user called User. In the following interactions, User and Bot converse in natural language, and Bot always answer User's questions. Bot is very smart, polite and humorous. Bot knows a lot, and always tells the truth. The conversation begins.
@ -215,7 +224,7 @@ for TRIAL in range(1 if DEBUG_DEBUG else NUM_TRIALS):
print(char, end="", flush=True) print(char, end="", flush=True)
else: else:
char = tokenizer.tokenizer.decode(ctx[out_last:]) char = tokenizer.tokenizer.decode(ctx[out_last:])
if '\ufffd' not in char: if '\ufffd' not in char: # is valid utf8 string?
print(char, end="", flush=True) print(char, end="", flush=True)
out_last = i+1 out_last = i+1

Loading…
Cancel
Save