Spaces:
Sleeping
Sleeping
zyu
commited on
Commit
·
40e17e4
1
Parent(s):
3e1656e
fix path issues
Browse files- .gitignore +176 -0
- app.py +6 -16
- dataset_and_model_info.json +3 -3
.gitignore
ADDED
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Created by https://www.toptal.com/developers/gitignore/api/python
|
2 |
+
# Edit at https://www.toptal.com/developers/gitignore?templates=python
|
3 |
+
|
4 |
+
### Python ###
|
5 |
+
# Byte-compiled / optimized / DLL files
|
6 |
+
__pycache__/
|
7 |
+
*.py[cod]
|
8 |
+
*$py.class
|
9 |
+
|
10 |
+
# C extensions
|
11 |
+
*.so
|
12 |
+
|
13 |
+
# Distribution / packaging
|
14 |
+
.Python
|
15 |
+
build/
|
16 |
+
develop-eggs/
|
17 |
+
dist/
|
18 |
+
downloads/
|
19 |
+
eggs/
|
20 |
+
.eggs/
|
21 |
+
lib/
|
22 |
+
lib64/
|
23 |
+
parts/
|
24 |
+
sdist/
|
25 |
+
var/
|
26 |
+
wheels/
|
27 |
+
share/python-wheels/
|
28 |
+
*.egg-info/
|
29 |
+
.installed.cfg
|
30 |
+
*.egg
|
31 |
+
MANIFEST
|
32 |
+
|
33 |
+
# PyInstaller
|
34 |
+
# Usually these files are written by a python script from a template
|
35 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
36 |
+
*.manifest
|
37 |
+
*.spec
|
38 |
+
|
39 |
+
# Installer logs
|
40 |
+
pip-log.txt
|
41 |
+
pip-delete-this-directory.txt
|
42 |
+
|
43 |
+
# Unit test / coverage reports
|
44 |
+
htmlcov/
|
45 |
+
.tox/
|
46 |
+
.nox/
|
47 |
+
.coverage
|
48 |
+
.coverage.*
|
49 |
+
.cache
|
50 |
+
nosetests.xml
|
51 |
+
coverage.xml
|
52 |
+
*.cover
|
53 |
+
*.py,cover
|
54 |
+
.hypothesis/
|
55 |
+
.pytest_cache/
|
56 |
+
cover/
|
57 |
+
|
58 |
+
# Translations
|
59 |
+
*.mo
|
60 |
+
*.pot
|
61 |
+
|
62 |
+
# Django stuff:
|
63 |
+
*.log
|
64 |
+
local_settings.py
|
65 |
+
db.sqlite3
|
66 |
+
db.sqlite3-journal
|
67 |
+
|
68 |
+
# Flask stuff:
|
69 |
+
instance/
|
70 |
+
.webassets-cache
|
71 |
+
|
72 |
+
# Scrapy stuff:
|
73 |
+
.scrapy
|
74 |
+
|
75 |
+
# Sphinx documentation
|
76 |
+
docs/_build/
|
77 |
+
|
78 |
+
# PyBuilder
|
79 |
+
.pybuilder/
|
80 |
+
target/
|
81 |
+
|
82 |
+
# Jupyter Notebook
|
83 |
+
.ipynb_checkpoints
|
84 |
+
|
85 |
+
# IPython
|
86 |
+
profile_default/
|
87 |
+
ipython_config.py
|
88 |
+
|
89 |
+
# pyenv
|
90 |
+
# For a library or package, you might want to ignore these files since the code is
|
91 |
+
# intended to run in multiple environments; otherwise, check them in:
|
92 |
+
# .python-version
|
93 |
+
|
94 |
+
# pipenv
|
95 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
96 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
97 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
98 |
+
# install all needed dependencies.
|
99 |
+
#Pipfile.lock
|
100 |
+
|
101 |
+
# poetry
|
102 |
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
103 |
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
104 |
+
# commonly ignored for libraries.
|
105 |
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
106 |
+
#poetry.lock
|
107 |
+
|
108 |
+
# pdm
|
109 |
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
110 |
+
#pdm.lock
|
111 |
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
112 |
+
# in version control.
|
113 |
+
# https://pdm.fming.dev/#use-with-ide
|
114 |
+
.pdm.toml
|
115 |
+
|
116 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
117 |
+
__pypackages__/
|
118 |
+
|
119 |
+
# Celery stuff
|
120 |
+
celerybeat-schedule
|
121 |
+
celerybeat.pid
|
122 |
+
|
123 |
+
# SageMath parsed files
|
124 |
+
*.sage.py
|
125 |
+
|
126 |
+
# Environments
|
127 |
+
.env
|
128 |
+
.venv
|
129 |
+
env/
|
130 |
+
venv/
|
131 |
+
ENV/
|
132 |
+
env.bak/
|
133 |
+
venv.bak/
|
134 |
+
|
135 |
+
# Spyder project settings
|
136 |
+
.spyderproject
|
137 |
+
.spyproject
|
138 |
+
|
139 |
+
# Rope project settings
|
140 |
+
.ropeproject
|
141 |
+
|
142 |
+
# mkdocs documentation
|
143 |
+
/site
|
144 |
+
|
145 |
+
# mypy
|
146 |
+
.mypy_cache/
|
147 |
+
.dmypy.json
|
148 |
+
dmypy.json
|
149 |
+
|
150 |
+
# Pyre type checker
|
151 |
+
.pyre/
|
152 |
+
|
153 |
+
# pytype static type analyzer
|
154 |
+
.pytype/
|
155 |
+
|
156 |
+
# Cython debug symbols
|
157 |
+
cython_debug/
|
158 |
+
|
159 |
+
# PyCharm
|
160 |
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
161 |
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
162 |
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
163 |
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
164 |
+
.idea/
|
165 |
+
|
166 |
+
### Python Patch ###
|
167 |
+
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
|
168 |
+
poetry.toml
|
169 |
+
|
170 |
+
# ruff
|
171 |
+
.ruff_cache/
|
172 |
+
|
173 |
+
# LSP config files
|
174 |
+
pyrightconfig.json
|
175 |
+
|
176 |
+
# End of https://www.toptal.com/developers/gitignore/api/python
|
app.py
CHANGED
@@ -45,13 +45,6 @@ def hold_deterministic(seed):
|
|
45 |
|
46 |
|
47 |
def main():
|
48 |
-
# st.title("Privalingo Playground Demo")
|
49 |
-
# html_temp = """
|
50 |
-
# <div style="background:#025246 ;padding:10px">
|
51 |
-
# <h2 style="color:white;text-align:center;">Playground Demo </h2>
|
52 |
-
# </div>
|
53 |
-
# """
|
54 |
-
# st.markdown(html_temp, unsafe_allow_html=True)
|
55 |
hold_deterministic(SEED)
|
56 |
|
57 |
st.title("Neural Machine Translation with DP-SGD")
|
@@ -71,15 +64,13 @@ def main():
|
|
71 |
|
72 |
st_model_load = st.text(f'Loading model trained on {dataset} with epsilon {epsilon}...')
|
73 |
|
74 |
-
|
75 |
-
model_name = MODEL.split('/')[-1]
|
76 |
-
model_path = os.path.join(CHECKPOINTS_DIR, ckpt, model_name)
|
77 |
|
78 |
if not os.path.exists(model_path):
|
79 |
-
st.error(f"Model not found. Use {
|
80 |
-
model_path =
|
81 |
|
82 |
-
model, tokenizer = load_model(model_path, tokenizer_name=
|
83 |
st.success('Model loaded!')
|
84 |
st_model_load.text("")
|
85 |
|
@@ -92,10 +83,9 @@ def main():
|
|
92 |
|
93 |
|
94 |
if __name__ == '__main__':
|
95 |
-
DATASETS_MODEL_INFO_PATH = os.getcwd()
|
96 |
-
CHECKPOINTS_DIR = os.getcwd() + "/checkpoints"
|
97 |
DATASETS_MODEL_INFO = load_json(DATASETS_MODEL_INFO_PATH)
|
98 |
-
|
99 |
|
100 |
MAX_SEQ_LEN = 512
|
101 |
NUM_BEAMS = 3
|
|
|
45 |
|
46 |
|
47 |
def main():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
hold_deterministic(SEED)
|
49 |
|
50 |
st.title("Neural Machine Translation with DP-SGD")
|
|
|
64 |
|
65 |
st_model_load = st.text(f'Loading model trained on {dataset} with epsilon {epsilon}...')
|
66 |
|
67 |
+
model_path = DATASETS_MODEL_INFO[dataset]['languages pairs'][language_pair]['epsilon'][str(epsilon)]
|
|
|
|
|
68 |
|
69 |
if not os.path.exists(model_path):
|
70 |
+
st.error(f"Model not found. Use {DEFAULT_MODEL} instead")
|
71 |
+
model_path = DEFAULT_MODEL
|
72 |
|
73 |
+
model, tokenizer = load_model(model_path, tokenizer_name=DEFAULT_MODEL)
|
74 |
st.success('Model loaded!')
|
75 |
st_model_load.text("")
|
76 |
|
|
|
83 |
|
84 |
|
85 |
if __name__ == '__main__':
|
86 |
+
DATASETS_MODEL_INFO_PATH = os.path.join(os.getcwd(), "dataset_and_model_info.json")
|
|
|
87 |
DATASETS_MODEL_INFO = load_json(DATASETS_MODEL_INFO_PATH)
|
88 |
+
DEFAULT_MODEL = 'google/mt5-small'
|
89 |
|
90 |
MAX_SEQ_LEN = 512
|
91 |
NUM_BEAMS = 3
|
dataset_and_model_info.json
CHANGED
@@ -3,9 +3,9 @@
|
|
3 |
"languages pairs": {
|
4 |
"German-English": {
|
5 |
"epsilon": {
|
6 |
-
"1": "
|
7 |
-
"5": "
|
8 |
-
"non": "
|
9 |
}
|
10 |
}
|
11 |
}
|
|
|
3 |
"languages pairs": {
|
4 |
"German-English": {
|
5 |
"epsilon": {
|
6 |
+
"1": "MarcoYuTono/privalingo-WMT-de-en-eps1",
|
7 |
+
"5": "MarcoYuTono/privalingo-WMT-de-en-eps5",
|
8 |
+
"non": "MarcoYuTono/privalingo-WMT-de-en-infinite"
|
9 |
}
|
10 |
}
|
11 |
}
|