Building a simple chatbot in jupyter using ipywidgets
pip install ipywidgets translate
- load generator:
from ppllama import load_model,setup_model_parallel
local_rank, world_size = setup_model_parallel()
model, generator = load_model(ckpt_dir="ckpt/7B/", tokenizer_path="ckpt/tokenizer.model", local_rank=0, world_size=1)
- load chatbot
from examples.chatbot.ui import SimpleChatbot
bot = SimpleChatbot(usrname="User",
botname="Chatbot",
lang="zh",
max_gen_len=64,
temperature=0.8,
top_p=0.95,
prompt=None)
bot.set_generator(generator)
bot.show()
# bot.clear() # clear chat history
- use baidu translator (optional):
APPID= YOUR_APPID
APPKEY= YOUR_APPKEY
bot.switch_baidu_fanyi(appid=APPID, appkey=APPKEY)
bot.show()