Upload ERNIE-4.5-21B-A3B-PT with huggingface_hub
Browse files- ERNIE-4.5-21B-A3B-PT +5 -10
ERNIE-4.5-21B-A3B-PT
CHANGED
|
@@ -7,16 +7,11 @@
|
|
| 7 |
# ///
|
| 8 |
|
| 9 |
try:
|
| 10 |
-
#
|
| 11 |
-
from transformers import
|
| 12 |
-
|
| 13 |
-
pipe = pipeline("text-generation", model="baidu/ERNIE-4.5-21B-A3B-PT", trust_remote_code=True)
|
| 14 |
-
messages = [
|
| 15 |
-
{"role": "user", "content": "Who are you?"},
|
| 16 |
-
]
|
| 17 |
-
pipe(messages)
|
| 18 |
except Exception as e:
|
| 19 |
-
exception_file = 'baidu_ERNIE-4.5-21B-A3B-
|
| 20 |
with open(exception_file, 'w') as f:
|
| 21 |
import traceback
|
| 22 |
traceback.print_exc(file=f)
|
|
@@ -25,6 +20,6 @@ except Exception as e:
|
|
| 25 |
upload_file(
|
| 26 |
path_or_fileobj=exception_file,
|
| 27 |
repo_id='model-metadata/model-code-exception',
|
| 28 |
-
path_in_repo='09-07-25/baidu_ERNIE-4.5-21B-A3B-
|
| 29 |
repo_type='dataset',
|
| 30 |
)
|
|
|
|
| 7 |
# ///
|
| 8 |
|
| 9 |
try:
|
| 10 |
+
# Load model directly
|
| 11 |
+
from transformers import AutoModelForCausalLM
|
| 12 |
+
model = AutoModelForCausalLM.from_pretrained("baidu/ERNIE-4.5-21B-A3B-PT", trust_remote_code=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
except Exception as e:
|
| 14 |
+
exception_file = 'baidu_ERNIE-4.5-21B-A3B-PT_1_exception.txt'
|
| 15 |
with open(exception_file, 'w') as f:
|
| 16 |
import traceback
|
| 17 |
traceback.print_exc(file=f)
|
|
|
|
| 20 |
upload_file(
|
| 21 |
path_or_fileobj=exception_file,
|
| 22 |
repo_id='model-metadata/model-code-exception',
|
| 23 |
+
path_in_repo='09-07-25/baidu_ERNIE-4.5-21B-A3B-PT_1_exception.txt',
|
| 24 |
repo_type='dataset',
|
| 25 |
)
|