상대적으로 채팅에 맞춰 조정된 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
저장소 복제 후 봇 폴더 내부에 요구 사항을 설치합니다.
python3.7 -m pip install -r requirements.txt
참고: 실제로는 16GB RAM 또는 8GB 비디오 카드가 필요합니다. 그렇지 않으면 영원히 기다리게 될 것입니다. cuda takelit 10.0 및 cuda 툴킷 10용 cudnn을 지원하는 최소 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
원하는 대로 Python 명령과 일치하도록 start.sh를 편집할 수 있습니다.
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 및 잘림 오류가 있을 수 있습니다.