From 1a0f353f36e21c7027e604f3f904e9aa3af0ca52 Mon Sep 17 00:00:00 2001 From: alxspiker Date: Fri, 12 May 2023 18:54:59 -0600 Subject: [PATCH 1/2] Better .env with more settings Might also help fix never ending ai response. --- example.env | 29 ++++++++++++++++++++++++++++- startLLM.py | 4 +++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/example.env b/example.env index a8626f5..42fbf52 100644 --- a/example.env +++ b/example.env @@ -1,6 +1,33 @@ +################################# +# DIRECTORY SETTINGS # +################################# +# Vertex database folder name. Database will be created after running ingest.py on your documents. PERSIST_DIRECTORY=db +# The directory your documents are in. (Currently supporting TXT,CSV,PDF) +# Note: You can define the directory as an argument instead. Ex: "python ./ingest.py 'c:/documents'" DOCUMENTS_DIRECTORY=source_documents + +################################# +# LLM MODEL SETTINGS # +################################# +# Absolute path to your llama supported embeddings model. +# Can be the same as your LLM's MODEL_PATH below if using LlamaCpp for your model type. LLAMA_EMBEDDINGS_MODEL=models/ggml-model-q4_0.bin +# Your LLM model type. (Currently supports GPT4All or LlamaCpp) +# MODEL_TYPE=LlamaCpp MODEL_TYPE=GPT4All +# Absolute path to your GPT4All or LlamaCpp LLM model MODEL_PATH=models/ggml-gpt4all-j-v1.3-groovy.bin -MODEL_N_CTX=1000 \ No newline at end of file +# Context size for both the vertex datbase and the llm model seperately in one value. +# Increase this value only if you are getting context size errors. (Try just doubling it.) +# Default is 1024 +MODEL_N_CTX=1024 +# Temperature between 0 and 1 for your GPT4All or LlamaCpp LLM model. +# 0=Logical 1=Creative +# Default is 0.8 +MODEL_TEMP=0.8 +# Stop sequences for your GPT4All or LlamaCpp LLM model. +# Stop based on certain characters or strings. +# This stops the model from writing multiple lines and continuing. +# \n is for new lines and \t is for tabs. +MODEL_STOP=\n,\t \ No newline at end of file diff --git a/startLLM.py b/startLLM.py index 88c4864..c71dee5 100644 --- a/startLLM.py +++ b/startLLM.py @@ -12,6 +12,8 @@ model_type = os.environ.get('MODEL_TYPE') model_path = os.environ.get('MODEL_PATH') model_n_ctx = os.environ.get('MODEL_N_CTX') +model_temp = os.environ.get('MODEL_TEMP') +model_stop = os.environ.get('MODEL_STOP').split(",") def main(): # Load stored vectorstore @@ -32,7 +34,7 @@ def main(): match model_type: case "LlamaCpp": from langchain.llms import LlamaCpp - llm = LlamaCpp(model_path=local_path, n_ctx=model_n_ctx, callbacks=callbacks, verbose=True) + llm = LlamaCpp(model_path=local_path, n_ctx=model_n_ctx, temperature=model_temp, stop=model_stop, callbacks=callbacks, verbose=True) case "GPT4All": from langchain.llms import GPT4All llm = GPT4All(model=local_path, n_ctx=model_n_ctx, callbacks=callbacks, verbose=True, backend='gptj') From 39b97634748aef83f1763573811f655485dfca9f Mon Sep 17 00:00:00 2001 From: su77ungr <69374354+su77ungr@users.noreply.github.com> Date: Sat, 13 May 2023 05:39:26 +0200 Subject: [PATCH 2/2] Update example.env --- example.env | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/example.env b/example.env index 42fbf52..5d9b6f1 100644 --- a/example.env +++ b/example.env @@ -1,33 +1,25 @@ -################################# # DIRECTORY SETTINGS # -################################# -# Vertex database folder name. Database will be created after running ingest.py on your documents. + PERSIST_DIRECTORY=db -# The directory your documents are in. (Currently supporting TXT,CSV,PDF) -# Note: You can define the directory as an argument instead. Ex: "python ./ingest.py 'c:/documents'" DOCUMENTS_DIRECTORY=source_documents -################################# # LLM MODEL SETTINGS # -################################# + +# Your LLM type (GPT4All or LlamaCpp) +MODEL_TYPE=GPT4All + # Absolute path to your llama supported embeddings model. -# Can be the same as your LLM's MODEL_PATH below if using LlamaCpp for your model type. LLAMA_EMBEDDINGS_MODEL=models/ggml-model-q4_0.bin -# Your LLM model type. (Currently supports GPT4All or LlamaCpp) -# MODEL_TYPE=LlamaCpp -MODEL_TYPE=GPT4All -# Absolute path to your GPT4All or LlamaCpp LLM model + +# Absolute path to your GPT4All or LlamaCpp model MODEL_PATH=models/ggml-gpt4all-j-v1.3-groovy.bin -# Context size for both the vertex datbase and the llm model seperately in one value. -# Increase this value only if you are getting context size errors. (Try just doubling it.) -# Default is 1024 + +# Context size for both the vector datbase and the llm seperately in one value +# Double this value if you are getting context size errors MODEL_N_CTX=1024 -# Temperature between 0 and 1 for your GPT4All or LlamaCpp LLM model. -# 0=Logical 1=Creative -# Default is 0.8 +# Temperature range of 0=Logical to 1=Creative MODEL_TEMP=0.8 -# Stop sequences for your GPT4All or LlamaCpp LLM model. + # Stop based on certain characters or strings. -# This stops the model from writing multiple lines and continuing. # \n is for new lines and \t is for tabs. -MODEL_STOP=\n,\t \ No newline at end of file +MODEL_STOP=\n,\t