一个针对聊天进行了相对调整的 GPT-2 Telegram 聊天机器人。请随时为我制作 PR,我会检查您的代码!该机器人并非始终 100% 准确(为什么我在 /retry 函数中进行编码。)
由于机器人消耗大量内存,因此我以循环模式对其进行编程。每次输入都会在您的帐户 ID 上重置计时器,一旦计时器耗尽,机器人就可以免费供其他用户使用。当计时器耗尽时,您会收到通知,其他用户可以查看还剩多少时间以及机器人是否正在使用。
Ubuntu 20/WSL 上的简要安装说明。
我强烈建议您查看 google collab 上的 jupyter notebook/ipynb。
安装python3.7(我认为3.6也可以,但3.8不行):
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.7
在 python 3.7 上安装 pip:
wget https://bootstrap.pypa.io/get-pip.py
python3.7 get-pip.py
克隆存储库后在 bot 文件夹内安装需求:
python3.7 -m pip install -r requirements.txt
注意:您实际上需要 16GB 内存或 8GB 显卡。否则你将永远等待。您可以使用至少支持 cuda takelit 10.0 和 cudnn for cuda toolkit 10 的 8GB 显卡的 GPU 功能。此安装也适用于带有 python 3.7 和 nvidia 的 Windows,您必须以管理员身份在 Windows 上运行 python 3.7 来运行命令提示符。
下载模型:
python3.7 download_model.py 1558M
在 src/GPT2-Learning.py 中设置您的电报机器人 API 密钥
Replace "BOTKEY" with telegram bot token i.e. "1827396499:AAHifc06oS31oQ9L3TuCiZxD9EIfKPi0oWQ"
运行机器人:
如果使用 python3 命令:
./start.sh
如果使用python3.7命令:
python3.7 src/GPT2-Learning.py
您可以根据需要编辑 start.sh 以匹配您的 python 命令。
start - Basic start command.
help - Show quick help command.
chatbot - Chatbot mode, me+you string edit and open-ended questions.
finish - Default finish sentence command counting words as output length.
learnon - Turn on sentence compilation with Me+you string for conversation.
learnoff - Turn off the sentence compilation.
learnreset - Reset the learned conversation.
retry - Retry the current computation.
这是学习聊天机器人模式的示例,使用最新的 gpt-2 数据库并将 top_p 设置为 0.83:
Me: Hello! How are you today? Are you feeling alright? I hope you are doing well and not getting into any trouble.
Bot: Yeah, I'm fine. Do you want to make something to eat?
Me: I already made some food, but thanks! I had some jalapeno poppers. I made a ton of them last night after I sold a lawnmower to some folks I got for free earlier in the day. So what are your plans for the day?
Bot: Nothing special. Nothing exciting in particular. I just wanna chill out for a bit.
Me: Just a typical day of kicking back and relaxing huh? Are you gonna watch cartoons or any movies in particular?
Bot: If it's not sports I'll probably just watch something on the TV.
Me: Sounds alright. I coded on my chatbot project most of the morning. Was waiting on someone to come buy a projector but they haven't shown up yet unfortunately. What do you do for work if you don't mind me asking?
Bot: I'm a web developer and engineer. It's fun.
Me: Cool! I'm also a coder and an ethical hacker. I mostly know how to code in Python but I've been unemployed for some time now after my spine injury. I wish I could have joined the military when I was younger. Were you ever in the military?
Bot: No. I'm not really too proud of my military career. It ended up taking a huge toll on my back.
Me: What happened to your back if you don't mind me asking?
Bot: First of all, it's better than before.
Me: Well that's good to hear. Did you injure your back in the military or doing something else?
Bot: Nope. It's an old injury.
Me: Ah I see- Well I'll talk to you later. Sorry about your back! I hope we can catch up tomorrow!
Bot: Yes, of course. Thanks again for chatting!
INFO:tensorflow:Restoring parameters from models/1558M/model.ckpt
2020-05-10 14:19:43,794 - tensorflow - INFO - Restoring parameters from models/1558M/model.ckpt
==========
Before splitlines: Nothing special. Nothing exciting in particular. I just wanna chill out for a bit. You: I'll try to keep my spirits up. Just keep in mind that today's the 10th anniversary of the citywide strike
==========
==========
Mode: True
Learn: True
Length: 44
==========
Before regex: Nothing special. Nothing exciting in particular. I just wanna chill out for a bit. You: I'll try to keep my spirits up. Just keep in mind that today's the 10th anniversary of the citywide strike
==========
Output: Nothing special. Nothing exciting in particular. I just wanna chill out for a bit.
==========
Raw_text or Original: You: Hello! How are you today? Are you feeling alright? I hope you are doing well and not getting into any trouble. Me: Yeah, I'm fine. Do you want to make something to eat? You: I already made some food, but thanks! I had some jalapeno poppers. I made a ton of them last night after I sold a lawnmower to some folks I got for free earlier in the day. So what are your plans for the day? Me:
==========
Learning text or Next: You: Hello! How are you today? Are you feeling alright? I hope you are doing well and not getting into any trouble. Me: Yeah, I'm fine. Do you want to make something to eat? You: I already made some food, but thanks! I had some jalapeno poppers. I made a ton of them last night after I sold a lawnmower to some folks I got for free earlier in the day. So what are your plans for the day? Me: Nothing special. Nothing exciting in particular. I just wanna chill out for a bit.
==========
top_p out: 0.8338636363636364
==========
top_p in: 0.83
==========
有关语法分数的列表,请参阅/SCORES.MD。
提示:
0.77 top_p 听起来情绪化、困惑和模仿。
0.66 top_p 听起来是经过深思熟虑和字面意思的,但可能会出现 ascii 和截止错误。