Spaces:
Sleeping
Sleeping
helloworld53
commited on
Commit
·
f1220a5
1
Parent(s):
40335fb
New streamlit committed
Browse files- .requirements.txt.swp +0 -0
- app.py +62 -2
- requirements.txt +4 -0
.requirements.txt.swp
ADDED
Binary file (12.3 kB). View file
|
|
app.py
CHANGED
@@ -1,4 +1,64 @@
|
|
1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
from langchain.callbacks.manager import CallbackManager
|
3 |
+
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
|
4 |
+
from langchain.chains import LLMChain
|
5 |
+
from langchain.prompts import PromptTemplate
|
6 |
+
from langchain_community.llms import LlamaCpp
|
7 |
+
from llama_cpp import Llama
|
8 |
+
from pinecone import Pinecone
|
9 |
+
from huggingface_hub import hf_hub_download
|
10 |
+
@st.cache_resource()
|
11 |
+
def load_model():
|
12 |
|
13 |
+
# from google.colab import userdata
|
14 |
+
model_name_or_path = "CompendiumLabs/bge-large-en-v1.5-gguf"
|
15 |
+
model_basename = 'bge-large-en-v1.5-f32.gguf'
|
16 |
+
model_path = hf_hub_download(
|
17 |
+
repo_id=model_name_or_path,
|
18 |
+
filename=model_basename,
|
19 |
+
cache_dir= '/content/models' # Directory for the model
|
20 |
+
)
|
21 |
+
model = Llama(model_path, embedding=True)
|
22 |
+
|
23 |
+
st.success("Loaded NLP model from Hugging Face!") # 👈 Show a success message
|
24 |
+
|
25 |
+
|
26 |
+
# pc = Pinecone(api_key=api_key)
|
27 |
+
# index = pc.Index("law")
|
28 |
+
# model_2_name = "TheBloke/zephyr-7B-beta-GGUF"
|
29 |
+
# model_2base_name = "zephyr-7b-beta.Q4_K_M.gguf"
|
30 |
+
# model_path_model = hf_hub_download(
|
31 |
+
# repo_id=model_2_name,
|
32 |
+
# filename=model_2base_name,
|
33 |
+
# cache_dir= '/content/models' # Directory for the model
|
34 |
+
# )
|
35 |
+
# prompt_template = "<|system|>\
|
36 |
+
# </s>\
|
37 |
+
# <|user|>\
|
38 |
+
# {prompt}</s>\
|
39 |
+
# <|assistant|>"
|
40 |
+
# template = prompt_template
|
41 |
+
# prompt = PromptTemplate.from_template(template)
|
42 |
+
# callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])
|
43 |
+
# llm = LlamaCpp(
|
44 |
+
# model_path=model_path_model,
|
45 |
+
# temperature=0.75,
|
46 |
+
# max_tokens=2500,
|
47 |
+
# top_p=1,
|
48 |
+
# callback_manager=callback_manager,
|
49 |
+
# verbose=True,
|
50 |
+
# n_ctx=2048,
|
51 |
+
# n_threads = 2# Verbose is required to pass to the callback manager
|
52 |
+
# )
|
53 |
+
return model
|
54 |
+
|
55 |
+
st.title("Please ask your question on Lithuanian rules for foreigners.")
|
56 |
+
a = load_model()
|
57 |
+
question = st.text_input("Enter your question:")
|
58 |
+
# if question:
|
59 |
+
# # Perform Question Answering
|
60 |
+
# answer = qa_chain(context=context, question=question)
|
61 |
+
|
62 |
+
# # Display the answer
|
63 |
+
# st.header("Answer:")
|
64 |
+
# st.write(answer)
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
huggingface-hub
|
2 |
+
pinecone-client
|
3 |
+
llama-cpp-python -C cmake.args="-DLLAMA_BLAS=ON;-DLLAMA_BLAS_VENDOR=OpenBLAS"
|
4 |
+
langchain
|