Spaces:
Sleeping
Sleeping
Pratik Dwivedi
commited on
Commit
·
d9c6906
1
Parent(s):
9bf72c1
multiple models
Browse files
app.py
CHANGED
@@ -8,14 +8,25 @@ def register_gguf_model():
|
|
8 |
|
9 |
prompter = Prompt()
|
10 |
|
11 |
-
your_model_name = "
|
12 |
hf_repo_name = "TheBloke/Llama-2-7B-Chat-GGUF"
|
13 |
model_file = "llama-2-7b-chat.Q5_K_S.gguf"
|
14 |
-
print("registering
|
15 |
prompter.model_catalog.register_gguf_model(your_model_name,hf_repo_name, model_file, prompt_wrapper="open_chat")
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
return prompter
|
20 |
|
21 |
def load_pdf_from_url(url):
|
@@ -33,15 +44,20 @@ def load_pdf_content(pdf):
|
|
33 |
|
34 |
def main():
|
35 |
st.title("BetterZila RAG Enabled LLM")
|
|
|
|
|
36 |
|
|
|
|
|
37 |
with st.spinner("Loading model..."):
|
38 |
-
prompter
|
39 |
st.success("Model loaded!")
|
40 |
|
41 |
with st.spinner("Loading PDF content from the assignment URL..."):
|
42 |
url = "https://pgcag.files.wordpress.com/2010/01/48lawsofpower.pdf"
|
43 |
pdf = load_pdf_from_url(url)
|
44 |
content = load_pdf_content(pdf)
|
|
|
45 |
st.success("PDF content loaded!")
|
46 |
|
47 |
queries = ['Can you give me an example from history where the enemy was crushed totally from the book?', "What's the point of making myself less accessible?", "Can you tell me the story of Queen Elizabeth I from this 48 laws of power book?"]
|
@@ -49,8 +65,11 @@ def main():
|
|
49 |
for query in queries:
|
50 |
st.subheader(f"Query: {query}")
|
51 |
with st.spinner("Generating response..."):
|
|
|
52 |
resp = prompter.prompt_main(query, context=content)
|
53 |
response = resp['llm_response']
|
|
|
|
|
54 |
st.success("Response generated!")
|
55 |
st.write(response)
|
56 |
|
|
|
8 |
|
9 |
prompter = Prompt()
|
10 |
|
11 |
+
your_model_name = "llama"
|
12 |
hf_repo_name = "TheBloke/Llama-2-7B-Chat-GGUF"
|
13 |
model_file = "llama-2-7b-chat.Q5_K_S.gguf"
|
14 |
+
print("registering models")
|
15 |
prompter.model_catalog.register_gguf_model(your_model_name,hf_repo_name, model_file, prompt_wrapper="open_chat")
|
16 |
+
your_model_name = "open_gpt4"
|
17 |
+
hf_repo_name = "TheBloke/Open_Gpt4_8x7B-GGUF"
|
18 |
+
model_file = "open_gpt4_8x7b.Q4_K_M.gguf"
|
19 |
+
prompter.model_catalog.register_gguf_model(your_model_name,hf_repo_name, model_file, prompt_wrapper="open_chat")
|
20 |
+
your_model_name = "phi2"
|
21 |
+
hf_repo_name = "TheBloke/phi-2-GGUF"
|
22 |
+
model_file = "phi-2.Q4_K_M.gguf"
|
23 |
+
prompter.model_catalog.register_gguf_model(your_model_name,hf_repo_name, model_file, prompt_wrapper="open_chat")
|
24 |
+
your_model_name = "mistral"
|
25 |
+
hf_repo_name = "TheBloke/Mistral-7B-Instruct-v0.2-GGUF"
|
26 |
+
model_file = "mistral-7b-instruct-v0.2.Q4_K_M.gguf"
|
27 |
+
prompter.model_catalog.register_gguf_model(your_model_name,hf_repo_name, model_file, prompt_wrapper="open_chat")
|
28 |
+
# print("loading model")
|
29 |
+
# prompter.load_model(your_model_name)
|
30 |
return prompter
|
31 |
|
32 |
def load_pdf_from_url(url):
|
|
|
44 |
|
45 |
def main():
|
46 |
st.title("BetterZila RAG Enabled LLM")
|
47 |
+
with st.spinner("Registering Models for use..."):
|
48 |
+
prompter = register_gguf_model()
|
49 |
|
50 |
+
model_name = st.selectbox("Select Model", ["llama", "open_gpt4", "phi2", "mistral"])
|
51 |
+
st.write("You selected: ", model_name)
|
52 |
with st.spinner("Loading model..."):
|
53 |
+
prompter.load_model(model_name)
|
54 |
st.success("Model loaded!")
|
55 |
|
56 |
with st.spinner("Loading PDF content from the assignment URL..."):
|
57 |
url = "https://pgcag.files.wordpress.com/2010/01/48lawsofpower.pdf"
|
58 |
pdf = load_pdf_from_url(url)
|
59 |
content = load_pdf_content(pdf)
|
60 |
+
print("Loaded PDF content")
|
61 |
st.success("PDF content loaded!")
|
62 |
|
63 |
queries = ['Can you give me an example from history where the enemy was crushed totally from the book?', "What's the point of making myself less accessible?", "Can you tell me the story of Queen Elizabeth I from this 48 laws of power book?"]
|
|
|
65 |
for query in queries:
|
66 |
st.subheader(f"Query: {query}")
|
67 |
with st.spinner("Generating response..."):
|
68 |
+
print("Query: ", query)
|
69 |
resp = prompter.prompt_main(query, context=content)
|
70 |
response = resp['llm_response']
|
71 |
+
print("Time taken: ", response['usage']['processing_time'])
|
72 |
+
print("Response: ", response)
|
73 |
st.success("Response generated!")
|
74 |
st.write(response)
|
75 |
|