Spaces:
Runtime error
Runtime error
fakezeta
commited on
Commit
·
cb7bd30
1
Parent(s):
88278c4
Trying lmsys/fastchat-t5 model
Browse files- app.py +0 -2
- query_data.py +20 -12
- requirements.txt +3 -3
app.py
CHANGED
@@ -5,8 +5,6 @@ from query_data import get_chain
|
|
5 |
import os
|
6 |
import time
|
7 |
|
8 |
-
os.environ["OPENAI_API_KEY"] = "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"
|
9 |
-
|
10 |
st.set_page_config(page_title="LangChain Local PDF Chat", page_icon=":robot:")
|
11 |
|
12 |
footer="""<style>
|
|
|
5 |
import os
|
6 |
import time
|
7 |
|
|
|
|
|
8 |
st.set_page_config(page_title="LangChain Local PDF Chat", page_icon=":robot:")
|
9 |
|
10 |
footer="""<style>
|
query_data.py
CHANGED
@@ -1,20 +1,28 @@
|
|
1 |
-
from langchain.llms import LlamaCpp
|
|
|
2 |
from langchain.chains import ConversationalRetrievalChain
|
3 |
-
from huggingface_hub import hf_hub_download
|
4 |
|
5 |
-
import psutil
|
6 |
import os
|
7 |
|
8 |
-
|
9 |
-
|
10 |
|
11 |
def get_chain(vectorstore):
|
12 |
-
if not os.path.exists("ggml-vic7b-q5_1.bin"):
|
13 |
-
|
14 |
-
llm = LlamaCpp(model_path="ggml-vic7b-q5_1.bin", n_ctx=2048, n_threads=psutil.cpu_count(logical=False))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
qa_chain = ConversationalRetrievalChain.from_llm(
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
)
|
20 |
return qa_chain
|
|
|
1 |
+
#from langchain.llms import LlamaCpp
|
2 |
+
from langchain import HuggingFacePipeline
|
3 |
from langchain.chains import ConversationalRetrievalChain
|
4 |
+
#from huggingface_hub import hf_hub_download
|
5 |
|
6 |
+
#import psutil
|
7 |
import os
|
8 |
|
9 |
+
offload_path = "offload"
|
|
|
10 |
|
11 |
def get_chain(vectorstore):
|
12 |
+
#if not os.path.exists("ggml-vic7b-q5_1.bin"):
|
13 |
+
# hf_hub_download(repo_id="eachadea/ggml-vicuna-7b-1.1", filename="ggml-vic7b-q5_1.bin", local_dir=".")
|
14 |
+
#llm = LlamaCpp(model_path="ggml-vic7b-q5_1.bin", n_ctx=2048, n_threads=psutil.cpu_count(logical=False))
|
15 |
+
if not os.path.exists(offload_path):
|
16 |
+
os.makedirs(offload_path)
|
17 |
+
llm = HuggingFacePipeline.from_model_id(model_id="lmsys/fastchat-t5-3b-v1.0",
|
18 |
+
task="text2text-generation",
|
19 |
+
model_kwargs={"max_length":512,
|
20 |
+
"device_map":"auto",
|
21 |
+
"offload_folder":"offload"
|
22 |
+
}
|
23 |
+
)
|
24 |
qa_chain = ConversationalRetrievalChain.from_llm(
|
25 |
+
llm,
|
26 |
+
vectorstore.as_retriever(),
|
27 |
+
)
|
|
|
28 |
return qa_chain
|
requirements.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
langchain
|
2 |
typing-extensions>=4.5.0
|
3 |
-
llama-cpp-python
|
4 |
streamlit_chat
|
5 |
pypdf
|
6 |
chromadb
|
7 |
tensorflow_text
|
8 |
-
|
9 |
-
|
|
|
|
1 |
langchain
|
2 |
typing-extensions>=4.5.0
|
|
|
3 |
streamlit_chat
|
4 |
pypdf
|
5 |
chromadb
|
6 |
tensorflow_text
|
7 |
+
huggingface-hub
|
8 |
+
accelerate
|
9 |
+
transformers
|