-
Notifications
You must be signed in to change notification settings - Fork 143
python bindings #948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
python bindings #948
Changes from all commits
a6d6073
1f6a883
696b21a
2e3cb4f
0d648bb
b656975
11cfa21
351eb35
f03c369
820bef1
e52f7d1
e5cc7c4
90919ef
bc48bf8
3bff35e
52f1d6f
b1eedce
efdc157
703643a
4fd32cc
792630c
5fb41b9
b8b8522
ba28c92
1073489
37f8a07
3ad4ac7
d2aef2a
104bc73
27f8221
4de8da0
a52db82
e7fd6b4
ba9ba07
d27b6b4
ccabd9e
10f238f
cc8e323
92303fc
55be37f
b3d61fe
591a6be
6e29b50
d7aeaa2
63dc4a2
5b9db4d
75ece83
ccb3353
a4b9168
b3226a8
4741b4e
fedaac7
b9929ec
b9e0acb
4d291db
15a0582
f76a9e9
87f8b12
7a05ce7
2441097
f1c41a4
72cc9ff
ab238e8
958e7de
4cbe320
45dc2ed
b857b07
b6e110a
d4c9d08
c90f42c
5fbe03e
3ced0ef
54be85f
bbfd305
2ae7bab
183dde2
5b1b758
4c7339e
612498c
8e1ef4b
033657a
38ed661
4d527a2
737f852
9c3e0c4
e7844c6
6eebba5
30eee61
0bc2ad9
e7e8de0
b2bbc9b
3620316
87e31e6
9bed4f9
dfd8ecb
9181d87
cd6984e
ce0fe7f
ed88f1d
7ca3005
1b9489c
e0ba10f
c48227f
b349d8b
50d7332
0e63804
5b91cf7
15e87fe
b1c871a
2ccc541
4199d37
3599f09
b398263
3d8c64b
08c4ef0
87ff8ad
4661fa9
2c5863c
4b9588f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -115,6 +115,7 @@ jobs: | |
| -DCOMPILE_CPU=${{ matrix.cpu }} \ | ||
| -DCOMPILE_CUDA=${{ matrix.gpu }} \ | ||
| -DCOMPILE_EXAMPLES=${{ matrix.examples }} \ | ||
| -DUSE_TCMALLOC=OFF \ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Python bindings doesn't work with TCMalloc? Why? Would be great to have it fixed or at least commented/documented. |
||
| -DCOMPILE_SERVER=on \ | ||
| -DCOMPILE_TESTS=${{ matrix.unit_tests }} \ | ||
| -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-${{ matrix.cuda }} \ | ||
|
|
@@ -139,7 +140,18 @@ jobs: | |
| run: | | ||
| ./marian --version | ||
| ./marian-decoder --version | ||
| ./marian-scorer --version | ||
| ./marian-server --version | ||
| ./spm_encode --version | ||
|
Comment on lines
-142
to
-144
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above, why do we need to remove these checks? |
||
| ls -hlv $(find . -maxdepth 1 -type f -executable \( -name "marian*" -o -name "spm*" \)) | ||
|
|
||
|
|
||
| - name: Install PyMarian | ||
| working-directory: build | ||
| env: | ||
| CUDA_VERSION: ${{ matrix.cuda }} | ||
| run: | | ||
| python3 -m venv .venv && source .venv/bin/activate | ||
| python3 -m pip install -U setuptools wheel | ||
| python3 -m pip install pybind11 sentencepiece scikit-build | ||
| cd ../src/python | ||
| python3 setup.py build -j2 install | ||
| cd ../../ | ||
| python3 -c "from pymarian import Translator" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -134,4 +134,20 @@ jobs: | |
| .\marian-decoder.exe --version | ||
| .\marian-scorer.exe --version | ||
| dir *.exe | ||
| cd .. | ||
| rd /s /q build | ||
|
Comment on lines
+137
to
+138
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this for debugging? I would suggest adding a short comment above explaining what it does and why it is done. |
||
| shell: cmd | ||
|
|
||
| - name: Install PyMarian | ||
| working-directory: src/python | ||
| run: | | ||
| python3 -m venv .venv | ||
| .venv\Scripts\activate.bat | ||
| python3 -m pip install -U setuptools wheel | ||
| python3 -m pip install pybind11 sentencepiece scikit-build | ||
| python3 setup.py install -j2 | ||
| cd ..\..\ | ||
| python3 -c "from pymarian import Translator" | ||
| env: | ||
| CUDA_VERSION: ${{ matrix.cuda }} | ||
| shell: cmd | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,3 @@ | ||||||||
| # Config files from CMake | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this comment is still valid, isn't it? |
||||||||
| src/common/project_version.h | ||||||||
| src/common/git_revision.h | ||||||||
| src/common/build_info.cpp | ||||||||
|
|
@@ -61,4 +60,10 @@ examples/mnist/*ubyte | |||||||
| /vs/MarianDll.VC.VC.opendb | ||||||||
|
|
||||||||
| .vs | ||||||||
| .vscode | ||||||||
| .vscode | ||||||||
|
|
||||||||
| src/python/build/ | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: consider adding a comment above explaining that group of excluded files, for example:
Suggested change
|
||||||||
| src/python/dist/ | ||||||||
| src/python/_skbuild/ | ||||||||
| src/python/pymarian.egg-info/ | ||||||||
| src/python/bench/*.txt | ||||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,13 +1,17 @@ | ||||||||
|
|
||||||||
| include_directories(.) | ||||||||
|
|
||||||||
| add_subdirectory(./yaml-cpp) | ||||||||
| add_subdirectory(./SQLiteCpp) | ||||||||
| add_subdirectory(./pathie-cpp) | ||||||||
| add_subdirectory(./zlib) | ||||||||
| add_subdirectory(./faiss) | ||||||||
| add_subdirectory(./yaml-cpp EXCLUDE_FROM_ALL) | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I believe it's worth explicitly mentioning what this flag does in a comment:
Suggested change
|
||||||||
| add_subdirectory(./SQLiteCpp EXCLUDE_FROM_ALL) | ||||||||
| add_subdirectory(./pathie-cpp EXCLUDE_FROM_ALL) | ||||||||
| add_subdirectory(./zlib EXCLUDE_FROM_ALL) | ||||||||
| add_subdirectory(./faiss EXCLUDE_FROM_ALL) | ||||||||
| include_directories(./faiss) | ||||||||
|
|
||||||||
| # if(SKBUILD) | ||||||||
| # add_subdirectory(./pybind11 EXCLUDE_FROM_ALL) | ||||||||
| # endif(SKBUILD) | ||||||||
|
|
||||||||
|
Comment on lines
+11
to
+14
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it was a temporary code only, we should remove it.
Suggested change
|
||||||||
| if(COMPILE_CPU) | ||||||||
| if(NOT GENERATE_MARIAN_INSTALL_TARGETS) | ||||||||
| set(INTGEMM_DONT_BUILD_TESTS ON CACHE BOOL "Disable intgemm tests") | ||||||||
|
|
@@ -42,7 +46,7 @@ if(USE_FBGEMM) | |||||||
|
|
||||||||
| set(FBGEMM_BUILD_TESTS OFF CACHE BOOL "Disable fbgemm tests") | ||||||||
| set(FBGEMM_BUILD_BENCHMARKS OFF CACHE BOOL "Disable fbgemm benchmark") | ||||||||
| add_subdirectory(./fbgemm) | ||||||||
| add_subdirectory(./fbgemm EXCLUDE_FROM_ALL) | ||||||||
|
|
||||||||
| # asmjit (3rd-party submodule of fbgemm) sets -Wall -Wextra near the end of | ||||||||
| # the compile options, invalidating any -Wno-... flags that we may have set | ||||||||
|
|
@@ -72,15 +76,19 @@ if(USE_SENTENCEPIECE) | |||||||
|
|
||||||||
| # regardless of -DUSE_STATIC_LIBS setting always build sentencepiece statically | ||||||||
| set(SPM_ENABLE_SHARED OFF CACHE BOOL "Builds shared libaries in addition to static libraries." FORCE) | ||||||||
| set(SPM_ENABLE_TCMALLOC ON CACHE BOOL "Enable TCMalloc if available.") | ||||||||
|
|
||||||||
| if(USE_STATIC_LIBS) | ||||||||
| set(SPM_TCMALLOC_STATIC ON CACHE BOOL "Link static library of TCMALLOC." FORCE) | ||||||||
| else(USE_STATIC_LIBS) | ||||||||
| set(SPM_TCMALLOC_STATIC OFF CACHE BOOL "Link static library of TCMALLOC.") | ||||||||
| endif(USE_STATIC_LIBS) | ||||||||
|
|
||||||||
| add_subdirectory(./sentencepiece) | ||||||||
| if(USE_TCMALLOC) | ||||||||
| set(SPM_ENABLE_TCMALLOC ON CACHE BOOL "Enable TCMalloc if available.") | ||||||||
| if(USE_STATIC_LIBS) | ||||||||
| set(SPM_TCMALLOC_STATIC ON CACHE BOOL "Link static library of TCMALLOC." FORCE) | ||||||||
| else(USE_STATIC_LIBS) | ||||||||
| set(SPM_TCMALLOC_STATIC OFF CACHE BOOL "Link static library of TCMALLOC.") | ||||||||
| endif(USE_STATIC_LIBS) | ||||||||
| else(USE_TCMALLOC) | ||||||||
| set(SPM_ENABLE_TCMALLOC OFF CACHE BOOL "Enable TCMalloc if available.") | ||||||||
| endif(USE_TCMALLOC) | ||||||||
|
|
||||||||
| add_subdirectory(./sentencepiece EXCLUDE_FROM_ALL) | ||||||||
|
erip marked this conversation as resolved.
|
||||||||
| include_directories(./sentencepiece) | ||||||||
|
|
||||||||
| set_target_properties(spm_encode spm_decode spm_train spm_normalize spm_export_vocab | ||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,9 @@ include_directories(.) | |||||||||||||||||||||
| include_directories(3rd_party) | ||||||||||||||||||||||
| include_directories(3rd_party/SQLiteCpp/include) | ||||||||||||||||||||||
| include_directories(3rd_party/sentencepiece) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| include_directories(3rd_party/pybind11/include) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if(USE_SENTENCEPIECE) | ||||||||||||||||||||||
| include_directories(3rd_party/sentencepiece/third_party/protobuf-lite) | ||||||||||||||||||||||
| endif(USE_SENTENCEPIECE) | ||||||||||||||||||||||
|
|
@@ -255,11 +258,11 @@ if (NOT COMPILE_LIBRARY_ONLY) | |||||||||||||||||||||
| endif(COMPILE_SERVER) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| foreach(exec ${EXECUTABLES}) | ||||||||||||||||||||||
| target_link_libraries(${exec} marian) | ||||||||||||||||||||||
| if(CUDA_FOUND) | ||||||||||||||||||||||
| target_link_libraries(${exec} marian_cuda) | ||||||||||||||||||||||
| endif(CUDA_FOUND) | ||||||||||||||||||||||
| set_target_properties(${exec} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") | ||||||||||||||||||||||
| target_link_libraries(${exec} marian) | ||||||||||||||||||||||
| if(CUDA_FOUND) | ||||||||||||||||||||||
| target_link_libraries(${exec} marian_cuda) | ||||||||||||||||||||||
| endif(CUDA_FOUND) | ||||||||||||||||||||||
| set_target_properties(${exec} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") | ||||||||||||||||||||||
|
Comment on lines
+261
to
+265
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reverting the removal of line indentations:
Suggested change
|
||||||||||||||||||||||
| endforeach(exec) | ||||||||||||||||||||||
| endif(NOT COMPILE_LIBRARY_ONLY) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
@@ -277,9 +280,31 @@ endif(COMPILE_EXAMPLES) | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| if(GENERATE_MARIAN_INSTALL_TARGETS) | ||||||||||||||||||||||
| # Install the marian library if given a "make install" target | ||||||||||||||||||||||
| include(GNUInstallDirs) # This defines default values for installation directories (all platforms even if named GNU) | ||||||||||||||||||||||
| include(GNUInstallDirs) # This defines default values for installation directories (all platforms even if named GNU) | ||||||||||||||||||||||
| install(TARGETS marian | ||||||||||||||||||||||
| EXPORT marian-targets | ||||||||||||||||||||||
| ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| endif(GENERATE_MARIAN_INSTALL_TARGETS) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if(SKBUILD) | ||||||||||||||||||||||
| # Scikit-Build does not add your site-packages to the search path | ||||||||||||||||||||||
| # automatically, so we need to add it _or_ the pybind11 specific directory | ||||||||||||||||||||||
| # here. | ||||||||||||||||||||||
| execute_process( | ||||||||||||||||||||||
| COMMAND "${PYTHON_EXECUTABLE}" -c | ||||||||||||||||||||||
| "import pybind11; print(pybind11.get_cmake_dir())" | ||||||||||||||||||||||
| OUTPUT_VARIABLE _tmp_dir | ||||||||||||||||||||||
| OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ECHO STDOUT) | ||||||||||||||||||||||
| list(APPEND CMAKE_PREFIX_PATH "${_tmp_dir}") | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Now we can find pybind11 | ||||||||||||||||||||||
| find_package(pybind11 CONFIG REQUIRED) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| pybind11_add_module(pymarian MODULE python/pymarian/bind.cpp) | ||||||||||||||||||||||
| target_link_libraries(pymarian PUBLIC marian) | ||||||||||||||||||||||
| if(CUDA_FOUND) | ||||||||||||||||||||||
| target_link_libraries(pymarian PUBLIC marian_cuda) | ||||||||||||||||||||||
| endif(CUDA_FOUND) | ||||||||||||||||||||||
| install(TARGETS pymarian DESTINATION .) | ||||||||||||||||||||||
| endif(SKBUILD) | ||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -276,12 +276,22 @@ std::vector<DeviceId> Config::getDevices(Ptr<Options> options, | |
| return devices; | ||
| } | ||
|
|
||
| Ptr<Options> | ||
| parseOptions(int argc, char** argv, cli::mode mode, bool validate){ | ||
| Ptr<Options> parseOptions(int argc, char** argv, cli::mode mode, bool validate) { | ||
| ConfigParser cp(mode); | ||
| return cp.parseOptions(argc, argv, validate); | ||
| } | ||
|
|
||
| Ptr<Options> parseOptions(const std::string& args, cli::mode mode, bool validate) { | ||
| std::vector<std::string> vArgs = utils::split(args, " "); | ||
|
|
||
| std::string dummy("dummy"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: having a dummy string is a bit confusing at a first glance, can we simplify these couple of lines to make them more readable or add a comment? |
||
| std::vector<char*> cArgs = { &dummy[0] }; | ||
| for(auto& arg : vArgs) | ||
| cArgs.push_back(&arg[0]); | ||
|
|
||
| return parseOptions((int)cArgs.size(), cArgs.data(), mode, validate); | ||
| } | ||
|
|
||
| std::ostream& operator<<(std::ostream& out, const Config& config) { | ||
| YAML::Emitter outYaml; | ||
| cli::OutputYaml(config.get(), outYaml); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,11 +26,13 @@ std::shared_ptr<spdlog::logger> createStderrLogger(const std::string& name, | |
| const std::string& pattern, | ||
| const std::vector<std::string>& files, | ||
| bool quiet) { | ||
| std::vector<spdlog::sink_ptr> sinks; | ||
| auto logger = spdlog::get(name); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I believe this could deserve a short comment why it's done. |
||
| if(!logger) { | ||
| std::vector<spdlog::sink_ptr> sinks; | ||
|
|
||
| auto stderr_sink = spdlog::sinks::stderr_sink_mt::instance(); | ||
| if(!quiet) | ||
| sinks.push_back(stderr_sink); | ||
| auto stderr_sink = spdlog::sinks::stderr_sink_mt::instance(); | ||
| if(!quiet) | ||
| sinks.push_back(stderr_sink); | ||
|
|
||
| // @TODO: think how to solve this better than using OMPI_COMM_WORLD_RANK env variable | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: these lines also need an extra indentation |
||
| // only create output files if we are the main process or if MPI rank is not defined | ||
|
|
@@ -42,10 +44,11 @@ std::shared_ptr<spdlog::logger> createStderrLogger(const std::string& name, | |
| } | ||
| } | ||
|
|
||
| auto logger = std::make_shared<spdlog::logger>(name, begin(sinks), end(sinks)); | ||
| logger = std::make_shared<spdlog::logger>(name, begin(sinks), end(sinks)); | ||
|
|
||
| spdlog::register_logger(logger); | ||
| logger->set_pattern(pattern); | ||
| spdlog::register_logger(logger); | ||
| logger->set_pattern(pattern); | ||
| } | ||
| return logger; | ||
| } | ||
|
|
||
|
|
@@ -72,6 +75,7 @@ bool setLoggingLevel(spdlog::logger& logger, std::string const level) { | |
| } | ||
|
|
||
| static void setErrorHandlers(); | ||
|
|
||
| void createLoggers(const marian::Config* config) { | ||
| std::vector<std::string> generalLogs; | ||
| std::vector<std::string> validLogs; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ struct ModelTask { | |
|
|
||
| struct ModelServiceTask { | ||
| virtual ~ModelServiceTask() {} | ||
| virtual std::string run(const std::string&) = 0; | ||
| virtual std::string run(const std::string&, const std::string&) = 0; | ||
| virtual std::vector<std::string> run(const std::vector<std::string>&, const std::string&) = 0; | ||
|
Comment on lines
+14
to
+15
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add docstrings describing function parameters. |
||
| }; | ||
| } // namespace marian | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,20 @@ | ||||||
| Stuff required to build module (on Linux) | ||||||
| ``` | ||||||
| python3 -m venv ./venv | ||||||
| source ./venv/bin/activate | ||||||
| python -mpip install sentencepiece scikit-build pybind11 | ||||||
| ``` | ||||||
|
|
||||||
| Stuff required to run windowed demo | ||||||
| ``` | ||||||
| python -mpip install pyqt5 sacremoses git+https://github.com/mediacloud/sentence-splitter | ||||||
| ``` | ||||||
|
|
||||||
| Build the module (CPU version) | ||||||
| ``` | ||||||
| python setup.py build -j16 install | ||||||
| ``` | ||||||
|
|
||||||
| ``` | ||||||
| echo "Hello World." | python test_translate.py '--config /home/marcinjd/MTMA/decoder.yml' /home/marcinjd/MTMA/source.spm /home/marcinjd/MTMA/target.spm | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove hard-coded paths:
Suggested change
|
||||||
| ``` | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # | ||
|
|
||
| Install pymarian then | ||
|
|
||
| ```sh | ||
| pip install torch --extra-index-url https://download.pytorch.org/whl/cu113 | ||
| pip install transformers parallelformers sentencepiece sacrebleu | ||
| ``` | ||
|
|
||
| To run the benchmark, | ||
|
|
||
| ```sh | ||
| bash benchmark.sh | ||
| ``` |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,28 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
| #!/usr/bin/env sh | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding a short comment at the top of this file what this script does and a simple usage example. |
||||||||||||||||||||||||||||||||||||||||||||||
| function translate_native { | ||||||||||||||||||||||||||||||||||||||||||||||
| sacrebleu -t wmt20 -l en-de --echo src | \ | ||||||||||||||||||||||||||||||||||||||||||||||
| spm_encode --model /home/marcinjd/MTMA/source.spm | ../_skbuild/linux-x86_64-3.8/cmake-build/marian-decoder --quiet \ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the path |
||||||||||||||||||||||||||||||||||||||||||||||
| -c /home/marcinjd/MTMA/decoder.yml -b4 --mini-batch 16 --maxi-batch 100 -d 0 1 2 3 \ | ||||||||||||||||||||||||||||||||||||||||||||||
| | spm_decode --model /home/marcinjd/MTMA/target.spm > translations_native.txt | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| function translate_pybind { | ||||||||||||||||||||||||||||||||||||||||||||||
| sacrebleu -t wmt20 -l en-de --echo src | \ | ||||||||||||||||||||||||||||||||||||||||||||||
| spm_encode --model /home/marcinjd/MTMA/source.spm | \ | ||||||||||||||||||||||||||||||||||||||||||||||
| python test_translate.py '--config /home/marcinjd/MTMA/decoder.yml -b4 --mini-batch 16 --quiet --maxi-batch 100 -d 0 1 2 3' \ | ||||||||||||||||||||||||||||||||||||||||||||||
| | spm_decode --model /home/marcinjd/MTMA/target.spm > translations_pybind.txt | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+4
to
+14
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above, let's remove hard-coded paths:
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| function translate_hf_native { | ||||||||||||||||||||||||||||||||||||||||||||||
| sacrebleu -t wmt20 -l en-de --echo src | python test_hf_raw.py > translations_hf_raw.txt | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| echo -n "Native: " | ||||||||||||||||||||||||||||||||||||||||||||||
| time translate_native | ||||||||||||||||||||||||||||||||||||||||||||||
| echo | ||||||||||||||||||||||||||||||||||||||||||||||
| echo -n "Pybind: " | ||||||||||||||||||||||||||||||||||||||||||||||
| time translate_pybind | ||||||||||||||||||||||||||||||||||||||||||||||
| echo | ||||||||||||||||||||||||||||||||||||||||||||||
| echo -n "Transformers (native): " | ||||||||||||||||||||||||||||||||||||||||||||||
| time translate_hf_native | ||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the motivation for this to get removed?