{"id":26134328,"url":"https://github.com/estnafinema0/russian-jokes-generator","last_synced_at":"2026-04-19T22:02:01.936Z","repository":{"id":281733941,"uuid":"946246317","full_name":"estnafinema0/russian-jokes-generator","owner":"estnafinema0","description":"Transformer Models for Humorous Text Generation. Fine-tuned on Russian jokes dataset with ALiBi, RoPE, GQA, and SwiGLU.Plus a custom Byte-level BPE tokenizer.","archived":false,"fork":false,"pushed_at":"2025-03-10T21:07:02.000Z","size":301,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-10T22:19:27.767Z","etag":null,"topics":["alibi","bpe-tokenizer","grouped-query-attention","nlp","pytorch","rotary-position-embedding","swiglu","transformer-models"],"latest_commit_sha":null,"homepage":"https://huggingface.co/estnafinema0/russian-jokes-generator","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/estnafinema0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-10T20:57:31.000Z","updated_at":"2025-03-10T21:16:20.000Z","dependencies_parsed_at":"2025-03-10T22:19:31.564Z","dependency_job_id":"8da458ff-81ed-4fa2-a8ee-6e4fe62ffdba","html_url":"https://github.com/estnafinema0/russian-jokes-generator","commit_stats":null,"previous_names":["estnafinema0/russian-jokes-generator"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/estnafinema0/russian-jokes-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/estnafinema0%2Frussian-jokes-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/estnafinema0%2Frussian-jokes-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/estnafinema0%2Frussian-jokes-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/estnafinema0%2Frussian-jokes-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/estnafinema0","download_url":"https://codeload.github.com/estnafinema0/russian-jokes-generator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/estnafinema0%2Frussian-jokes-generator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32024251,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"online","status_checked_at":"2026-04-19T02:00:07.110Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alibi","bpe-tokenizer","grouped-query-attention","nlp","pytorch","rotary-position-embedding","swiglu","transformer-models"],"created_at":"2025-03-11T00:00:02.205Z","updated_at":"2026-04-19T22:02:01.918Z","avatar_url":"https://github.com/estnafinema0.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Russian Jokes Generator\n\nThis repository contains a set of Transformer-based language models fine-tuned on a dataset of Russian jokes (anecdotes). The models are designed to generate humorous and coherent Russian text. The repository includes three versions of the model: `nano`, `mini`, and `small`, each with different architectures and training configurations. Additionally, a custom Byte-level BPE tokenizer, trained on the Russian jokes dataset, is provided.\n\n## Table of Contents\n\n- [Model Details](#model-details)\n  - [Architecture](#architecture)\n  - [Training Details](#training-details)\n  - [Performance](#performance)\n- [Usage](#usage)\n  - [Loading the Model](#loading-the-model)\n  - [Generating Text](#generating-text)\n- [Examples](#examples)\n- [Repository Structure](#repository-structure)\n- [Jupyter Notebook](#jupyter-notebook)\n- [License](#license)\n\n## Model Details\n\n### Architecture\n\nThe models are based on the Transformer architecture, enhanced with several advanced techniques:\n\n1. Positional Embeddings: ALiBi (Attention with Linear Biases) and RoPE (Rotary Positional Embeddings) are used for positional encoding.\n2. Attention Mechanism: Grouped-Query Attention (GQA) and Multi-Head Latent Attention (MHLA) are employed to improve efficiency and performance.\n3. Activation Function: SwiGLU activation is used in the feed-forward layers.\n\nThree versions of the model are available:\n\n- **Nano**: 3 layers, 4 heads, 96 hidden dimensions.\n- **Mini**: 6 layers, 6 heads, 384 hidden dimensions. Trained with RoPE and MHLA.\n- **Small**: 12 layers, 12 heads, 768 hidden dimensions. Trained with RoPE and MHLA.\n\n### Training Details\n\nThe models were trained on the [IgorVolochay/russian_jokes](https://huggingface.co/datasets/IgorVolochay/russian_jokes) dataset. \n\nKey training parameters include:\n1. Epochs: The number of full iterations over the dataset was determined by the `n_step` parameter in the Trainer initialization. The models were trained for 1 epoch (nano), 1 epoch (mini), and 6 epochs (small).\n2. Batch Size: 32 for nano and mini models, 64 for the small model.\n3. Learning Rate: 5e-4 with cosine decay for the small model, 3e-4 for the nano and mini models.\n4. Loss Function: Cross-entropy loss was used for training.\n5. Hardware: Training was conducted on an NVIDIA A100 GPU via Google Colab.\n\n### Performance\n\nThe performance of each model is summarized below:\n\n| Model | Training Loss (min) | Validation Loss (min) |\n|-------|---------------------:|------------------------:|\n| Nano  | 3.784              | 3.932                  |\n| Mini  | 3.127              | 3.144                  |\n| Small | 2.933              | 3.025                  |\n\nTraining and validation loss curves for each model are provided below:\n\n#### Nano Model\n![Nano Training Loss](https://cdn-uploads.huggingface.co/production/uploads/67c40beb3a3d19149b5bdfbf/LSx0VS3BnNYt3Lokh7jsQ.png)\n\n#### Mini Model\n![Mini Training Loss](https://cdn-uploads.huggingface.co/production/uploads/67c40beb3a3d19149b5bdfbf/g20QvPA9RpQR_rGc3RYXK.png)\n\n#### Small Model\n![Small Training Loss](https://cdn-uploads.huggingface.co/production/uploads/67c40beb3a3d19149b5bdfbf/tylbErxZYhKUOgv-YfNjH.png)\n\n## Usage\n\n### Loading the Model\n\nYou can load the models and tokenizer from the Hugging Face Hub using the following code:\n\n```python\n# Small model\nmodel_small = TransformerForCausalLM.from_pretrained(\"estnafinema0/russian-jokes-generator\", revision=\"small\")\ntokenizer = ByteLevelBPETokenizer.from_pretrained(\"estnafinema0/russian-jokes-generator\")\n```\n\n### Generating Text\n\nTo generate text using the model, you can use the following code:\n\n```python\ntext = \"Штирлиц пришел домой\"\ninput_ids = torch.tensor(tokenizer.encode(text), device=device)\nmodel_output = model_small.generate(\n    input_ids[None, :], max_new_tokens=200, eos_token_id=tokenizer.eos_token_id, do_sample=True, top_k=10\n)\nprint(tokenizer.decode(model_output[0].tolist()))\n```\n\n## Examples\n\nHere are some examples of jokes generated by the `small` model:\n\n1. **Input**: \"Пришел Петя в баню и говорит\"\n   **Output**: \"Пришел Петя в баню и говорит - Василий Иванович, вы знаете, кто я - Петя, или Петя? - Ахааха, и я - Ахаилая, я - Ахаил! - А какая Петя? - Я - Ахаилая! - Ну и я, когда я банкрот, банкротство, конечно...\"\n\n2. **Input**: \"Вышел как-то на крыльцо\"\n   **Output**: \"Вышел как-то на крыльцо, а там плачет. Стукнулся: упал, выпал. Плачет – упал.\"\n\n3. **Input**: \"Священник задает ребёнку вопрос\"\n   **Output**: \"Священник задает ребёнку вопрос ему на ухо:- Что, братан, опять несёл?- Братан, ты что, братан, охуел?\"\n\n## Repository Structure\n\nThe repository is organized as follows:\n\n- **Models**: Three versions of the model (`nano`, `mini`, `small`) are available in different branches:\n  - `main`: Nano model.\n  - `mini`: Mini model.\n  - `small`: Small model.\n- **Tokenizer**: A custom Byte-level BPE tokenizer trained on the Russian jokes dataset.\n- **Jupyter Notebook**: A detailed notebook containing the implementation, training, and evaluation of the models.\n\n## Jupyter Notebook\n\nThe repository includes a Jupyter Notebook (`russian_jokes_generator.ipynb`) that provides a step-by-step guide to:\n\n- Training the tokenizer.\n- Implementing and training the Transformer models.\n- Evaluating the models and generating text.\n\nYou can find the notebook in the repository and run it locally or in Google Colab.\n\nP.S. Now the notebook is released in russian.\n\n## License\n\nThis project is licensed under the Apache 2.0 License. See the [LICENSE](https://www.apache.org/licenses/LICENSE-2.0.txt) file for more details.\n\n---\nThank you for your time!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Festnafinema0%2Frussian-jokes-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Festnafinema0%2Frussian-jokes-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Festnafinema0%2Frussian-jokes-generator/lists"}