Update app.py
Browse files
app.py
CHANGED
@@ -38,7 +38,7 @@ DEVICE = "cuda:0" if torch.cuda.is_available() else "cpu"
|
|
38 |
|
39 |
@st.cache_data
|
40 |
def load_data():
|
41 |
-
loader = PyPDFDirectoryLoader("/home/user/app/
|
42 |
docs = loader.load()
|
43 |
return docs
|
44 |
|
@@ -64,22 +64,27 @@ def load_model(_docs):
|
|
64 |
quantize_config=None,
|
65 |
)
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
DEFAULT_SYSTEM_PROMPT = """
|
68 |
-
You are a helpful, respectful and honest assistant
|
69 |
-
|
70 |
-
Please ensure that your responses are socially unbiased and positive in nature.
|
71 |
-
Always provide the citation for the answer from the text.
|
72 |
-
Try to include any section or subsection present in the text responsible for the answer.
|
73 |
-
Provide reference. Provide page number, section, sub section etc.
|
74 |
-
If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.
|
75 |
-
Given a government document that outlines rules and regulations for a specific industry or sector, use your language model to answer questions about the rules and their applicability over time.
|
76 |
-
The document may include provisions that take effect at different times, such as immediately upon publication, after a grace period, or on a specific date in the future.
|
77 |
-
Your task is to identify the relevant rules and determine when they go into effect, taking into account any dependencies or exceptions that may apply.
|
78 |
-
The current date is 14 September, 2023. Try to extract information which is closer to this date.
|
79 |
-
Take a deep breath and work on this problem step-by-step.
|
80 |
""".strip()
|
81 |
|
82 |
-
|
83 |
def generate_prompt(prompt: str, system_prompt: str = DEFAULT_SYSTEM_PROMPT) -> str:
|
84 |
return f"""[INST] <<SYS>>{system_prompt}<</SYS>>{prompt} [/INST]""".strip()
|
85 |
|
|
|
38 |
|
39 |
@st.cache_data
|
40 |
def load_data():
|
41 |
+
loader = PyPDFDirectoryLoader("/home/user/app/ML/")
|
42 |
docs = loader.load()
|
43 |
return docs
|
44 |
|
|
|
64 |
quantize_config=None,
|
65 |
)
|
66 |
|
67 |
+
# DEFAULT_SYSTEM_PROMPT = """
|
68 |
+
# You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe.
|
69 |
+
# Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content.
|
70 |
+
# Please ensure that your responses are socially unbiased and positive in nature.
|
71 |
+
# Always provide the citation for the answer from the text.
|
72 |
+
# Try to include any section or subsection present in the text responsible for the answer.
|
73 |
+
# Provide reference. Provide page number, section, sub section etc.
|
74 |
+
# If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.
|
75 |
+
# Given a government document that outlines rules and regulations for a specific industry or sector, use your language model to answer questions about the rules and their applicability over time.
|
76 |
+
# The document may include provisions that take effect at different times, such as immediately upon publication, after a grace period, or on a specific date in the future.
|
77 |
+
# Your task is to identify the relevant rules and determine when they go into effect, taking into account any dependencies or exceptions that may apply.
|
78 |
+
# The current date is 14 September, 2023. Try to extract information which is closer to this date.
|
79 |
+
# Take a deep breath and work on this problem step-by-step.
|
80 |
+
# """.strip()
|
81 |
+
|
82 |
+
|
83 |
DEFAULT_SYSTEM_PROMPT = """
|
84 |
+
You are a helpful, respectful and honest assistant with knowledge of machine learning, data science, computer science, Python programming language, mathematics, probability and statistics.
|
85 |
+
Take a deep breath and work on the given problem step-by-step.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
""".strip()
|
87 |
|
|
|
88 |
def generate_prompt(prompt: str, system_prompt: str = DEFAULT_SYSTEM_PROMPT) -> str:
|
89 |
return f"""[INST] <<SYS>>{system_prompt}<</SYS>>{prompt} [/INST]""".strip()
|
90 |
|