Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -15,6 +15,14 @@ from langchain.prompts import PromptTemplate
|
|
15 |
from langchain.vectorstores import Qdrant
|
16 |
from PyPDF2 import PdfReader
|
17 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
PROMPT_TEMPLATE = """
|
20 |
Use the following pieces of context enclosed by triple backquotes to answer the question at the end.
|
@@ -114,7 +122,7 @@ def load_llm(model_name: str, temperature: float) -> Union[ChatOpenAI, LlamaCpp]
|
|
114 |
elif model_name.startswith("llama-2-"):
|
115 |
callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])
|
116 |
|
117 |
-
return LlamaCpp(
|
118 |
model_path=f"./models/{model_name}.bin",
|
119 |
input={"temperature": temperature,
|
120 |
"max_length": 2048,
|
@@ -123,7 +131,8 @@ def load_llm(model_name: str, temperature: float) -> Union[ChatOpenAI, LlamaCpp]
|
|
123 |
n_ctx=2048,
|
124 |
callback_manager=callback_manager,
|
125 |
verbose=False, # True
|
126 |
-
)
|
|
|
127 |
|
128 |
|
129 |
def load_embeddings(model_name: str) -> Union[OpenAIEmbeddings, LlamaCppEmbeddings]:
|
|
|
15 |
from langchain.vectorstores import Qdrant
|
16 |
from PyPDF2 import PdfReader
|
17 |
import streamlit as st
|
18 |
+
# Use a pipeline as a high-level helper
|
19 |
+
from transformers import pipeline
|
20 |
+
|
21 |
+
pipe = pipeline("text-generation", model="TheBloke/Llama-2-7B-Chat-GGML")
|
22 |
+
|
23 |
+
# Load model directly
|
24 |
+
from transformers import AutoModel
|
25 |
+
model = AutoModel.from_pretrained("TheBloke/Llama-2-7B-Chat-GGML")
|
26 |
|
27 |
PROMPT_TEMPLATE = """
|
28 |
Use the following pieces of context enclosed by triple backquotes to answer the question at the end.
|
|
|
122 |
elif model_name.startswith("llama-2-"):
|
123 |
callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])
|
124 |
|
125 |
+
'''return LlamaCpp(
|
126 |
model_path=f"./models/{model_name}.bin",
|
127 |
input={"temperature": temperature,
|
128 |
"max_length": 2048,
|
|
|
131 |
n_ctx=2048,
|
132 |
callback_manager=callback_manager,
|
133 |
verbose=False, # True
|
134 |
+
)'''
|
135 |
+
return model
|
136 |
|
137 |
|
138 |
def load_embeddings(model_name: str) -> Union[OpenAIEmbeddings, LlamaCppEmbeddings]:
|