Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,14 @@ from langchain.vectorstores import FAISS
|
|
4 |
from langchain.llms import CTransformers
|
5 |
from langchain.chains import RetrievalQA
|
6 |
import gradio as gr
|
|
|
|
|
7 |
|
|
|
|
|
|
|
|
|
|
|
8 |
DB_FAISS_PATH = "vectorstores/db_faiss"
|
9 |
|
10 |
custom_prompt_template = """Use the following pieces of information to answer the user's question.
|
@@ -23,7 +30,7 @@ def set_custom_prompt():
|
|
23 |
|
24 |
def load_llm():
|
25 |
llm = CTransformers(
|
26 |
-
model=
|
27 |
model_type="llama",
|
28 |
max_new_tokens=512,
|
29 |
temperature=0.5
|
|
|
4 |
from langchain.llms import CTransformers
|
5 |
from langchain.chains import RetrievalQA
|
6 |
import gradio as gr
|
7 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
8 |
+
from huggingface_hub import hf_hub_download
|
9 |
|
10 |
+
def load_model():
|
11 |
+
model_name = 'TheBloke/Llama-2-7B-Chat-GGML'
|
12 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
13 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
14 |
+
return tokenizer, model
|
15 |
DB_FAISS_PATH = "vectorstores/db_faiss"
|
16 |
|
17 |
custom_prompt_template = """Use the following pieces of information to answer the user's question.
|
|
|
30 |
|
31 |
def load_llm():
|
32 |
llm = CTransformers(
|
33 |
+
model=model,
|
34 |
model_type="llama",
|
35 |
max_new_tokens=512,
|
36 |
temperature=0.5
|