Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenzhuo
XVERSE-MoE-A4.2B
Commits
5114c1e2
"vscode:/vscode.git/clone" did not exist on "b9cca5b3e4d9cfdc7b1381769893f75b0eef5afb"
Commit
5114c1e2
authored
Apr 12, 2024
by
chenzhuo
Browse files
Upload New File
parent
1a04978b
Pipeline
#853
failed with stages
in 0 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
0 deletions
+12
-0
hugginginfer.py
hugginginfer.py
+12
-0
No files found.
hugginginfer.py
0 → 100644
View file @
5114c1e2
import
torch
import
sys
'''
'''
from
transformers
import
AutoTokenizer
,
AutoModelForCausalLM
tokenizer
=
AutoTokenizer
.
from_pretrained
(
"weight/"
)
model
=
AutoModelForCausalLM
.
from_pretrained
(
"weight/"
,
trust_remote_code
=
True
,
torch_dtype
=
torch
.
bfloat16
,
device_map
=
'auto'
)
model
=
model
.
eval
()
inputs
=
tokenizer
(
'北京的景点:故宫、天坛、万里长城等。
\n
深圳的景点:'
,
return_tensors
=
'pt'
).
input_ids
inputs
=
inputs
.
cuda
()
generated_ids
=
model
.
generate
(
inputs
,
max_new_tokens
=
64
,
eos_token_id
=
tokenizer
.
eos_token_id
,
repetition_penalty
=
1.1
)
print
(
tokenizer
.
batch_decode
(
generated_ids
,
skip_special_tokens
=
True
))
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment