Spaces:
Sleeping
Sleeping
Commit ·
fdf1e35
1
Parent(s): e4811e0
Model prompt change
Browse files
app.py
CHANGED
|
@@ -27,22 +27,22 @@ tiny_model = "TinyLlama/TinyLlama-1.1B-Chat-v1.0"
|
|
| 27 |
tokenizer = AutoTokenizer.from_pretrained(tiny_model)
|
| 28 |
chat_model = AutoModelForCausalLM.from_pretrained(
|
| 29 |
tiny_model,
|
| 30 |
-
torch_dtype=torch.float32
|
|
|
|
| 31 |
|
| 32 |
pipe = pipeline(
|
| 33 |
"text-generation",
|
| 34 |
model=chat_model,
|
| 35 |
tokenizer=tokenizer,
|
| 36 |
device_map="auto",
|
| 37 |
-
max_new_tokens=
|
| 38 |
)
|
| 39 |
|
| 40 |
def clean_chat_output(full_text):
|
| 41 |
-
|
| 42 |
if "<|assistant|>" in full_text:
|
| 43 |
full_text = full_text.split("<|assistant|>")[-1]
|
| 44 |
|
| 45 |
-
# Remove any leftover "Item:" echoes
|
| 46 |
lines = full_text.strip().split("\n")
|
| 47 |
if lines[0].lower().startswith("item:"):
|
| 48 |
lines = lines[1:]
|
|
|
|
| 27 |
tokenizer = AutoTokenizer.from_pretrained(tiny_model)
|
| 28 |
chat_model = AutoModelForCausalLM.from_pretrained(
|
| 29 |
tiny_model,
|
| 30 |
+
torch_dtype=torch.float32,
|
| 31 |
+
device_map = "auto")
|
| 32 |
|
| 33 |
pipe = pipeline(
|
| 34 |
"text-generation",
|
| 35 |
model=chat_model,
|
| 36 |
tokenizer=tokenizer,
|
| 37 |
device_map="auto",
|
| 38 |
+
max_new_tokens=100
|
| 39 |
)
|
| 40 |
|
| 41 |
def clean_chat_output(full_text):
|
| 42 |
+
|
| 43 |
if "<|assistant|>" in full_text:
|
| 44 |
full_text = full_text.split("<|assistant|>")[-1]
|
| 45 |
|
|
|
|
| 46 |
lines = full_text.strip().split("\n")
|
| 47 |
if lines[0].lower().startswith("item:"):
|
| 48 |
lines = lines[1:]
|