Spaces:
Runtime error
Runtime error
__
Browse files
app.py
CHANGED
@@ -3,11 +3,24 @@ from transformers import (
|
|
3 |
AutoTokenizer, AutoModelForCausalLM)
|
4 |
st.balloons()
|
5 |
|
6 |
-
|
7 |
-
def f():
|
8 |
-
return 1
|
9 |
|
10 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
# DONE 6.1s
|
13 |
|
|
|
3 |
AutoTokenizer, AutoModelForCausalLM)
|
4 |
st.balloons()
|
5 |
|
6 |
+
device = 'cuda'
|
|
|
|
|
7 |
|
8 |
+
@st.cache
|
9 |
+
def model_init():
|
10 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
11 |
+
"ckip-joint/bloom-1b1-zh")
|
12 |
+
model = AutoModelForCausalLM.from_pretrained(
|
13 |
+
"ckip-joint/bloom-1b1-zh",
|
14 |
+
# Ref.: Eric, Thanks!
|
15 |
+
# torch_dtype="auto",
|
16 |
+
# device_map="auto",
|
17 |
+
# Ref. for `half`: Chan-Jan, Thanks!
|
18 |
+
).eval().to(device)
|
19 |
+
return tok, model
|
20 |
+
|
21 |
+
tok, model = model_init()
|
22 |
+
|
23 |
+
st.text(str(repr(model)))
|
24 |
|
25 |
# DONE 6.1s
|
26 |
|