Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
emoUS-public
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
dsml
emoUS-public
Commits
27f2a2b3
Commit
27f2a2b3
authored
Dec 14, 2021
by
aaa123git
Browse files
Options
Downloads
Patches
Plain Diff
* append the last sys turn
* fix Booking in scgpt
parent
726a6326
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
convlab2/nlg/scgpt/multiwoz/preprocess.py
+3
-0
3 additions, 0 deletions
convlab2/nlg/scgpt/multiwoz/preprocess.py
convlab2/nlg/scgpt/multiwoz/scgpt.py
+18
-3
18 additions, 3 deletions
convlab2/nlg/scgpt/multiwoz/scgpt.py
with
21 additions
and
3 deletions
convlab2/nlg/scgpt/multiwoz/preprocess.py
+
3
−
0
View file @
27f2a2b3
...
...
@@ -106,6 +106,9 @@ if __name__ == '__main__':
domain
=
key
.
split
(
'
-
'
)[
0
]
if
domain
not
in
[
'
general
'
,
'
Booking
'
]:
current_domain
=
domain
else
:
if
args
.
role
==
'
sys
'
:
turns
.
append
(
turn
)
title
=
title
if
title
in
val_list
:
current
=
results_val
...
...
This diff is collapsed.
Click to expand it.
convlab2/nlg/scgpt/multiwoz/scgpt.py
+
18
−
3
View file @
27f2a2b3
...
...
@@ -2,6 +2,7 @@ import torch
import
numpy
as
np
import
os
import
zipfile
from
copy
import
deepcopy
from
transformers
import
GPT2LMHeadModel
,
GPT2Tokenizer
from
convlab2.nlg.scgpt.utils
import
tuple2seq
...
...
@@ -71,8 +72,9 @@ class SCGPT(NLG):
'
Restaurant
'
:
False
,
'
Taxi
'
:
False
,
'
Train
'
:
False
,}
if
not
self
.
is_user
:
self
.
sess_domains
[
'
Booking
'
]
=
False
self
.
cur_domain
=
None
# if not self.is_user:
# self.sess_domains['Booking'] = False
def
generate
(
self
,
meta
):
...
...
@@ -80,10 +82,23 @@ class SCGPT(NLG):
if
not
meta
:
return
'
No user action
'
meta
=
deepcopy
(
meta
)
for
list_
in
meta
:
domain
=
list_
[
1
]
if
domain
not
in
(
'
general
'
,
'
Booking
'
):
self
.
cur_domain
=
domain
for
i
,
list_
in
enumerate
(
meta
):
list_
=
list
(
list_
)
if
list_
[
1
]
==
'
Booking
'
:
if
self
.
cur_domain
is
not
None
:
list_
[
1
]
=
self
.
cur_domain
meta
[
i
]
=
list_
else
:
print
(
'
`cur_domain` is None, but there is `Booking` in dialog action.
'
)
raw_text
=
tuple2seq
(
meta
)
domains
=
set
([
item
[
1
]
for
item
in
meta
])
for
domain
in
domains
:
if
domain
!=
'
general
'
and
not
self
.
sess_domains
[
domain
]:
if
domain
not
in
(
'
general
'
,
'
Booking
'
)
and
not
self
.
sess_domains
[
domain
]:
raw_text
=
raw_text
.
replace
(
domain
.
lower
(),
domain
.
lower
()
+
'
*
'
,
1
)
self
.
sess_domains
[
domain
]
=
True
context_tokens
=
self
.
tokenizer
.
encode
(
raw_text
,
add_special_tokens
=
False
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment