Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,32 +1,8 @@
|
|
1 |
-
from transformers import
|
2 |
|
3 |
-
model_name = "meta-llama/Llama-3.3-70B-Instruct"
|
4 |
-
|
5 |
-
model = AutoModelForCausalLM.from_pretrained(
|
6 |
-
model_name,
|
7 |
-
torch_dtype="auto",
|
8 |
-
device_map="auto"
|
9 |
-
)
|
10 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
11 |
-
|
12 |
-
prompt = "How many r in strawberry."
|
13 |
messages = [
|
14 |
-
{"role": "system", "content": "You are a
|
15 |
-
{"role": "user", "content":
|
16 |
]
|
17 |
-
|
18 |
-
|
19 |
-
tokenize=False,
|
20 |
-
add_generation_prompt=True
|
21 |
-
)
|
22 |
-
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
23 |
-
|
24 |
-
generated_ids = model.generate(
|
25 |
-
**model_inputs,
|
26 |
-
max_new_tokens=512
|
27 |
-
)
|
28 |
-
generated_ids = [
|
29 |
-
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
30 |
-
]
|
31 |
-
|
32 |
-
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
|
|
1 |
+
from transformers import pipeline
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
messages = [
|
4 |
+
{"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
|
5 |
+
{"role": "user", "content": "Who are you?"},
|
6 |
]
|
7 |
+
chatbot = pipeline("text-generation", model="mistralai/Mistral-Nemo-Instruct-2407",max_new_tokens=128)
|
8 |
+
chatbot(messages)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|