ffreemt commited on
Commit
f32218b
1 Parent(s): bfb2c2a

Update pygpt4all in requirements.txt

Browse files
.gitignore CHANGED
@@ -7,3 +7,4 @@ __pycache__
7
  .yarn
8
  .chroma
9
  .pnp.cjs
 
 
7
  .yarn
8
  .chroma
9
  .pnp.cjs
10
+ models
ggml-try.py ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Adopted from https://github.com/imartinez/privateGPT/blob/main/privateGPT.py
2
+
3
+ https://raw.githubusercontent.com/imartinez/privateGPT/main/requirements.txt
4
+
5
+ -c https://gpt4all.io/models/ggml-gpt4all-j-v1.3-groovy.bin
6
+ """
7
+ from dotenv import load_dotenv, dotenv_values
8
+ from langchain.chains import RetrievalQA
9
+ from langchain.embeddings import HuggingFaceEmbeddings
10
+ from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
11
+ from langchain.vectorstores import Chroma
12
+ from langchain.llms import GPT4All, LlamaCpp
13
+ import os
14
+ import argparse
15
+ import time
16
+
17
+ from types import SimpleNamespace
18
+ from chromadb.config import Settings
19
+
20
+ # embeddings_model_name = os.environ.get("EMBEDDINGS_MODEL_NAME")
21
+ # persist_directory = os.environ.get('PERSIST_DIRECTORY')
22
+
23
+ # load_dotenv()
24
+ # model_type = os.environ.get('MODEL_TYPE')
25
+ # model_path = os.environ.get('MODEL_PATH')
26
+ # model_n_ctx = os.environ.get('MODEL_N_CTX')
27
+ # model_n_batch = int(os.environ.get('MODEL_N_BATCH',8))
28
+ # target_source_chunks = int(os.environ.get('TARGET_SOURCE_CHUNKS',4))
29
+
30
+ settings = dict([('PERSIST_DIRECTORY', 'db1'),
31
+ ('MODEL_TYPE', 'GPT4All'),
32
+ ('MODEL_PATH', 'models/ggml-gpt4all-j-v1.3-groovy.bin'),
33
+ ('EMBEDDINGS_MODEL_NAME', 'all-MiniLM-L6-v2'),
34
+ ('MODEL_N_CTX', '1000'),
35
+ ('MODEL_N_BATCH', '8'),
36
+ ('TARGET_SOURCE_CHUNKS', '4')])
37
+
38
+ # models/ggml-gpt4all-j-v1.3-groovy.bin ~5G
39
+
40
+ # all-MiniLM-L6-v2 () or
41
+ embeddings_model_name = settings.get("EMBEDDINGS_MODEL_NAME")
42
+
43
+ # embeddings_model_name = 'all-MiniLM-L6-v2'
44
+ embeddings_model_name = 'paraphrase-multilingual-mpnet-base-v2'
45
+
46
+ persist_directory = settings.get('PERSIST_DIRECTORY')
47
+
48
+ model_type = settings.get('MODEL_TYPE')
49
+ model_path = settings.get('MODEL_PATH')
50
+ model_n_ctx = settings.get('MODEL_N_CTX')
51
+ model_n_batch = int(settings.get('MODEL_N_BATCH',8))
52
+ target_source_chunks = int(settings.get('TARGET_SOURCE_CHUNKS',4))
53
+
54
+ # Define the Chroma settings
55
+ CHROMA_SETTINGS = Settings(
56
+ chroma_db_impl='duckdb+parquet',
57
+ persist_directory=persist_directory,
58
+ anonymized_telemetry=False
59
+ )
60
+
61
+ args = SimpleNamespace(hide_source=False, mute_stream=False)
62
+
63
+ embeddings = HuggingFaceEmbeddings(model_name=embeddings_model_name)
64
+ db = Chroma(persist_directory=persist_directory, embedding_function=embeddings, client_settings=CHROMA_SETTINGS)
65
+
66
+ retriever = db.as_retriever(search_kwargs={"k": target_source_chunks})
67
+ # activate/deactivate the streaming StdOut callback for LLMs
68
+ callbacks = [] if args.mute_stream else [StreamingStdOutCallbackHandler()]
69
+ # Prepare the LLM
70
+ match model_type:
71
+ case "LlamaCpp":
72
+ llm = LlamaCpp(model_path=model_path, n_ctx=model_n_ctx, n_batch=model_n_batch, callbacks=callbacks, verbose=False)
73
+ case "GPT4All":
74
+ llm = GPT4All(model=model_path, n_ctx=model_n_ctx, backend='gptj', n_batch=model_n_batch, callbacks=callbacks, verbose=False)
75
+ case _default:
76
+ # raise exception if model_type is not supported
77
+ raise Exception(f"Model type {model_type} is not supported. Please choose one of the following: LlamaCpp, GPT4All")
78
+
79
+ # need about 5G RAM
80
+
81
+ qa = RetrievalQA.from_chain_type(llm=llm, chain_type="stuff", retriever=retriever, return_source_documents= not args.hide_source)
requirements-cuda.txt CHANGED
@@ -27,4 +27,5 @@ docx2txt
27
 
28
  safetensors
29
  about-time
30
- openai
 
 
27
 
28
  safetensors
29
  about-time
30
+ openai
31
+ pygpt4all
requirements-win10-cpu.txt CHANGED
@@ -30,4 +30,6 @@ docx2txt
30
  about-time
31
  openai
32
  more-itertools
33
- # tqdm
 
 
 
30
  about-time
31
  openai
32
  more-itertools
33
+ # tqdm
34
+
35
+ pygpt4all
requirements.txt CHANGED
@@ -28,4 +28,7 @@ docx2txt
28
  about-time
29
  openai
30
  more-itertools
31
- # tqdm
 
 
 
 
28
  about-time
29
  openai
30
  more-itertools
31
+
32
+ #
33
+ wheel
34
+ pygpt4all