Spaces:
Sleeping
Sleeping
Update rag.py
Browse files
rag.py
CHANGED
@@ -112,6 +112,9 @@ class FinancialChatbot:
|
|
112 |
|
113 |
# return response
|
114 |
|
|
|
|
|
|
|
115 |
def generate_answer(self, context, question):
|
116 |
prompt = f"""
|
117 |
You are a financial assistant. If the user greets you (e.g., "Hello," "Hi," "Good morning"), respond politely without requiring context.
|
@@ -126,7 +129,8 @@ class FinancialChatbot:
|
|
126 |
input_text = prompt
|
127 |
# f"Context: {context}\nQuestion: {question}\nAnswer:"
|
128 |
inputs = self.qwen_tokenizer.encode(input_text, return_tensors="pt")
|
129 |
-
outputs = self.qwen_model.generate(inputs, max_length=100)
|
|
|
130 |
return self.qwen_tokenizer.decode(outputs[0], skip_special_tokens=True)
|
131 |
|
132 |
|
|
|
112 |
|
113 |
# return response
|
114 |
|
115 |
+
ValueError: Input length of input_ids is 127, but `max_length` is set to 100. This can lead to unexpected behavior. You should consider increasing `max_length` or, better yet, setting `max_new_tokens`.
|
116 |
+
|
117 |
+
|
118 |
def generate_answer(self, context, question):
|
119 |
prompt = f"""
|
120 |
You are a financial assistant. If the user greets you (e.g., "Hello," "Hi," "Good morning"), respond politely without requiring context.
|
|
|
129 |
input_text = prompt
|
130 |
# f"Context: {context}\nQuestion: {question}\nAnswer:"
|
131 |
inputs = self.qwen_tokenizer.encode(input_text, return_tensors="pt")
|
132 |
+
# outputs = self.qwen_model.generate(inputs, max_length=100)
|
133 |
+
outputs = self.qwen_model.generate(inputs, max_new_tokens=50)
|
134 |
return self.qwen_tokenizer.decode(outputs[0], skip_special_tokens=True)
|
135 |
|
136 |
|