diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7f11624 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,36 @@ +name: Release + +on: + push: + tags: + - '*' + +permissions: + contents: write + +env: + ZIP_NAME: jan-models-bggpt-${{ github.ref_name }}.zip + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Generate models + working-directory: utils/model-generator + run: | + pip install -r requirements.txt + python main.py + + # Create a .zip file of the models directory without the parent directory + - name: Create .zip file + working-directory: models + run: | + zip -r ../${{ env.ZIP_NAME }} . + + - name: Release + uses: softprops/action-gh-release@v1 + with: + files: ${{ env.ZIP_NAME }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cbd44c9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.gguf +models diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..687be82 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Ivaylo Stoyanov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..ba01987 --- /dev/null +++ b/README.md @@ -0,0 +1,53 @@ +# BgGPT for Jan πŸ‘‹ +[![Release](https://github.com/ivkos/jan-models-bggpt/actions/workflows/release.yml/badge.svg)](https://github.com/ivkos/jan-models-bggpt/actions/workflows/release.yml) + +πŸ€πŸ’šβ€οΈ + +Π’ΠΎΠ²Π° Ρ€Π΅ΠΏΠΎ прСдоставя JSON описания Π½Π° Π±ΡŠΠ»Π³Π°Ρ€ΡΠΊΠΈΡ‚Π΅ Π΅Π·ΠΈΠΊΠΎΠ²ΠΈ ΠΌΠΎΠ΄Π΅Π»ΠΈ [**BgGPT**](https://bggpt.ai), +подходящи Π·Π° инсталиранС Π² Ρ‡Π°Ρ‚Π±ΠΎΡ‚Π° [**Jan**](https://jan.ai). + +[**Jan**](https://jan.ai) Π΅ Π°Π»Ρ‚Π΅Ρ€Π½Π°Ρ‚ΠΈΠ²Π° Π½Π° ChatGPT, която ΠΌΠΎΠΆΠ΅ Π΄Π° сС ΠΈΠ·ΠΏΠΎΠ»Π·Π²Π° +Π»ΠΎΠΊΠ°Π»Π½ΠΎ ΠΈ Π½Π΅ изисква ΠΈΠ½Ρ‚Π΅Ρ€Π½Π΅Ρ‚ Π²Ρ€ΡŠΠ·ΠΊΠ° слСд свалянС Π½Π° Π΅Π·ΠΈΠΊΠΎΠ²ΠΈΡ‚Π΅ ΠΌΠΎΠ΄Π΅Π»ΠΈ. + + +πŸ“₯ Π’ [Ρ€Π΅Π»ΠΈΠΉΠ·ΠΈΡ‚Π΅](../../releases) Π½Π° Ρ‚ΠΎΠ²Π° Ρ€Π΅ΠΏΠΎ Ρ‰Π΅ Π½Π°ΠΌΠ΅Ρ€ΠΈΡ‚Π΅ .zip Ρ„Π°ΠΉΠ»ΠΎΠ²Π΅, ΠΊΠΎΠΈΡ‚ΠΎ +ΡΡŠΠ΄ΡŠΡ€ΠΆΠ°Ρ‚ JSON описания Π½Π° ΠΌΠΎΠ΄Π΅Π»ΠΈΡ‚Π΅. + + +## Как Π΄Π° ΠΈΠ·ΠΏΠΎΠ»Π·Π²Π°ΠΌ Ρ‚Π΅Π·ΠΈ ΠΌΠΎΠ΄Π΅Π»ΠΈ Π² Jan? +1. Π˜Π½ΡΡ‚Π°Π»ΠΈΡ€Π°ΠΉΡ‚Π΅ [Jan](https://jan.ai) Π½Π° ΠΊΠΎΠΌΠΏΡŽΡ‚ΡŠΡ€Π° си, Π°ΠΊΠΎ Π²Π΅Ρ‡Π΅ Π½Π΅ стС Π³ΠΎ Π½Π°ΠΏΡ€Π°Π²ΠΈΠ»ΠΈ. +2. ΠžΡ‚ [послСдния Ρ€Π΅Π»ΠΈΠΉΠ·](../../releases/latest) Π½Π° Ρ‚ΠΎΠ²Π° Ρ€Π΅ΠΏΠΎ ΠΈΠ·Ρ‚Π΅Π³Π»Π΅Ρ‚Π΅ .zip Ρ„Π°ΠΉΠ»Π°. +3. Π Π°Π·Π°Ρ€Ρ…ΠΈΠ²ΠΈΡ€Π°ΠΉΡ‚Π΅ ΡΡŠΠ΄ΡŠΡ€ΠΆΠ°Π½ΠΈΠ΅Ρ‚ΠΎ Π½Π° .zip Ρ„Π°ΠΉΠ»Π° Π² дирСкторията Π½Π° Jan: + - Linux ΠΈ macOS: `~/jan/models` + - Windows: `C:\Users\\jan\models` +4. РСстартирайтС Jan, Π°ΠΊΠΎ Π² ΠΌΠΎΠΌΠ΅Π½Ρ‚Π° Π΅ стартиран. +5. ΠžΡ‚ ΠΌΠ΅Π½ΡŽΡ‚ΠΎ **Hub** Π² Jan Π½Π°ΠΌΠ΅Ρ€Π΅Ρ‚Π΅ ΠΈ ΠΈΠ·Ρ‚Π΅Π³Π»Π΅Ρ‚Π΅ избрания ΠΌΠΎΠ΄Π΅Π». + +## Кой ΠΌΠΎΠ΄Π΅Π» Π΄Π° ΠΈΠ·Π±Π΅Ρ€Π°? +BgGPT ΠΈΠ΄Π²Π° Π² няколко Ρ€Π°Π·Π»ΠΈΡ‡Π½ΠΈ ΠΊΠ²Π°Π½Ρ‚ΡƒΠ²Π°Π½ΠΈ Ρ€Π°Π·ΠΌΠ΅Ρ€Π°. МоТС Π΄Π° ΠΈΠ·Π±Π΅Ρ€Π΅Ρ‚Π΅ ΠΌΠΎΠ΄Π΅Π», ΠΊΠΎΠΉΡ‚ΠΎ +Π΄Π° отговаря Π½Π° Π²Π°ΡˆΠΈΡ‚Π΅ Π½ΡƒΠΆΠ΄ΠΈ, ΠΊΠ°Ρ‚ΠΎ Π²Π·Π΅ΠΌΠ΅Ρ‚Π΅ ΠΏΡ€Π΅Π΄Π²ΠΈΠ΄ Ρ€Π°Π·ΠΌΠ΅Ρ€Π° Π½Π° диска ΠΈ +изискванСто Π·Π° VRAM. + +ℹ️ По-ΠΌΠ°Π»ΠΊΠΈΡ‚Π΅ ΠΌΠΎΠ΄Π΅Π»ΠΈ Π² ΠΏΠΎΠ²Π΅Ρ‡Π΅Ρ‚ΠΎ случаи са ΠΏΠΎ-Π±ΡŠΡ€Π·ΠΈ ΠΏΡ€ΠΈ ΠΏΠΎ-ΠΌΠ°Π»ΠΊΠΎ +Π½Π°Π»ΠΈΡ‡Π½Π° VRAM, Π½ΠΎ Π³Π΅Π½Π΅Ρ€ΠΈΡ€Π°Ρ‚ ΠΏΠΎ-нСкачСствСни Ρ€Π΅Π·ΡƒΠ»Ρ‚Π°Ρ‚ΠΈ. + + +| МодСл | Π Π°Π·ΠΌΠ΅Ρ€ Π²ΡŠΡ€Ρ…Ρƒ диска | ИзискванС Π·Π° VRAM | +| --- | --- | --- | +| `Q4_K_S` | 4.17 GB | 5.21 GB | +| `Q4_K_M` ✨ | 4.40 GB | 5.50 GB | +| `Q5_K_S` ✨ | 5.03 GB | 6.29 GB | +| `Q5_K_M` ✨ | 5.17 GB | 6.46 GB | +| `Q6_K` | 5.98 GB | 7.48 GB | +| `Q8_0` | 7.75 GB | 9.69 GB | +| `F16` | 14.6 GB | 18.25 GB | + + +> ✨ ΠŸΡ€Π΅ΠΏΠΎΡ€ΡŠΡ‡Π°Π½ΠΈ ΠΌΠΎΠ΄Π΅Π»ΠΈ, Π±Π°Π·ΠΈΡ€Π°Π½ΠΈ Π½Π° [Ρ‚Π°Π·ΠΈ дискусия Π² llama.cpp]( + https://github.com/ggerganov/llama.cpp/discussions/2094 +). +> VRAM = 1.25 * Disk + +## Π’Ρ€ΡŠΠ·ΠΊΠΈ +- [INSAIT @ Hugging Face](https://huggingface.co/INSAIT-Institute) +- [Jan @ GitHub](https://github.com/janhq/jan) diff --git a/utils/model-generator/main.py b/utils/model-generator/main.py new file mode 100644 index 0000000..acaf78f --- /dev/null +++ b/utils/model-generator/main.py @@ -0,0 +1,47 @@ +import json +import os + +import requests + +THIS_DIR = os.path.dirname(__file__) +REPO_ROOT = os.path.join(THIS_DIR, "..", "..") +MODELS_DIR = os.path.join(REPO_ROOT, "models") + + +def main(): + files = [] + + with open(os.path.join(THIS_DIR, "models_list.json"), "r") as fd: + models_list = json.load(fd) + + for model_object in models_list: + repo = model_object["repo"] + gguf_files = model_object["gguf_files"] + + for filename in gguf_files: + file_url = f"{repo}/resolve/main/{filename}" + + head_resp = requests.head(file_url, allow_redirects=True) + files.append((file_url, filename, head_resp.headers["Content-Length"])) + + with open(os.path.join(os.path.dirname(__file__), "model.template.json"), "r") as template: + template_content = template.read() + + for file_url, filename, size in files: + filename_no_ext = os.path.splitext(filename)[0] + filled_template = template_content \ + .replace("<>", filename) \ + .replace("<>", filename_no_ext) \ + .replace("<>", file_url) \ + .replace("<>", size) + + os.makedirs(os.path.join( + MODELS_DIR, filename_no_ext + ), exist_ok=True) + + with open(os.path.join(MODELS_DIR, filename_no_ext, "model.json"), "w", newline="\n") as model: + model.write(filled_template) + + +if __name__ == "__main__": + main() diff --git a/utils/model-generator/model.template.json b/utils/model-generator/model.template.json new file mode 100644 index 0000000..266cd08 --- /dev/null +++ b/utils/model-generator/model.template.json @@ -0,0 +1,36 @@ +{ + "sources": [ + { + "filename": "<>", + "url": "<>" + } + ], + "id": "<>", + "object": "model", + "name": "<>", + "version": "0.1", + "description": "Bulgarian language model", + "format": "gguf", + "settings": { + "ctx_len": 4096, + "prompt_template": "[INST] {prompt} [/INST]", + "llama_model_path": "<>" + }, + "parameters": { + "temperature": 0.7, + "top_p": 0.95, + "stream": true, + "max_tokens": 4096, + "stop": [], + "frequency_penalty": 0, + "presence_penalty": 0 + }, + "metadata": { + "author": "BgGPT", + "tags": [ + "7B" + ], + "size": <> + }, + "engine": "nitro" +} diff --git a/utils/model-generator/models_list.json b/utils/model-generator/models_list.json new file mode 100644 index 0000000..657f19a --- /dev/null +++ b/utils/model-generator/models_list.json @@ -0,0 +1,26 @@ +[ + { + "repo": "https://huggingface.co/INSAIT-Institute/BgGPT-7B-Instruct-v0.1-GGUF", + "gguf_files": [ + "BgGPT-7B-Instruct-v0.1.F16.gguf", + "BgGPT-7B-Instruct-v0.1.Q4_K_M.gguf", + "BgGPT-7B-Instruct-v0.1.Q4_K_S.gguf", + "BgGPT-7B-Instruct-v0.1.Q5_K_M.gguf", + "BgGPT-7B-Instruct-v0.1.Q5_K_S.gguf", + "BgGPT-7B-Instruct-v0.1.Q6_K.gguf", + "BgGPT-7B-Instruct-v0.1.Q8_0.gguf" + ] + }, + { + "repo": "https://huggingface.co/INSAIT-Institute/BgGPT-7B-Instruct-v0.2-GGUF", + "gguf_files": [ + "BgGPT-7B-Instruct-v0.2.F16.gguf", + "BgGPT-7B-Instruct-v0.2.Q4_K_M.gguf", + "BgGPT-7B-Instruct-v0.2.Q4_K_S.gguf", + "BgGPT-7B-Instruct-v0.2.Q5_K_M.gguf", + "BgGPT-7B-Instruct-v0.2.Q5_K_S.gguf", + "BgGPT-7B-Instruct-v0.2.Q6_K.gguf", + "BgGPT-7B-Instruct-v0.2.Q8_0.gguf" + ] + } +] diff --git a/utils/model-generator/requirements.txt b/utils/model-generator/requirements.txt new file mode 100644 index 0000000..2c24336 --- /dev/null +++ b/utils/model-generator/requirements.txt @@ -0,0 +1 @@ +requests==2.31.0