Spaces:
Sleeping
Sleeping
bugfix to Error: "str" object has no attribute "pad_token_id"
Browse files
app.py
CHANGED
|
@@ -7,6 +7,7 @@ from datetime import datetime
|
|
| 7 |
import gradio as gr
|
| 8 |
import torch
|
| 9 |
from transformers import pipeline, TextIteratorStreamer
|
|
|
|
| 10 |
from duckduckgo_search import DDGS
|
| 11 |
import spaces # Import spaces early to enable ZeroGPU support
|
| 12 |
|
|
@@ -55,12 +56,13 @@ def load_pipeline(model_name):
|
|
| 55 |
if model_name in PIPELINES:
|
| 56 |
return PIPELINES[model_name]
|
| 57 |
repo = MODELS[model_name]["repo_id"]
|
|
|
|
| 58 |
for dtype in (torch.bfloat16, torch.float16, torch.float32):
|
| 59 |
try:
|
| 60 |
pipe = pipeline(
|
| 61 |
task="text-generation",
|
| 62 |
model=repo,
|
| 63 |
-
tokenizer=
|
| 64 |
trust_remote_code=True,
|
| 65 |
torch_dtype=dtype,
|
| 66 |
device_map="auto"
|
|
@@ -73,7 +75,7 @@ def load_pipeline(model_name):
|
|
| 73 |
pipe = pipeline(
|
| 74 |
task="text-generation",
|
| 75 |
model=repo,
|
| 76 |
-
tokenizer=
|
| 77 |
trust_remote_code=True,
|
| 78 |
device_map="auto"
|
| 79 |
)
|
|
|
|
| 7 |
import gradio as gr
|
| 8 |
import torch
|
| 9 |
from transformers import pipeline, TextIteratorStreamer
|
| 10 |
+
from transformers import AutoTokenizer
|
| 11 |
from duckduckgo_search import DDGS
|
| 12 |
import spaces # Import spaces early to enable ZeroGPU support
|
| 13 |
|
|
|
|
| 56 |
if model_name in PIPELINES:
|
| 57 |
return PIPELINES[model_name]
|
| 58 |
repo = MODELS[model_name]["repo_id"]
|
| 59 |
+
tokenizer = AutoTokenizer.from_pretrained(repo)
|
| 60 |
for dtype in (torch.bfloat16, torch.float16, torch.float32):
|
| 61 |
try:
|
| 62 |
pipe = pipeline(
|
| 63 |
task="text-generation",
|
| 64 |
model=repo,
|
| 65 |
+
tokenizer=tokenizer,
|
| 66 |
trust_remote_code=True,
|
| 67 |
torch_dtype=dtype,
|
| 68 |
device_map="auto"
|
|
|
|
| 75 |
pipe = pipeline(
|
| 76 |
task="text-generation",
|
| 77 |
model=repo,
|
| 78 |
+
tokenizer=tokenizer,
|
| 79 |
trust_remote_code=True,
|
| 80 |
device_map="auto"
|
| 81 |
)
|