Spaces:
Runtime error
Runtime error
Update flask_app.py
Browse files- flask_app.py +4 -4
flask_app.py
CHANGED
|
@@ -8,7 +8,7 @@ import torch
|
|
| 8 |
# Load your tokenizer and model
|
| 9 |
tokenizer = AutoTokenizer.from_pretrained("NLPGenius/GovGPT-llama3")
|
| 10 |
model = AutoModelForCausalLM.from_pretrained("NLPGenius/GovGPT-llama3",
|
| 11 |
-
torch_dtype=torch.bfloat16,
|
| 12 |
device_map="auto",)
|
| 13 |
|
| 14 |
|
|
@@ -21,7 +21,7 @@ llm_chain = transformers.pipeline(
|
|
| 21 |
# we pass model parameters here too
|
| 22 |
temperature=0.3, # 'randomness' of outputs, 0.0 is the min and 1.0 the max
|
| 23 |
do_sample=True,
|
| 24 |
-
max_length=2000, #
|
| 25 |
truncation=True,
|
| 26 |
repetition_penalty=1.1 # without this output begins repeating
|
| 27 |
)
|
|
@@ -106,8 +106,8 @@ def model_inference(retriever, question):
|
|
| 106 |
You are a helpful assistant. Answer the query accurately by focusing solely on the most relevant parts of the provided context.
|
| 107 |
|
| 108 |
1. Identify and use only the sections of the context directly related to the query, ignoring unrelated or extraneous information.
|
| 109 |
-
2. If the query cannot be explicitly answered using the relevant parts of the context, respond with: "The answer is not found
|
| 110 |
-
3. If you are unsure or do not know the answer, respond with: "I don't know."
|
| 111 |
4. Do not add information, interpretations, or assumptions beyond what is explicitly stated in the context.
|
| 112 |
5. Ensure the response is concise, avoids redundancy, and directly addresses the query.
|
| 113 |
|
|
|
|
| 8 |
# Load your tokenizer and model
|
| 9 |
tokenizer = AutoTokenizer.from_pretrained("NLPGenius/GovGPT-llama3")
|
| 10 |
model = AutoModelForCausalLM.from_pretrained("NLPGenius/GovGPT-llama3",
|
| 11 |
+
#torch_dtype=torch.bfloat16,
|
| 12 |
device_map="auto",)
|
| 13 |
|
| 14 |
|
|
|
|
| 21 |
# we pass model parameters here too
|
| 22 |
temperature=0.3, # 'randomness' of outputs, 0.0 is the min and 1.0 the max
|
| 23 |
do_sample=True,
|
| 24 |
+
max_length=2000, # max number of tokens to generate in the output
|
| 25 |
truncation=True,
|
| 26 |
repetition_penalty=1.1 # without this output begins repeating
|
| 27 |
)
|
|
|
|
| 106 |
You are a helpful assistant. Answer the query accurately by focusing solely on the most relevant parts of the provided context.
|
| 107 |
|
| 108 |
1. Identify and use only the sections of the context directly related to the query, ignoring unrelated or extraneous information.
|
| 109 |
+
2. If the query cannot be explicitly answered using the relevant parts of the context, respond with: "The answer is not found."
|
| 110 |
+
3. If you are unsure or do not know the answer, respond with: "I don't know.", don't try to make up an answer.
|
| 111 |
4. Do not add information, interpretations, or assumptions beyond what is explicitly stated in the context.
|
| 112 |
5. Ensure the response is concise, avoids redundancy, and directly addresses the query.
|
| 113 |
|