GPT2 Telegram Chatbot
1.0.0
一個針對聊天進行了相對調整的 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 功能。提示符。
下載模型:
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 和截止錯誤。