This Python script is designed to create interactive text-based stories in a Telegram chat using the Karpathy's tinyllamas model. Users can initiate a story by sending a message in the format "There once was a...". The bot generates and continues the story based on the user's input.
Before running this code, make sure you have the following prerequisites in place:
-
Python installed on your system (Python 3.6 or later).
-
The required Python packages can be installed using
pip
:pip install python-telegram-bot
-
You need a Telegram Bot API key. You can obtain one by talking to BotFather.
-
Clone the repository and navigate to the project folder:
git clone https://github.com/karpathy/llama2.c.git cd llama2.c
-
Build and run the project using
make
:make runfast
-
Download the stories42M model for generating text. You can change the
download_url
variable to a different model if needed. By default, it points to a model provided by Hugging Face:download_url = "https://huggingface.co/karpathy/tinyllamas/resolve/main/stories42M.bin" wget $download_url
Before running the script, make sure to replace "xxxxxxxxxxxxxxxxxxxxxxxx"
in the API_KEY
variable with your Telegram Bot API key that you obtained from BotFather.
To start the bot, simply run the script:
python your_script_name.py
Once the bot is running, you can interact with it on Telegram. Start a conversation with your bot, and you can use the /start
and /help
commands to get instructions on how to initiate a story and some helpful guidance.
This project is licensed under the MIT License - see the LICENSE file for details.
- This code is based on an example from karpathy's repository.
- It uses the python-telegram-bot library to interact with Telegram.
Feel free to customize and modify this code to meet your specific requirements. Happy storytelling!
>python train.py --compile=False