Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lambo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
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
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
Syntactic Tools
lambo
Commits
9fcf1532
Commit
9fcf1532
authored
Dec 13, 2022
by
piotrmp
Browse files
Options
Downloads
Patches
Plain Diff
Subword splitting implementation.
parent
183cf56d
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!2
Multiword generation
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lambo/examples/run_training_splitting.py
+34
-0
34 additions, 0 deletions
src/lambo/examples/run_training_splitting.py
with
34 additions
and
0 deletions
src/lambo/examples/run_training_splitting.py
0 → 100644
+
34
−
0
View file @
9fcf1532
"""
Script for training LAMBO subword splitting models using UD data from pretrained
"""
import
sys
from
pathlib
import
Path
import
importlib_resources
as
resources
import
torch
from
lambo.learning.train
import
train_new_and_save
,
train_pretrained_and_save
from
lambo.segmenter.lambo
import
Lambo
from
lambo.subwords.train
import
train_subwords_and_save
if
__name__
==
'
__main__
'
:
treebanks
=
Path
.
home
()
/
'
data/lambo/ud-treebanks-v2.11/
'
outpath
=
Path
.
home
()
/
'
data/lambo/models/subword/
'
segmenting_path
=
Path
.
home
()
/
'
data/lambo/models/full211-s/
'
device
=
torch
.
device
(
'
cuda
'
if
torch
.
cuda
.
is_available
()
else
'
cpu
'
)
languages_file_str
=
resources
.
read_text
(
'
lambo.resources
'
,
'
languages.txt
'
,
encoding
=
'
utf-8
'
,
errors
=
'
strict
'
)
lines
=
[
line
.
strip
()
for
line
in
languages_file_str
.
split
(
'
\n
'
)
if
not
line
[
0
]
==
'
#
'
]
for
i
,
line
in
enumerate
(
lines
):
#if len(sys.argv)>4 and i % 5 != int(sys.argv[4]):
# continue
parts
=
line
.
split
()
model
=
parts
[
0
]
if
(
outpath
/
(
model
+
'
_subwords.pth
'
)).
exists
():
continue
print
(
str
(
i
)
+
'
/
'
+
str
(
len
(
lines
))
+
'
==========
'
+
model
+
'
==========
'
)
inpath
=
treebanks
/
model
segmenter
=
Lambo
.
from_path
(
segmenting_path
,
model
)
train_subwords_and_save
(
'
LAMBO-BILSTM
'
,
treebanks
/
model
,
outpath
,
segmenter
,
epochs
=
20
)
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