kk53 commited on
Commit
8cc3b16
·
verified ·
1 Parent(s): d7fa171
Files changed (1) hide show
  1. app.py +9 -10
app.py CHANGED
@@ -9,7 +9,6 @@ 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'
@@ -20,10 +19,10 @@ def load_model():
20
  model = Llama(model_path, embedding=True)
21
 
22
  st.success("Loaded NLP model from Hugging Face!") # 👈 Show a success message
23
- apikey = st.secrets["apikey"]
24
  pc = Pinecone(api_key=apikey)
25
  index = pc.Index("law")
26
-
27
  # pc = Pinecone(api_key=api_key)
28
  # index = pc.Index("law")
29
  model_2_name = "TheBloke/zephyr-7B-beta-GGUF"
@@ -31,7 +30,7 @@ def load_model():
31
  model_path_model = hf_hub_download(
32
  repo_id=model_2_name,
33
  filename=model_2base_name,
34
- )
35
  callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])
36
  llm = LlamaCpp(
37
  model_path=model_path_model,
@@ -39,13 +38,13 @@ def load_model():
39
  max_tokens=2500,
40
  top_p=1,
41
  callback_manager=callback_manager,
42
- verbose=True,
43
  n_ctx=2048,
44
  n_threads = 2# Verbose is required to pass to the callback manager
45
  )
46
- st.success("loaded the second NLP model from Hugging Face!")
 
47
 
48
-
49
  # prompt_template = "<|system|>\
50
  # </s>\
51
  # <|user|>\
@@ -56,7 +55,7 @@ def load_model():
56
 
57
  return model, llm, index
58
 
59
-
60
  st.title("Please ask your question on Lithuanian rules for foreigners.")
61
  model,llm, index = load_model()
62
 
@@ -66,7 +65,7 @@ if question != "":
66
  query = model.create_embedding(question)
67
  st.write(query)
68
  q = query['data'][0]['embedding']
69
-
70
  response = index.query(
71
  vector=q,
72
  top_k=1,
@@ -75,4 +74,4 @@ if question != "":
75
  )
76
  response_t = response['matches'][0]['metadata']['text']
77
  st.write(response_t)
78
- st.header("Answer:")
 
9
  from huggingface_hub import hf_hub_download
10
  @st.cache_resource()
11
  def load_model():
 
12
  # from google.colab import userdata
13
  model_name_or_path = "CompendiumLabs/bge-large-en-v1.5-gguf"
14
  model_basename = 'bge-large-en-v1.5-f32.gguf'
 
19
  model = Llama(model_path, embedding=True)
20
 
21
  st.success("Loaded NLP model from Hugging Face!") # 👈 Show a success message
22
+ apikey = st.secrets["apikey"]
23
  pc = Pinecone(api_key=apikey)
24
  index = pc.Index("law")
25
+
26
  # pc = Pinecone(api_key=api_key)
27
  # index = pc.Index("law")
28
  model_2_name = "TheBloke/zephyr-7B-beta-GGUF"
 
30
  model_path_model = hf_hub_download(
31
  repo_id=model_2_name,
32
  filename=model_2base_name,
33
+ )
34
  callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])
35
  llm = LlamaCpp(
36
  model_path=model_path_model,
 
38
  max_tokens=2500,
39
  top_p=1,
40
  callback_manager=callback_manager,
41
+ verbose=True,
42
  n_ctx=2048,
43
  n_threads = 2# Verbose is required to pass to the callback manager
44
  )
45
+ st.success("loaded the second NLP model from Hugging Face!")
46
+
47
 
 
48
  # prompt_template = "<|system|>\
49
  # </s>\
50
  # <|user|>\
 
55
 
56
  return model, llm, index
57
 
58
+
59
  st.title("Please ask your question on Lithuanian rules for foreigners.")
60
  model,llm, index = load_model()
61
 
 
65
  query = model.create_embedding(question)
66
  st.write(query)
67
  q = query['data'][0]['embedding']
68
+
69
  response = index.query(
70
  vector=q,
71
  top_k=1,
 
74
  )
75
  response_t = response['matches'][0]['metadata']['text']
76
  st.write(response_t)
77
+ st.header("Answer:")