Spaces:
Runtime error
Runtime error
Commit
·
16fb26d
1
Parent(s):
dc3d805
Fix return values in respond function and add photo
Browse files- app.py +5 -1
- logo111.png +0 -0
app.py
CHANGED
|
@@ -19,6 +19,10 @@ model_name = "dicta-il/dictalm2.0-instruct"
|
|
| 19 |
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16)
|
| 20 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
@app.route('/chat', methods=['POST'])
|
| 23 |
def chat():
|
| 24 |
data = request.json
|
|
@@ -33,7 +37,7 @@ def chat():
|
|
| 33 |
inputs = tokenizer(user_input, return_tensors='pt', padding=True, truncation=True)
|
| 34 |
input_ids = inputs['input_ids']
|
| 35 |
attention_mask = inputs['attention_mask']
|
| 36 |
-
outputs = model.generate(input_ids, attention_mask=attention_mask
|
| 37 |
response_text = tokenizer.decode(outputs[0], skip_special_tokens=True).replace(user_input, '').strip()
|
| 38 |
|
| 39 |
return jsonify({"response": response_text})
|
|
|
|
| 19 |
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16)
|
| 20 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 21 |
|
| 22 |
+
# Set the pad_token to eos_token if not already set
|
| 23 |
+
if tokenizer.pad_token is None:
|
| 24 |
+
tokenizer.pad_token = tokenizer.eos_token
|
| 25 |
+
|
| 26 |
@app.route('/chat', methods=['POST'])
|
| 27 |
def chat():
|
| 28 |
data = request.json
|
|
|
|
| 37 |
inputs = tokenizer(user_input, return_tensors='pt', padding=True, truncation=True)
|
| 38 |
input_ids = inputs['input_ids']
|
| 39 |
attention_mask = inputs['attention_mask']
|
| 40 |
+
outputs = model.generate(input_ids, attention_mask=attention_mask)
|
| 41 |
response_text = tokenizer.decode(outputs[0], skip_special_tokens=True).replace(user_input, '').strip()
|
| 42 |
|
| 43 |
return jsonify({"response": response_text})
|
logo111.png
ADDED
|