adityakumar commited on
Commit
5bfd411
1 Parent(s): f92fa28

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -13
app.py CHANGED
@@ -16,6 +16,9 @@ from langchain.chains import ConversationalRetrievalChain, LLMChain
16
  #from langchain.chains import LLMChain
17
  from langchain_core.prompts import PromptTemplate
18
 
 
 
 
19
 
20
  # adding separator
21
  def add_vertical_space(spaces=1):
@@ -34,7 +37,7 @@ def main():
34
  TEMP_DIR = "temp"
35
 
36
  # embedding model path
37
- EMBEDDING_MODEL_PATH = "embeddings/MiniLM-L6-v2"
38
 
39
  # creating faiss db direcoty if it doesnot exist already
40
  if not os.path.exists(TEMP_DIR):
@@ -62,7 +65,10 @@ def main():
62
  data = loader.load()
63
 
64
  # creating embeddings using huggingface
65
- embeddings = HuggingFaceEmbeddings(model_name='sentence-transformers/all-MiniLM-L6-v2')
 
 
 
66
 
67
  # creating chunks from CSV file
68
  #text_splitter = RecursiveCharacterTextSplitter(chunk_size=800, chunk_overlap=50)
@@ -81,17 +87,20 @@ def main():
81
  docsearch.save_local(DB_FAISS_PATH)
82
 
83
  # loading local llama model
84
- llm = CTransformers(#model="models/llama-2-7b-chat.ggmlv3.q8_0.bin",
85
- model="TheBloke/Llama-2-7B-Chat-GGML",
86
- model_type="llama",
87
- #callbacks=[StreamingStdOutCallbackHandler()],
88
- config={'max_new_tokens': 1024,
89
- 'temperature': 0.5,
90
- 'context_length' : 4096
91
- #'repetition_penalty': 1.1
92
- }
93
- )
94
-
 
 
 
95
  # loading remote zephyr model
96
  #llm = AutoModelForCausalLM.from_pretrained("TheBloke/zephyr-7B-beta-GGUF",
97
  # model_file="zephyr-7b-beta.Q5_K_M.gguf",
 
16
  #from langchain.chains import LLMChain
17
  from langchain_core.prompts import PromptTemplate
18
 
19
+ # below 2 libraries are for loading remote models
20
+ from transformers import LlamaForCausalLM
21
+ from sentence_transformers import SentenceTransformer
22
 
23
  # adding separator
24
  def add_vertical_space(spaces=1):
 
37
  TEMP_DIR = "temp"
38
 
39
  # embedding model path
40
+ #EMBEDDING_MODEL_PATH = "embeddings/MiniLM-L6-v2"
41
 
42
  # creating faiss db direcoty if it doesnot exist already
43
  if not os.path.exists(TEMP_DIR):
 
65
  data = loader.load()
66
 
67
  # creating embeddings using huggingface
68
+ #embeddings = HuggingFaceEmbeddings(model_name='sentence-transformers/all-MiniLM-L6-v2')
69
+
70
+ # loading remote embedding model
71
+ embeddings = SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')
72
 
73
  # creating chunks from CSV file
74
  #text_splitter = RecursiveCharacterTextSplitter(chunk_size=800, chunk_overlap=50)
 
87
  docsearch.save_local(DB_FAISS_PATH)
88
 
89
  # loading local llama model
90
+ #llm = CTransformers(#model="models/llama-2-7b-chat.ggmlv3.q8_0.bin",
91
+ # model="TheBloke/Llama-2-7B-Chat-GGML",
92
+ # model_type="llama",
93
+ # #callbacks=[StreamingStdOutCallbackHandler()],
94
+ # config={'max_new_tokens': 1024,
95
+ # 'temperature': 0.5,
96
+ # 'context_length' : 4096
97
+ # #'repetition_penalty': 1.1
98
+ # }
99
+ # )
100
+
101
+ # loading remote llama model
102
+ llm = LlamaForCausalLM.from_pretrained("meta-llama/Llama-2-7b-hf")
103
+
104
  # loading remote zephyr model
105
  #llm = AutoModelForCausalLM.from_pretrained("TheBloke/zephyr-7B-beta-GGUF",
106
  # model_file="zephyr-7b-beta.Q5_K_M.gguf",