Skip to content

Commit

Permalink
Merge pull request #18 from LyaaaaaGames/Develop
Browse files Browse the repository at this point in the history
Release 1.2.2
  • Loading branch information
Lyaaaaaaaaaaaaaaa authored Apr 2, 2023
2 parents b840a5d + 81ea151 commit d7042be
Show file tree
Hide file tree
Showing 15 changed files with 59 additions and 42 deletions.
9 changes: 4 additions & 5 deletions conda_config.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
name: aidventure
channels:
- defaults
- conda-forge
- pytorch
dependencies:
- pip
- python=3.9.7
- pytorch=1.12
- websockets=10.0
- transformers=4.21
- pytorch
- websockets=10.4
- transformers=4.27
- sentencepiece
- accelerate=0.12.0
- accelerate
11 changes: 5 additions & 6 deletions conda_config_cuda.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
name: aidventure
channels:
- defaults
- conda-forge
- pytorch
dependencies:
- pip
- python=3.9.7
- pytorch=1.12
- websockets=10.0
- transformers=4.21
- pytorch
- websockets=10.4
- transformers=4.27
- sentencepiece
- accelerate=0.12.0
- torchvision=0.12
- accelerate
- torchvision
- cudatoolkit
9 changes: 6 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#---------------------------------------------------------------------------
#-- Copyright (c) 2021-2022 LyaaaaaGames
#-- Copyright (c) 2022 AIdventure_Server contributors
#-- Copyright (c) 2021-present LyaaaaaGames
#-- Copyright (c) 2022-present AIdventure_Server contributors
#--
#-- author : Lyaaaaa
#--
Expand All @@ -23,9 +23,12 @@
#--
#-- 22/05/2022 Lyaaaaa
#-- - Uncommented "download_conda" and "install_conda" as it breaks the installer. Oups...
#--
#-- 01/04/2023 Lyaaaaa
#-- - Updated the miniconda link to use the newest version : 23.1.0-1.
#---------------------------------------------------------------------------

mini_conda_link="https://repo.anaconda.com/miniconda/Miniconda3-py39_4.10.3-Linux-x86_64.sh"
mini_conda_link="https://repo.anaconda.com/miniconda/Miniconda3-py39_23.1.0-1-Linux-x86_64.sh"
cache_folder="cache"
environment_prefix="server/miniconda/"
conda_environment_file="conda_config"
Expand Down
4 changes: 2 additions & 2 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#---------------------------------------------------------------------------
#-- Copyright (c) 2021-2022 LyaaaaaGames
#-- Copyright (c) 2022 AIdventure_Server contributors
#-- Copyright (c) 2021-present LyaaaaaGames
#-- Copyright (c) 2022-present AIdventure_Server contributors
#--
#-- author : Lyaaaaa
#--
Expand Down
9 changes: 6 additions & 3 deletions server/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#---------------------------------------------------------------------------
#-- Copyright (c) 2021-2022 LyaaaaaGames
#-- Copyright (c) 2022 AIdventure_Server contributors
#-- Copyright (c) 2021-present LyaaaaaGames
#-- Copyright (c) 2022-present AIdventure_Server contributors
#--
#-- author : Lyaaaaa
#--
Expand All @@ -26,6 +26,9 @@
#-- 21/05/2022 Lyaaaaa
#-- - Set LOG_FILEMODE default value to 'w'
#-- - Set LOG_LEVEL default value to DEBUG (Experimental branch only)
#--
#-- 09/11/2022 Lyaaaaa
#-- - Set LOG_LEVEL default value back to INFO
#---------------------------------------------------------------------------

import logging
Expand All @@ -37,4 +40,4 @@
# Logs
LOG_FILENAME = "server_logs.text"
LOG_FILEMODE = "w"
LOG_LEVEL = logging.DEBUG
LOG_LEVEL = logging.INFO
4 changes: 2 additions & 2 deletions server/downloader.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
#-- Copyright (c) 2021-2022 LyaaaaaGames
#-- Copyright (c) 2022 AIdventure_Server contributors
#-- Copyright (c) 2021-present LyaaaaaGames
#-- Copyright (c) 2022-present AIdventure_Server contributors
#--
#-- Author : Lyaaaaaaaaaaaaaaa
#--
Expand Down
18 changes: 13 additions & 5 deletions server/generator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
#-- Copyright (c) 2021-2022 LyaaaaaGames
#-- Copyright (c) 2022 AIdventure_Server contributors
#-- Copyright (c) 2021-present LyaaaaaGames
#-- Copyright (c) 2022-present AIdventure_Server contributors
#--
#-- Author : Lyaaaaaaaaaaaaaaa
#--
Expand All @@ -17,9 +17,18 @@
#-- - 22/05/2022 Lyaaaaa
#-- - Updated generate_text to support the gpu once again. Simplified the
#-- script by merging all the models input into a single dict "model_input".
#--
#-- - 01/03/2022 Lyaaaaa
#-- - Added GenerationConfig import from transformers.
#-- - Because max_length has been replaced by max_new_tokens, it is no more
#-- needed to have max_length = max_length + model_input's length.
#-- - p_parameters aren't sent into generate() anymore. They are now given
#-- to a GenerationConfig object which is an attribute (generation_config)
#-- of the Model. generate() automatically uses these config.
#------------------------------------------------------------------------------

from model import Model
from transformers import GenerationConfig

class Generator(Model):

Expand All @@ -38,10 +47,9 @@ def generate_text(self,
if self.is_gpu_enabled:
model_input.to("cuda")

p_parameters["max_length"] += len(model_input[0])
self._Model.generation_config = GenerationConfig(**p_parameters)

model_output = self._Model.generate(**model_input,
**p_parameters)
model_output = self._Model.generate(**model_input)
generated_text = self._Tokenizer.decode(model_output[0], skip_special_tokens=True)

return generated_text
4 changes: 2 additions & 2 deletions server/json_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
#-- Copyright (c) 2021-2022 LyaaaaaGames
#-- Copyright (c) 2022 AIdventure_Server contributors
#-- Copyright (c) 2021-present LyaaaaaGames
#-- Copyright (c) 2022-present AIdventure_Server contributors
#--
#-- Author : Lyaaaaaaaaaaaaaaa
#--
Expand Down
4 changes: 2 additions & 2 deletions server/logger.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#---------------------------------------------------------------------------
#-- Copyright (c) 2021-2022 LyaaaaaGames
#-- Copyright (c) 2022 AIdventure_Server contributors
#-- Copyright (c) 2021-present LyaaaaaGames
#-- Copyright (c) 2022-present AIdventure_Server contributors
#--
#-- author : Lyaaaaa
#--
Expand Down
9 changes: 7 additions & 2 deletions server/model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
#-- Copyright (c) 2021-2022 LyaaaaaGames
#-- Copyright (c) 2022 AIdventure_Server contributors
#-- Copyright (c) 2021-present LyaaaaaGames
#-- Copyright (c) 2022-present AIdventure_Server contributors
#--
#-- Author : Lyaaaaaaaaaaaaaaa
#--
Expand Down Expand Up @@ -114,6 +114,9 @@
#-- - Extracted a log print from _enable_gpu to _disable_gpu
#-- - Updated _empty_gpu_cache to torch.no_grad() otherwise the memory stays
#-- in use. Even with this solution a few hundreds of MB stays in use...
#--
#-- - 01/04/2023 Lyaaaaa
#-- - Updated __init__ to declare attribute generation_config.
#------------------------------------------------------------------------------

from transformers import AutoModelForCausalLM, AutoModelForSeq2SeqLM, AutoTokenizer
Expand Down Expand Up @@ -145,6 +148,8 @@ def __init__(self,
self.is_gpu_enabled = False
self._model_type = p_model_type
self._low_memory_mode = p_low_memory_mode
self.generation_config = None


if self._load() == False:
self._download()
Expand Down
4 changes: 2 additions & 2 deletions server/model_type.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
#-- Copyright (c) 2021-2022 LyaaaaaGames
#-- Copyright (c) 2022 AIdventure_Server contributors
#-- Copyright (c) 2021-present LyaaaaaGames
#-- Copyright (c) 2022-present AIdventure_Server contributors
#--
#-- Author : Lyaaaaaaaaaaaaaaa
#--
Expand Down
4 changes: 2 additions & 2 deletions server/request.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
#-- Copyright (c) 2021-2022 LyaaaaaGames
#-- Copyright (c) 2022 AIdventure_Server contributors
#-- Copyright (c) 2021-present LyaaaaaGames
#-- Copyright (c) 2022-present AIdventure_Server contributors
#--
#-- Author : Lyaaaaaaaaaaaaaaa
#--
Expand Down
4 changes: 2 additions & 2 deletions server/server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
#-- Copyright (c) 2021-2022 LyaaaaaGames
#-- Copyright (c) 2022 AIdventure_Server contributors
#-- Copyright (c) 2021-present LyaaaaaGames
#-- Copyright (c) 2022-present AIdventure_Server contributors
#--
#-- Author : Lyaaaaaaaaaaaaaaa
#--
Expand Down
4 changes: 2 additions & 2 deletions server/translator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
#-- Copyright (c) 2021-2022 LyaaaaaGames
#-- Copyright (c) 2022 AIdventure_Server contributors
#-- Copyright (c) 2021-present LyaaaaaGames
#-- Copyright (c) 2022-present AIdventure_Server contributors
#--
#-- Author : Lyaaaaaaaaaaaaaaa
#--
Expand Down
4 changes: 2 additions & 2 deletions style_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Each python script must start with this header.

```
#---------------------------------------------------------------------------
#-- Copyright (c) 2021-2022 LyaaaaaGames
#-- Copyright (c) 2022 AIdventure_Server contributors
#-- Copyright (c) 2021-present LyaaaaaGames
#-- Copyright (c) 2022-present AIdventure_Server contributors
#--
#-- author :
#--
Expand Down

0 comments on commit d7042be

Please sign in to comment.