Upload custom_code/17-06-25/openbmb_MiniCPM4-0.5B_0.py with huggingface_hub
Browse files
custom_code/17-06-25/openbmb_MiniCPM4-0.5B_0.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# /// script
|
2 |
+
# requires-python = ">=3.12"
|
3 |
+
# dependencies = [
|
4 |
+
# "transformers",
|
5 |
+
# "torch",
|
6 |
+
# ]
|
7 |
+
# ///
|
8 |
+
|
9 |
+
try:
|
10 |
+
# Use a pipeline as a high-level helper
|
11 |
+
from transformers import pipeline
|
12 |
+
|
13 |
+
pipe = pipeline("text-generation", model="openbmb/MiniCPM4-0.5B", trust_remote_code=True)
|
14 |
+
messages = [
|
15 |
+
{"role": "user", "content": "Who are you?"},
|
16 |
+
]
|
17 |
+
pipe(messages)
|
18 |
+
except Exception as e:
|
19 |
+
with open(f'openbmb_MiniCPM4-0.5B_0_exception.txt', 'w') as f:
|
20 |
+
import traceback
|
21 |
+
traceback.print_exc(file=f)
|
22 |
+
from huggingface_hub import upload_file
|
23 |
+
upload_file(
|
24 |
+
path_or_fileobj=f'openbmb_MiniCPM4-0.5B_0_exception.txt',
|
25 |
+
repo_id='model-metadata/model-code-exception',
|
26 |
+
path_in_repo=f'17-06-25/openbmb_MiniCPM4-0.5B_0_exception.txt',
|
27 |
+
repo_type='dataset',
|
28 |
+
)
|