This project is part of the compulsory course Programming for Linguists in National Research University Higher School of Economics. It is a joke generator, that is a special case of text generation.
Input: a collection of jokes.
Output: generated text based on the input collection.
The program is trained on two models, which are based on the same architecture — RuGPT3. Before starting generation it is possible to select a model, a topic of jokes (if it is a ‘Наша’ model) and the length of the generated text. Besides, you need to enter a prompt for a joke and the program will continue the text.
Team-lead / NLP-engineer: Polina Savinova
Logic and Interface developer: Egor Zharikov
QA / Tech Writer: Vita Zaytseva
Product Manager: Evgenia Pareshina
To install the program you need to open Git on your computer and write the command:
git clone https://github.com/posavinova/russian_jokes_generator.git
The generator consists of the following folders:
-
models_configTwo models are stored here. Both are based on the same architecture — RuGPT3. The difference between them is fine-tuning on different datasets. Our model was fine-tuned on a collection of texts from humornet.ru. As for the other model, we are giving credits to Neural Shit.
-
spiderHere you can find scraper for collecting dataset from the site humornet.ru
-
srcIt is the folder where the GUI, the model request and the saving the history of jokes are stored.
-
testsHere you can find unit tests on models.
| Module | Description | Component |
|---|---|---|
pathlib |
module for working with file paths | |
pylint |
module for code analyser | |
gdown |
module for downloading big files from Google Drive | models |
torch |
module for machine learning | models |
transformers |
module for downloading and training models | models |
BeautifulSoup4 |
module for finding information on web pages | scraper |
pandas |
module for working with tabular data | scraper |
requests |
module for downloading web pages | scraper |
tqdm |
module for tracking progress | scraper |
Before starting check that you have installed all the required modules. If not, open the console and write the command:
pip install -r requirements.txt
Now you are ready to start!
To run the generator you need to open the file main.py in the folder src and run the method:
if __name__ == '__main__':
app = Application()
app.runWhen you start the generator, the Joke Generator front-end application will open.
At the bottom you can see 2 drop-down lists: model and length.
You can choose "Чужая" or "Наша" model. If you select "Наша" model, you can select a tag or, in other words,
a topic of the future generated joke. There are 10 themes to choose from:
- Food
- Politics
- Cats
- Vulgar
- Job
- Computers
- Children
- Stirlitz
- Students
- Neighbours
Besides, you can choose the length of the generated joke from 30 to 100 characters.
Above the drop-down lists there is a field where you can write the prompt for a joke. To the right of this field there is a button "Отправить". After clicking on it or pressing Enter, in the window above you can see your prompt and after a while the generated anecdote itself.
To get the generated joke, you need to enter a prompt for a joke in the field, select all categories and click on "Отправить" or press Enter. Then your prompt and the generated joke will appear.
Our program has an automatic function of saving jokes locally.
When you run the generator for the first time, the file jokes_history.txt is created,
where you can see all the generated jokes.