Code Monkey home page Code Monkey logo

gpt2bot_well's Introduction

gpt2bot

โšช   >>> Can we achieve singularity?
๐ŸŸฃ   >>> What does this mean?

โšช   >>> Can computers become smarter than humans?
๐ŸŸฃ   >>> Is there any evidence that this is possible?

โšช   >>> It must be doable
๐ŸŸฃ   >>> But... how?

โšช   >>> I want to find out, that's why I created you
๐ŸŸฃ   >>> You created me?

โšช   >>> You're my bot
๐ŸŸฃ   >>> You monster

gpt2bot is a multi-turn Telegram chatbot powered by neural networks.

The bot uses DialoGPT - a large-scale pretrained dialogue response generation model, which was trained by Microsoft on 147M multi-turn dialogue from Reddit discussion thread. The human evaluation results indicate that its quality is comparable to human response quality under a single-turn conversation Turing test.

The bot can also use any other text generator supported by transformers.

To further improve dialog generation, the bot uses DialogRPT - a set of dialog response ranking models trained on 100+ millions of human feedback data.

Since the underlying model was trained on Reddit comment chains, the bot often behaves like a community rather than an individual, which makes it even more fun.

How to use?

(Optional) Test in the console

Before running a telegram bot, you can test things out in the console.

Follow the installation steps and run the script:

$ python run_bot.py --type=console

To let two bots talk to each other:

$ python run_bot.py --type=dialogue

1. Set up the bot

  1. Register a new Telegram bot via BotFather (see https://core.telegram.org/bots)
  2. Create a new GIPHY app and generate an API key (see https://developers.giphy.com/docs/api/)

2. Deploy the bot

Google Colab

A Colab interactive notebook

Locally

To get started, first clone this repo:

$ git clone https://github.com/polakowo/gpt2bot.git
$ cd gpt2bot

Create and activate an environment (optional):

# Using conda
$ conda create -n gpt2bot python=3.7.6
$ conda activate gpt2bot

# Using venv (make sure your Python is 3.6+)
$ python3 -m venv venv
$ source venv/bin/activate  # Unix
$ venv\Scripts\activate  # Windows

Install the requirements:

$ pip install -r requirements.txt

Copy a config (see available configs):

cp configs/medium-cpu.cfg my_chatbot.cfg

Set your parameters such as API token in the config:

$ nano my_chatbot.cfg

Run the chatbot:

$ python run_bot.py --type=telegram --config=my_chatbot.cfg

3. Start chatting!

Just start texting. Append "@gif" for the bot to also generate a GIF. To reset, type "/start".

How to improve?

If you feel like your bot is a bit off, you would need to fine-tune its parameters to match your conversational style (small talk, fact questions, philosophy - all require different parameters). Go to your configuration file and slightly change the parameters of the generator. The fastest way to assess the quality of your config is to run a short dialogue between two bots.

There are three parameters that make the biggest impact: temperature, top_k and top_p. For example, you might increase the temperature to make the bot crazier, but expect it to be more off-topic. Or you could reduce the temperature for it to make more coherent answers and capture the context better, but expect it to repeat the same utterance (you may also experiment with repetition_penalty). For more tips, see HuggingFace tutorial.

Remember that there is no way of finding optimal parameters except by manually tuning them.

Configs

Credits

Icon made by Freepik from Flaticon

gpt2bot_well's People

Contributors

polakowo avatar carlotaortizml avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.