ChatterBot README

The project's README from github.com/gunthercox/ChatterBot. As one markdown file: README.md.

ChatterBot: Machine learning in Python

ChatterBot

ChatterBot is a machine-learning based conversational dialog engine built in Python which makes it possible to generate responses based on collections of known conversations. The language independent design of ChatterBot allows it to be trained to speak any language.

Package Version Python 3.12 Coverage Status Follow on Bluesky Join the chat at https://gitter.im/chatterbot/Lobby

An example of typical input would be something like this:

user: Good morning! How are you doing?
bot: I am doing very well, thank you for asking.
user: You're welcome.
bot: Do you like hats?

How it works

An untrained instance of ChatterBot starts off with no knowledge of how to communicate. Each time a user enters a statement, the library saves the text that they entered and the text that the statement was in response to. As ChatterBot receives more input the number of responses that it can reply to, and the accuracy of each response in relation to the input statement increases. The program selects the closest matching response by searching for the closest matching known statement that matches the input, it then returns the most likely response to that statement based on how frequently each response is issued by the people the bot communicates with.

Documentation

View the documentation for ChatterBot.

Installation

This package can be installed from PyPi by running:

pip install chatterbot

Basic Usage

from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer

chatbot = ChatBot('Ron Obvious')

# Create a new trainer for the chatbot
trainer = ChatterBotCorpusTrainer(chatbot)

# Train the chatbot based on the english corpus
trainer.train("chatterbot.corpus.english")

# Get a response to an input statement
chatbot.get_response("Hello, how are you today?")

Training data

ChatterBot comes with a data utility module that can be used to train chat bots. At the moment there is training data for over a dozen languages in this module. Contributions of additional training data or training data in other languages would be greatly appreciated. Take a look at the data files in the chatterbot-corpus package if you are interested in contributing.

from chatterbot.trainers import ChatterBotCorpusTrainer

# Create a new trainer for the chatbot
trainer = ChatterBotCorpusTrainer(chatbot)

# Train based on the english corpus
trainer.train("chatterbot.corpus.english")

# Train based on english greetings corpus
trainer.train("chatterbot.corpus.english.greetings")

# Train based on the english conversations corpus
trainer.train("chatterbot.corpus.english.conversations")

Corpus contributions are welcome! Please make a pull request.

Examples

For examples, see the examples section of the documentation.

History

See release notes for changes https://github.com/gunthercox/ChatterBot/releases

Contributing

Contributions are welcomed, to help ensure a smooth process please start with the contributing guidelines in our documentation: https://docs.chatterbot.us/contributing/

Sponsors

ChatterBot is sponsored by:

License

ChatterBot is licensed under the BSD 3-clause license.

ChatterBot (gunthercox/ChatterBot)

Searching Database…

Что это такое?ChatterBot — это диалоговый движок на машинном обучении для Python: он генерирует ответы чат-бота на основе коллекций известных диалогов, и его можно обучить говорить на любом языке.
То есть это библиотека для Python, на которой я строю своё, или готовый чат-бот, который можно просто запустить?Это библиотека: вы устанавливаете пакет и создаёте бота внутри своего кода на Python — отдельного приложения для запуска нет.
Как добавить его в проект?Установите пакет с PyPI через pip (pip install chatterbot), затем импортируйте его в своём коде на Python; в документации есть раздел Basic Usage, с которого можно начать.
Нужно ли что-то ещё, кроме Python, чтобы всё заработало?Нужна только среда Python: пакет ставится с PyPI, а pip сам подтянет его зависимости.
Можно пользоваться им сразу после установки или сначала нужно обучение?Сначала обучение: новый экземпляр изначально не знает, как вести беседу. Он учится по ходу общения с пользователями, а стартовать можно на встроенных обучающих данных.
Как он выбирает ответ на то, что я сказал?Он находит среди известных утверждений то, что ближе всего совпадает с вашим вводом, а затем возвращает самый вероятный ответ на него — исходя из того, как часто люди давали именно такой ответ.
Он становится лучше, чем больше людей с ним общаются?Да. Каждое утверждение пользователя сохраняется вместе с тем, ответом на что оно было, поэтому набор возможных ответов и их точность растут с каждым разговором.
Можно обучить его на языках, кроме английского?Да — архитектура не привязана к конкретному языку, а в составе модуля утилит для данных есть обучающие данные более чем для десяти языков; пополнение корпуса приветствуется.
What are similar projects?rasa, ParlAI, flair, botpress, awesome-nlp, spaCy, Hy-MT2, bert
Creator
gunthercox
Size
8.2 MB
Stars
14.5K
Age
12y
Commits · 90 Days