Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -65,7 +65,7 @@ def create_conversational_chain(vector_store):
|
|
65 |
#model_type="llama", config={'max_new_tokens': 500, 'temperature': 0.01})
|
66 |
llm = Replicate(
|
67 |
streaming = True,
|
68 |
-
model = "NousResearch/Llama-2-7b-hf",
|
69 |
callbacks=[StreamingStdOutCallbackHandler()],
|
70 |
input = {"temperature": 0.01, "max_length" :500,"top_p":1})
|
71 |
memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)
|
@@ -105,7 +105,7 @@ def main():
|
|
105 |
text.extend(loader.load())
|
106 |
os.remove(temp_file_path)
|
107 |
|
108 |
-
text_splitter = CharacterTextSplitter(separator="\n", chunk_size=
|
109 |
text_chunks = text_splitter.split_documents(text)
|
110 |
|
111 |
# Create embeddings
|
@@ -113,7 +113,7 @@ def main():
|
|
113 |
model_kwargs={'device': 'cpu'})
|
114 |
|
115 |
# Create vector store
|
116 |
-
vector_store = FAISS.from_documents(text_chunks,
|
117 |
|
118 |
# Create the chain object
|
119 |
chain = create_conversational_chain(vector_store)
|
|
|
65 |
#model_type="llama", config={'max_new_tokens': 500, 'temperature': 0.01})
|
66 |
llm = Replicate(
|
67 |
streaming = True,
|
68 |
+
model = AutoModelForCausalLM.from_pretrained("NousResearch/Llama-2-7b-hf", device_map='auto',torch_dtype=torch.float16,load_in_4bit=True, token=True ),
|
69 |
callbacks=[StreamingStdOutCallbackHandler()],
|
70 |
input = {"temperature": 0.01, "max_length" :500,"top_p":1})
|
71 |
memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)
|
|
|
105 |
text.extend(loader.load())
|
106 |
os.remove(temp_file_path)
|
107 |
|
108 |
+
text_splitter = CharacterTextSplitter(separator="\n", chunk_size=1500, chunk_overlap=300, length_function=len)
|
109 |
text_chunks = text_splitter.split_documents(text)
|
110 |
|
111 |
# Create embeddings
|
|
|
113 |
model_kwargs={'device': 'cpu'})
|
114 |
|
115 |
# Create vector store
|
116 |
+
vector_store = FAISS.from_documents(text_chunks,embeddings)
|
117 |
|
118 |
# Create the chain object
|
119 |
chain = create_conversational_chain(vector_store)
|