blob: f10a28fdb6c88005089f47895133947a7e8a4182 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# ebooks
Fediverse ebooks bot using neural networks
## Usage
First, install Python dependencies with `pip install psycopg2 torch transformers datasets Mastodon.py`. Currently only Mastodon with PostgreSQL is supported, but it should be easy to add support for other platforms and databases.
Generate the training data from the Mastodon database using `python data.py -d 'dbname=test user=postgres password=secret'`. You can skip this step if you have training data from another source.
Next, train the network with `python train.py`, which may take several hours. It's a lot faster when using a GPU. If you need advanced features when training, you can also train using [run_clm.py](https://github.com/huggingface/transformers/blob/master/examples/pytorch/language-modeling/run_clm.py).
Finally, create a Mastodon application for your bot account and run the bot with `python bot.py -i mastodon.instance -t access_token -n 'Initial text'`. You can create a cron job to run this periodically. Enjoy!
## Resources
- https://closeheat.com/blog/pytorch-lstm-text-generation-tutorial
- https://trungtran.io/2019/02/08/text-generation-with-pytorch/
- https://huggingface.co/docs/transformers/training
- https://huggingface.co/blog/how-to-generate
- https://github.com/huggingface/transformers/tree/master/examples/pytorch/language-modeling
|