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
OpenDAS
Lmdeploy
Commits
61e8d2c6
Unverified
Commit
61e8d2c6
authored
Jul 05, 2023
by
q.yao
Committed by
GitHub
Jul 05, 2023
Browse files
remove tokenizer_path from chat_example and move it to lmdeploy/turbomind (#55)
parent
da62f428
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
lmdeploy/turbomind/chat.py
lmdeploy/turbomind/chat.py
+5
-3
No files found.
examples/python/chat_example
.py
→
lmdeploy/turbomind/chat
.py
View file @
61e8d2c6
import
os.path
as
osp
import
random
import
fire
...
...
@@ -13,9 +14,10 @@ def input_prompt():
return
'
\n
'
.
join
(
iter
(
input
,
sentinel
))
def
main
(
model_name
,
model_path
,
tokenizer_model_path
,
session_id
:
int
=
1
):
def
main
(
model_name
,
model_path
,
session_id
:
int
=
1
):
tm_model
=
tm
.
TurboMind
(
model_path
)
generator
=
tm_model
.
create_instance
()
tokenizer_model_path
=
osp
.
join
(
model_path
,
'triton_models'
,
'tokenizer'
)
tokenizer
=
AutoTokenizer
.
from_pretrained
(
tokenizer_model_path
)
model
=
MODELS
.
get
(
model_name
)()
...
...
@@ -48,8 +50,8 @@ def main(model_name, model_path, tokenizer_model_path, session_id: int = 1):
random_seed
=
seed
if
nth_round
==
1
else
None
):
res
,
tokens
=
outputs
[
0
]
# decode res
response
=
tokenizer
.
decode
(
res
[
step
:],
skip_special_tokens
=
True
)
response
=
tokenizer
.
decode
(
res
[
step
:],
skip_special_tokens
=
True
)
print
(
f
'session
{
session_id
}
,
{
tokens
}
,
{
response
}
'
)
# update step
step
=
tokens
-
1
...
...
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