Update app.py
Browse files
app.py
CHANGED
|
@@ -16,6 +16,10 @@ print('token = ',token)
|
|
| 16 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 17 |
|
| 18 |
model_id = "mistralai/Mistral-7B-v0.3"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
tokenizer = AutoTokenizer.from_pretrained(model_id, token= token)
|
| 20 |
|
| 21 |
model = AutoModelForCausalLM.from_pretrained(model_id, token= token)
|
|
@@ -32,9 +36,15 @@ def respond(
|
|
| 32 |
temperature,
|
| 33 |
top_p,
|
| 34 |
):
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
outputs = model.generate(
|
| 38 |
gen_text=tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 39 |
|
| 40 |
print(gen_text)
|
|
|
|
| 16 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 17 |
|
| 18 |
model_id = "mistralai/Mistral-7B-v0.3"
|
| 19 |
+
|
| 20 |
+
model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
|
| 21 |
+
|
| 22 |
+
|
| 23 |
tokenizer = AutoTokenizer.from_pretrained(model_id, token= token)
|
| 24 |
|
| 25 |
model = AutoModelForCausalLM.from_pretrained(model_id, token= token)
|
|
|
|
| 36 |
temperature,
|
| 37 |
top_p,
|
| 38 |
):
|
| 39 |
+
messages = [
|
| 40 |
+
{"role": "user", "content": "What is your favourite condiment?"},
|
| 41 |
+
{"role": "assistant", "content": "Well, I'm quite partial to a good squeeze of fresh lemon juice. It adds just the right amount of zesty flavour to whatever I'm cooking up in the kitchen!"},
|
| 42 |
+
{"role": "user", "content": "Do you have mayonnaise recipes?"}
|
| 43 |
+
]
|
| 44 |
+
|
| 45 |
+
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to("cuda")
|
| 46 |
|
| 47 |
+
outputs = model.generate(inputs, max_new_tokens=20)
|
| 48 |
gen_text=tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 49 |
|
| 50 |
print(gen_text)
|