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
cfec5bed
Unverified
Commit
cfec5bed
authored
Sep 11, 2023
by
liukuikun
Committed by
GitHub
Sep 11, 2023
Browse files
[Fix] Update puyu model (#399)
parent
65c662f9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
14 deletions
+16
-14
lmdeploy/model.py
lmdeploy/model.py
+16
-14
No files found.
lmdeploy/model.py
View file @
cfec5bed
...
@@ -308,30 +308,32 @@ class Puyu(BaseModel):
...
@@ -308,30 +308,32 @@ class Puyu(BaseModel):
AI Laboratory."""
AI Laboratory."""
def
__init__
(
self
,
def
__init__
(
self
,
meta_instruction
=
''
,
system
=
''
,
system
=
''
,
user
=
'<|Human|>: '
,
eoh
=
''
,
eosys
=
''
,
eosys
=
''
,
assistant
=
'<|Assistant|>: '
,
user
=
''
,
system_role
=
'<|System|>: '
,
eoh
=
''
,
assistant
=
''
,
eoa
=
''
,
**
kwargs
):
**
kwargs
):
super
().
__init__
(
**
kwargs
)
super
().
__init__
(
**
kwargs
)
self
.
meta_instruction
=
system
self
.
meta_instruction
=
meta_instruction
self
.
system
=
system
self
.
user
=
user
self
.
user
=
user
self
.
eoh
=
eoh
self
.
eosys
=
eosys
self
.
assistant
=
assistant
self
.
assistant
=
assistant
self
.
system
=
system_role
self
.
eosys
=
eosys
self
.
eoh
=
eoh
self
.
eoa
=
eoa
def
decorate_prompt
(
self
,
prompt
,
sequence_start
=
True
):
def
decorate_prompt
(
self
,
prompt
,
sequence_start
=
True
):
assert
self
.
capability
==
'chat'
,
\
assert
self
.
capability
==
'chat'
,
\
f
'
{
type
(
self
).
__name__
}
has no capability of
{
self
.
capability
}
'
f
'
{
type
(
self
).
__name__
}
has no capability of
{
self
.
capability
}
'
if
sequence_start
:
if
sequence_start
:
return
f
'<BOS>
{
self
.
system
}{
self
.
meta_instruction
}{
self
.
eosys
}
\n
'
\
return
f
'<BOS>
{
self
.
system
}{
self
.
meta_instruction
}{
self
.
eosys
}
'
\
f
'
{
self
.
user
}{
prompt
}{
self
.
eoh
}
\n
'
\
f
'
{
self
.
user
}{
prompt
}{
self
.
eoh
}
'
\
f
'
{
self
.
assistant
}
'
f
'
{
self
.
assistant
}
'
else
:
else
:
return
f
'
\n
{
self
.
user
}{
prompt
}{
self
.
eoh
}
\n
{
self
.
assistant
}
'
return
f
'
{
self
.
eoa
}
{
self
.
user
}{
prompt
}{
self
.
eoh
}{
self
.
assistant
}
'
def
messages2prompt
(
self
,
messages
,
sequence_start
=
True
):
def
messages2prompt
(
self
,
messages
,
sequence_start
=
True
):
"""Return the prompt that is concatenated with other elements in the
"""Return the prompt that is concatenated with other elements in the
...
@@ -350,10 +352,10 @@ class Puyu(BaseModel):
...
@@ -350,10 +352,10 @@ class Puyu(BaseModel):
ret
=
f
'<BOS>
{
system
}{
self
.
meta_instruction
}{
self
.
eosys
}
'
ret
=
f
'<BOS>
{
system
}{
self
.
meta_instruction
}{
self
.
eosys
}
'
for
user
,
assistant
in
zip
(
users
,
assistants
):
for
user
,
assistant
in
zip
(
users
,
assistants
):
if
assistant
:
if
assistant
:
ret
+=
f
'
\n
{
self
.
user
}{
user
}{
self
.
eoh
}
\n
{
self
.
assistant
}
'
\
ret
+=
f
'
{
self
.
user
}{
user
}{
self
.
eoh
}{
self
.
assistant
}
'
\
f
'
{
assistant
}
'
f
'
{
assistant
}
{
self
.
eoa
}
'
else
:
else
:
ret
+=
f
'
\n
{
self
.
user
}{
user
}{
self
.
eoh
}
\n
{
self
.
assistant
}
'
ret
+=
f
'
{
self
.
user
}{
user
}{
self
.
eoh
}{
self
.
assistant
}
'
return
ret
return
ret
@
property
@
property
...
...
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