Spaces:
Sleeping
Sleeping
helloworld53
commited on
Commit
·
0772292
1
Parent(s):
c5226a5
no clue
Browse files
app.py
CHANGED
@@ -16,7 +16,7 @@ def load_model():
|
|
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 |
|
@@ -30,7 +30,7 @@ def load_model():
|
|
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 |
callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])
|
36 |
llm = LlamaCpp(
|
@@ -45,25 +45,7 @@ def load_model():
|
|
45 |
)
|
46 |
st.success("loaded the second NLP model from Hugging Face!")
|
47 |
|
48 |
-
|
49 |
-
model_2base_name = "zephyr-7b-beta.Q4_K_M.gguf"
|
50 |
-
model_path_model = hf_hub_download(
|
51 |
-
repo_id=model_2_name,
|
52 |
-
filename=model_2base_name,
|
53 |
-
cache_dir= '/content/models' # Directory for the model
|
54 |
-
)
|
55 |
-
callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])
|
56 |
-
llm = LlamaCpp(
|
57 |
-
model_path=model_path_model,
|
58 |
-
temperature=0.75,
|
59 |
-
max_tokens=2500,
|
60 |
-
top_p=1,
|
61 |
-
callback_manager=callback_manager,
|
62 |
-
verbose=True,
|
63 |
-
n_ctx=2048,
|
64 |
-
n_threads = 2# Verbose is required to pass to the callback manager
|
65 |
-
)
|
66 |
-
st.success("loaded the second NLP model from Hugging Face!")
|
67 |
# prompt_template = "<|system|>\
|
68 |
# </s>\
|
69 |
# <|user|>\
|
@@ -73,39 +55,14 @@ def load_model():
|
|
73 |
# prompt = PromptTemplate.from_template(template)
|
74 |
|
75 |
return model, llm
|
76 |
-
|
77 |
-
# llm = LlamaCpp(
|
78 |
-
# model_path=model_path_model,
|
79 |
-
# temperature=0.75,
|
80 |
-
# max_tokens=2500,
|
81 |
-
# top_p=1,
|
82 |
-
# callback_manager=callback_manager,
|
83 |
-
# verbose=True,
|
84 |
-
# n_ctx=2048,
|
85 |
-
# n_threads = 2# Verbose is required to pass to the callback manager
|
86 |
-
# )
|
87 |
-
return model, llm
|
88 |
|
89 |
st.title("Please ask your question on Lithuanian rules for foreigners.")
|
90 |
model,llm = load_model()
|
91 |
-
|
92 |
-
|
93 |
-
model,llm = load_model()
|
94 |
-
pc = Pinecone(api_key="003117b0-6caf-4de4-adf9-cc49da6587e6")
|
95 |
index = pc.Index("law")
|
96 |
question = st.text_input("Enter your question:")
|
97 |
-
query = model.create_embedding(question)
|
98 |
-
q = query['data'][0]['embedding']
|
99 |
-
response = index.query(
|
100 |
-
vector=q,
|
101 |
-
top_k=1,
|
102 |
-
include_metadata = True,
|
103 |
-
namespace = "ns1"
|
104 |
-
)
|
105 |
-
response_t = response['matches'][0]['metadata']['text']
|
106 |
-
st.header("Answer:")
|
107 |
-
st.write(response_t)
|
108 |
-
|
109 |
query = model.create_embedding(question)
|
110 |
q = query['data'][0]['embedding']
|
111 |
response = index.query(
|
|
|
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 |
|
|
|
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 |
callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])
|
36 |
llm = LlamaCpp(
|
|
|
45 |
)
|
46 |
st.success("loaded the second NLP model from Hugging Face!")
|
47 |
|
48 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
# prompt_template = "<|system|>\
|
50 |
# </s>\
|
51 |
# <|user|>\
|
|
|
55 |
# prompt = PromptTemplate.from_template(template)
|
56 |
|
57 |
return model, llm
|
58 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
st.title("Please ask your question on Lithuanian rules for foreigners.")
|
61 |
model,llm = load_model()
|
62 |
+
apikey = st.secrets["apikey"]
|
63 |
+
pc = Pinecone(api_key=apikey)
|
|
|
|
|
64 |
index = pc.Index("law")
|
65 |
question = st.text_input("Enter your question:")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
query = model.create_embedding(question)
|
67 |
q = query['data'][0]['embedding']
|
68 |
response = index.query(
|