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
a2d86eff
Commit
a2d86eff
authored
Dec 8, 2021
by
Carel van Niekerk
Browse files
Options
Downloads
Patches
Plain Diff
Update model loader
parent
7a7381cb
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
convlab2/nlg/scgpt/multiwoz/scgpt.py
+16
-11
16 additions, 11 deletions
convlab2/nlg/scgpt/multiwoz/scgpt.py
with
16 additions
and
11 deletions
convlab2/nlg/scgpt/multiwoz/scgpt.py
+
16
−
11
View file @
a2d86eff
...
@@ -10,23 +10,28 @@ from convlab2.nlg.nlg import NLG
...
@@ -10,23 +10,28 @@ from convlab2.nlg.nlg import NLG
from
convlab2.util.file_util
import
cached_path
from
convlab2.util.file_util
import
cached_path
MAX_LENGTH
=
int
(
10000
)
# Hardcoded max length to avoid infinite loop
MAX_LENGTH
=
int
(
10000
)
# Hardcoded max length to avoid infinite loop
DEFAULT_DIRECTORY
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
"
models
"
)
DEFAULT_ARCHIVE_FILE
=
os
.
path
.
join
(
DEFAULT_DIRECTORY
,
"
nlg-gpt-multiwoz.zip
"
)
class
SCGPT
(
NLG
):
class
SCGPT
(
NLG
):
def
__init__
(
self
,
def
__init__
(
self
,
model_file
=
None
,
archive_file
=
DEFAULT_ARCHIVE_FILE
,
use_cuda
=
True
,
is_user
=
False
):
use_cuda
=
True
,
# If no filename is mentioned then set to default
is_user
=
False
,
if
not
model_file
:
model_file
=
'
https://convlab.blob.core.windows.net/convlab-2/nlg-gpt-multiwoz.zip
'
):
if
is_user
:
model_file
=
'
https://convlab.blob.core.windows.net/convlab-2/nlg-gpt-multiwoz.zip
'
else
:
model_file
=
'
https://zenodo.org/record/5767426/files/neo_scgpt_system.zip
'
# Load from file/url
model_dir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
model_dir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
if
not
os
.
path
.
isfile
(
archive
_file
):
if
not
os
.
path
.
isfile
(
model
_file
):
archive
_file
=
cached_path
(
model_file
)
model
_file
=
cached_path
(
model_file
)
archive
=
zipfile
.
ZipFile
(
archive
_file
,
'
r
'
)
archive
=
zipfile
.
ZipFile
(
model
_file
,
'
r
'
)
archive
.
extractall
(
model_dir
)
archive
.
extractall
(
model_dir
)
# Get model directory
model_file
=
archive
.
filelist
[
0
].
filename
.
replace
(
'
/
'
,
''
)
self
.
model_name_or_path
=
os
.
path
.
join
(
model_dir
,
'
multiwoz
'
)
self
.
model_name_or_path
=
os
.
path
.
join
(
model_dir
,
model_file
)
self
.
length
=
50
self
.
length
=
50
self
.
num_samples
=
5
self
.
num_samples
=
5
self
.
temperature
=
1.0
self
.
temperature
=
1.0
...
...
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