Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Easy-to-use scripts to fine-tune GPT-2-JA with your own texts, to generate sentences, and to tweet them automatically.

NotificationsYou must be signed in to change notification settings

discus0434/text-generation

Repository files navigation


Text Generator Powered by GPT-2-JA

Twitter Follow

Easy to use scripts to fine-tune GPT-2 Japanese model with your own text, to generate sentences, and to tweet them automatically.



✨ Now You can try with Google Colab!

Open In Colab


Installation

1. Clone this repository

git clone https://github.com/discus0434/text-generation.gitcd text-generation

2. Install dependencies

pip

pip install -r requirements.txt

conda

conda create -n textgen python=3.9echo"source activate textgen">~/.bashrcconda run -n textgen pip install -r requirements.txt

...or build docker image

docker build text-generation/. -t textgendocker run -it --runtime=nvidia -d --restart=always textgen:latest bash

3. Runsetup.sh (not necessary for docker users)

Modify permission of shell scripts

chmod +x scripts/shell/setup.shchmod +x scripts/shell/finetune.shchmod +x scripts/shell/generate.sh

Runsetup.sh to download a pretrained model

scripts/shell/setup.sh

4. Arrange Twitter API tokens (not necessary if you do not interact with Twitter)

Arrange.env file in the project directory..env file should look like this:

API_KEY = XXXAPI_SECRET_KEY = XXXBEARER_TOKEN = XXXACCESS_TOKEN = XXXACCESS_TOKEN_SECRET = XXX

Usage

You can not only make a Twitter bot but just generate sentences.

Preparation

Arrange your text file you want to use insample_texts/.

mv<your text file>.txt sample_texts/

...or download someone's tweets with Python script to use it

python ./scripts/python/download_tweets.py -u<Twitter user ID> -max<number of tweets you will get>

Usage 1: Just generate sentences

Fine-tuning

scripts/shell/finetune.sh

Generate 10 sentences with your fine-tuned model

scripts/shell/generate.sh

Usage 2: Manage a Twitter bot powered by fine-tuned GPT-2-JA

Fine-tuning and generate tweet


...Run all of cells increate_tweet.ipynb.

Fine-tuning and generate tweets per 30 min till interrupted

python ./scripts/python/create_tweets.py&disown

Acknowledgements

This code borrows fromgpt2-japanese.

About

Easy-to-use scripts to fine-tune GPT-2-JA with your own texts, to generate sentences, and to tweet them automatically.

Topics

Resources

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp