upgraded documentation

This commit is contained in:
saloui 2023-05-14 10:23:28 +02:00
parent bccd0c903b
commit b676c29f58
9 changed files with 39 additions and 54 deletions

View File

@ -7,7 +7,7 @@ RUN python3 -m venv venv && . venv/bin/activate
RUN python3 -m pip install --no-cache-dir -r requirements.txt --upgrade pip
COPY ./app.py /srv/app.py
COPY ./pyGpt4All /srv/pyGpt4All
COPY ./gpt4all_api /srv/gpt4all_api
COPY ./backends /srv/backends
COPY ./static /srv/static
COPY ./templates /srv/templates

View File

@ -97,9 +97,10 @@ Now you're ready to work!
# Supported backends
Two backends are now supported:
1 - [The llama_cpp backend](https://github.com/nomic-ai/pygpt4all)
2 - [The GPT-j backend](https://github.com/marella/gpt4all-j)
3 - Hugging face's Transformers (under construction)
1 - [The llama_cpp backend by Abdeladim](https://github.com/abdeladim-s/pyllamacpp)
2 - [The GPT-j backend by Abdeladim](https://github.com/abdeladim-s/pygptj)
3 - [The GPT-j backend by marella](https://github.com/marella/gpt4all-j)
4 - Hugging face's Transformers (under construction)
# Supported models
You can also refuse to download the model during the install procedure and download it manually.

View File

@ -35,9 +35,6 @@ class GPT4ALL(GPTBackend):
model_path=f"./models/gpt_4all/{self.config['model']}",
)
def stop_generation(self):
self.model._grab_text_callback()
def generate(self,
prompt:str,
n_predict: int = 128,

View File

@ -34,9 +34,6 @@ class GptJ(GPTBackend):
prompt_context="", prompt_prefix="", prompt_suffix=""
)
def stop_generation(self):
self.model._grab_text_callback()
def generate(self,
prompt:str,
n_predict: int = 128,

View File

@ -34,9 +34,6 @@ class GPTJ(GPTBackend):
model=f"./models/llama_cpp/{self.config['model']}", avx2 = self.config["use_avx2"]
)
def stop_generation(self):
self.model._grab_text_callback()
def generate(self,
prompt:str,
n_predict: int = 128,

View File

@ -11,7 +11,7 @@ from pathlib import Path
from typing import Callable
from transformers import AutoTokenizer, TextGenerationPipeline
from auto_gptq import AutoGPTQForCausalLM, BaseQuantizeConfig
from pyGpt4All.backend import GPTBackend
from gpt4all_api.backend import GPTBackend
import torch
import yaml
@ -38,11 +38,6 @@ class GPTQ(GPTBackend):
self.model = AutoGPTQForCausalLM.from_pretrained(self.model_dir, BaseQuantizeConfig())
self.tokenizer = AutoTokenizer.from_pretrained(self.model_dir, use_fast=True )
def stop_generation(self):
self.model._grab_text_callback()
def generate(self,
prompt:str,
n_predict: int = 128,

View File

@ -13,7 +13,7 @@ from accelerate import init_empty_weights
from accelerate import load_checkpoint_and_dispatch
from transformers import AutoTokenizer
from transformers import AutoConfig, AutoModelForCausalLM
from pyGpt4All.backend import GPTBackend
from gpt4all_api.backend import GPTBackend
import torch
__author__ = "parisneo"
@ -39,10 +39,6 @@ class HuggingFace(GPTBackend):
self.tokenizer = AutoTokenizer.from_pretrained(config["model"])
self.model = AutoModelForCausalLM.from_pretrained(config["model"], load_in_8bit=True, device_map='auto')
def stop_generation(self):
self.model._grab_text_callback()
def generate(self,
prompt:str,
n_predict: int = 128,

View File

@ -37,9 +37,6 @@ class LLAMACPP(GPTBackend):
seed=self.config['seed'],
)
def stop_generation(self):
self.model._grab_text_callback()
def generate(self,
prompt:str,
n_predict: int = 128,

View File

@ -167,34 +167,39 @@ class ModelProcess:
time.sleep(1)
print(ex)
def _generate(self, prompt, id, n_predict):
self.id = id
if self.config["override_personality_model_parameters"]:
self.model.generate(
prompt,
new_text_callback=self._callback,
n_predict=n_predict,
temp=self.config['temperature'],
top_k=self.config['top_k'],
top_p=self.config['top_p'],
repeat_penalty=self.config['repeat_penalty'],
repeat_last_n = self.config['repeat_last_n'],
seed=self.config['seed'],
n_threads=self.config['n_threads']
)
if self.model is not None:
self.id = id
if self.config["override_personality_model_parameters"]:
self.model.generate(
prompt,
new_text_callback=self._callback,
n_predict=n_predict,
temp=self.config['temperature'],
top_k=self.config['top_k'],
top_p=self.config['top_p'],
repeat_penalty=self.config['repeat_penalty'],
repeat_last_n = self.config['repeat_last_n'],
seed=self.config['seed'],
n_threads=self.config['n_threads']
)
else:
self.model.generate(
prompt,
new_text_callback=self._callback,
n_predict=n_predict,
temp=self.personality.model_temperature,
top_k=self.personality.model_top_k,
top_p=self.personality.model_top_p,
repeat_penalty=self.personality.model_repeat_penalty,
repeat_last_n = self.personality.model_repeat_last_n,
#seed=self.config['seed'],
n_threads=self.config['n_threads']
)
else:
self.model.generate(
prompt,
new_text_callback=self._callback,
n_predict=n_predict,
temp=self.personality.model_temperature,
top_k=self.personality.model_top_k,
top_p=self.personality.model_top_p,
repeat_penalty=self.personality.model_repeat_penalty,
repeat_last_n = self.personality.model_repeat_last_n,
#seed=self.config['seed'],
n_threads=self.config['n_threads']
)
print("No model is installed or selected. Please make sure to install a model and select it inside your configuration before attempting to communicate with the model.")
print("To do this: Install the model to your models/<backend name> folder.")
print("Then set your model information in your local configuration file that you can find in configs/local_default.yaml")
print("You can also use the ui to set your model in the settings page.")
def _callback(self, text):
if not self.ready:
print(".",end="")