ぷるーふおぶこんせぷと で公開した機械翻訳エンジンを利用する翻訳環境です。 フォームに入力された文字列の翻訳、PDFの翻訳が可能です。
あくまで検証用の環境・ソフトウェアであり、公開サーバ上での実行を想定したものではありません。 (上記BLOGで公開されているWEB環境で用いているソフトウェアではありません。)
Dockerがセットアップされている場合、下記のように実行できます。
git clone http://github.com/s-taka/fugumtwget https://fugumt.com/FuguMT_ver.202011.1.zipshasum FuguMT_ver.202011.1.zip
unzip FuguMT_ver.202011.1.zipmv model/* fugumt/modelcd fugumt/dockerdocker build -t fugu_mt .docker run -v /path_to/fugumt/:/app/fugu_mt -p 127.0.0.1:8888:8080 -it --user `id -u`:`id -g` --rm fugu_mt python3 /app/fugu_mt/run.py /app/fugu_mt/config.json実行後、http://localhost:8888/ にアクセスすることで翻訳エンジンを利用可能です。
http://localhost:8888/pdf_upload/ からPDFの翻訳を行うことができます。 パスワードはconfig.jsonの"auth_info"から設定可能です。 デフォルトではpdf/pdfとなっています。
本ソフトウェアは信頼できるネットワーク上での実行を前提に利用してください。
翻訳サーバの実行の2.まで構築が終わっていれば、環境変数を設定し、コマンドラインからPDFを翻訳することもできます。
Dockerコンテナ起動
docker run -v /path_to/fugumt/:/app/fugu_mt -it --user `id -u`:`id -g` --rm fugu_mt bash環境変数を設定、カレントディレクトリの変更
export TFHUB_CACHE_DIR=/app/fugu_mt/cache/
export NLTK_DATA=/app/fugu_mt/cache/
export ALLENNLP_CACHE_ROOT=/app/fugu_mt/cache/
cd /app/fugu_mt/
python3 /app/fugu_mt/pdf_server.py --pdf Dockerコンテナ上のPDFパス --out Dockerコンテナ上のpickle保存場所 --out_html Dockerコンテナ上のHTML保存場所 --mk_process 1 /app/fugu_mt/config.jsonより簡易にモデルを試す場合は以下の手順でテストが可能です。 Docker build、モデルのダウンロードは「翻訳サーバの実行」と同じです。
docker run -v /path_to/fugumt/:/app/fugu_mt -it --user `id -u`:`id -g` --rm fugu_mt bash
cd /app/fugu_mtecho "Fugu MT model" | /app/marian/build/marian-decoder -c model/model.npz.decoder.yml下記のように_uncasedを指定すると、大文字・小文字を無視した翻訳を行います。
echo "Fugu MT model" | /app/marian/build/marian-decoder -c model/model_uncased.npz.decoder.ymlライブラリを通した翻訳は下記のように実行することができます。 Docker build、モデルのダウンロードは「翻訳サーバの実行」と同じです。
export TFHUB_CACHE_DIR=/app/fugu_mt/cache/
export NLTK_DATA=/app/fugu_mt/cache/
export ALLENNLP_CACHE_ROOT=/app/fugu_mt/cache/
# ライブラリをimport
from fugumt.tojpn import FuguJPNTranslator
from fugumt.misc import make_marian_process
from fugumt.misc import close_marian_process
# marian processを作成
marian_processes = make_marian_process("/app/marian/build/marian-server",
[["-p","8001","-c","model/model.npz.decoder.yml", "--log", "log/marian8001.log"]],
[8001])
# 翻訳
fgmt = FuguJPNTranslator([8001])
translated = fgmt.translate_text("This is a Fugu machine translator.")
print(translated)
# marian processをクローズ
close_marian_process(marian_processes)
[{'best_is_norm': 1, # 通常翻訳のスコアが良い場合は1、訳抜け防止モードが良い場合は0
'en': 'This is a Fugu machine translator.', # 入力された英文
'ja_best': 'ふぐ機械翻訳機。', # スコアが一番良かった日本語訳
'ja_best_score': 0.2991045981645584, # 上記スコア
'ja_norm': 'ふぐ機械翻訳機。', # 通常翻訳で一番良かった日本語訳
'ja_norm_score': 0.2991045981645584, # 上記スコア
'ja_parse': 'ふぐ機械翻訳機。', # 訳抜け防止モードで一番良かった日本語訳
'ja_parse_score': 0.2991045981645584 # 上記スコア
}]
本ソフトウェアは下記のライブラリ・ソフトウェアを利用しています。 またDockerfileに記載の通り、ubuntuで使用可能なパッケージを多数使用しています。 OSSとして素晴らしいソフトウェアを公開された方々に感謝いたします。
本ソフトウェアは研究用を目的に公開しています。 作者(Satoshi Takahashi)は本ソフトウェアの動作を保証せず、本ソフトウェアを使用して発生したあらゆる結果について一切の責任を負いません。 本ソフトウェア(Code)はMIT-Licenseです。
モデル作成では上記ソフトウェアに加え、下記のデータセット・ソフトウェアを使用しています。 オープンなライセンスでソフトウェア・データセットを公開された方々に感謝いたします。
Professor Tanaka originally placed the Corpus in the Public Domain, and that status was maintained for the versions used by WWWJDIC. In late 2009 the Tatoeba Project decided to move it to a Creative Commons CC-BY licence (that project is in France, where the concept of public domain is not part of the legal framework.) It can be freely downloaded and used provided the source is attributed.
https://tatoeba.org TatoebaのデータはCC-BY 2.0 FRで提供されています。
ニューラル機械翻訳モデル「FuguMT model 」は 上記に独自収集データを加えMarian-NMT + SentencePieceで作成しています。 モデル構築に使用したデータ量は約660万対訳ペア、V100 GPU 1つを用いて約30時間学習しています。
「FuguMT model ver.202011.1」のライセンスはCC BY-SA 4.0 です。fine tuningを行う場合も本モデルのライセンスに従った取扱いをお願いいたします。 (zipファイル内のreadmeもご確認ください。)
本モデルは研究用を目的に公開しています。 作者(Satoshi Takahashi)は本モデルの動作を保証せず、本モデルを使用して発生したあらゆる結果について一切の責任を負いません。
※ FuguMT model ver.202011.1ではTatoeba、CCAlignedは使用しておらず、ver.202101.1以降のモデルで使用予定です。
※ 出典を書く際はBlogのURL記載またはリンクをお願いします。 https://staka.jp/wordpress/
13 commits
Python
95.9%
Dockerfile
4.1%
ぷるーふおぶこんせぷと で公開した機械翻訳エンジンを利用する翻訳環境です。 フォームに入力された文字列の翻訳、PDFの翻訳が可能です。
あくまで検証用の環境・ソフトウェアであり、公開サーバ上での実行を想定したものではありません。 (上記BLOGで公開されているWEB環境で用いているソフトウェアではありません。)
Dockerがセットアップされている場合、下記のように実行できます。
git clone http://github.com/s-taka/fugumtwget https://fugumt.com/FuguMT_ver.202011.1.zipshasum FuguMT_ver.202011.1.zip
unzip FuguMT_ver.202011.1.zipmv model/* fugumt/modelcd fugumt/dockerdocker build -t fugu_mt .docker run -v /path_to/fugumt/:/app/fugu_mt -p 127.0.0.1:8888:8080 -it --user `id -u`:`id -g` --rm fugu_mt python3 /app/fugu_mt/run.py /app/fugu_mt/config.json実行後、http://localhost:8888/ にアクセスすることで翻訳エンジンを利用可能です。
http://localhost:8888/pdf_upload/ からPDFの翻訳を行うことができます。 パスワードはconfig.jsonの"auth_info"から設定可能です。 デフォルトではpdf/pdfとなっています。
本ソフトウェアは信頼できるネットワーク上での実行を前提に利用してください。
翻訳サーバの実行の2.まで構築が終わっていれば、環境変数を設定し、コマンドラインからPDFを翻訳することもできます。
Dockerコンテナ起動
docker run -v /path_to/fugumt/:/app/fugu_mt -it --user `id -u`:`id -g` --rm fugu_mt bash環境変数を設定、カレントディレクトリの変更
export TFHUB_CACHE_DIR=/app/fugu_mt/cache/
export NLTK_DATA=/app/fugu_mt/cache/
export ALLENNLP_CACHE_ROOT=/app/fugu_mt/cache/
cd /app/fugu_mt/
python3 /app/fugu_mt/pdf_server.py --pdf Dockerコンテナ上のPDFパス --out Dockerコンテナ上のpickle保存場所 --out_html Dockerコンテナ上のHTML保存場所 --mk_process 1 /app/fugu_mt/config.jsonより簡易にモデルを試す場合は以下の手順でテストが可能です。 Docker build、モデルのダウンロードは「翻訳サーバの実行」と同じです。
docker run -v /path_to/fugumt/:/app/fugu_mt -it --user `id -u`:`id -g` --rm fugu_mt bash
cd /app/fugu_mtecho "Fugu MT model" | /app/marian/build/marian-decoder -c model/model.npz.decoder.yml下記のように_uncasedを指定すると、大文字・小文字を無視した翻訳を行います。
echo "Fugu MT model" | /app/marian/build/marian-decoder -c model/model_uncased.npz.decoder.ymlライブラリを通した翻訳は下記のように実行することができます。 Docker build、モデルのダウンロードは「翻訳サーバの実行」と同じです。
export TFHUB_CACHE_DIR=/app/fugu_mt/cache/
export NLTK_DATA=/app/fugu_mt/cache/
export ALLENNLP_CACHE_ROOT=/app/fugu_mt/cache/
# ライブラリをimport
from fugumt.tojpn import FuguJPNTranslator
from fugumt.misc import make_marian_process
from fugumt.misc import close_marian_process
# marian processを作成
marian_processes = make_marian_process("/app/marian/build/marian-server",
[["-p","8001","-c","model/model.npz.decoder.yml", "--log", "log/marian8001.log"]],
[8001])
# 翻訳
fgmt = FuguJPNTranslator([8001])
translated = fgmt.translate_text("This is a Fugu machine translator.")
print(translated)
# marian processをクローズ
close_marian_process(marian_processes)
[{'best_is_norm': 1, # 通常翻訳のスコアが良い場合は1、訳抜け防止モードが良い場合は0
'en': 'This is a Fugu machine translator.', # 入力された英文
'ja_best': 'ふぐ機械翻訳機。', # スコアが一番良かった日本語訳
'ja_best_score': 0.2991045981645584, # 上記スコア
'ja_norm': 'ふぐ機械翻訳機。', # 通常翻訳で一番良かった日本語訳
'ja_norm_score': 0.2991045981645584, # 上記スコア
'ja_parse': 'ふぐ機械翻訳機。', # 訳抜け防止モードで一番良かった日本語訳
'ja_parse_score': 0.2991045981645584 # 上記スコア
}]
本ソフトウェアは下記のライブラリ・ソフトウェアを利用しています。 またDockerfileに記載の通り、ubuntuで使用可能なパッケージを多数使用しています。 OSSとして素晴らしいソフトウェアを公開された方々に感謝いたします。
本ソフトウェアは研究用を目的に公開しています。 作者(Satoshi Takahashi)は本ソフトウェアの動作を保証せず、本ソフトウェアを使用して発生したあらゆる結果について一切の責任を負いません。 本ソフトウェア(Code)はMIT-Licenseです。
モデル作成では上記ソフトウェアに加え、下記のデータセット・ソフトウェアを使用しています。 オープンなライセンスでソフトウェア・データセットを公開された方々に感謝いたします。
Professor Tanaka originally placed the Corpus in the Public Domain, and that status was maintained for the versions used by WWWJDIC. In late 2009 the Tatoeba Project decided to move it to a Creative Commons CC-BY licence (that project is in France, where the concept of public domain is not part of the legal framework.) It can be freely downloaded and used provided the source is attributed.
https://tatoeba.org TatoebaのデータはCC-BY 2.0 FRで提供されています。
ニューラル機械翻訳モデル「FuguMT model 」は 上記に独自収集データを加えMarian-NMT + SentencePieceで作成しています。 モデル構築に使用したデータ量は約660万対訳ペア、V100 GPU 1つを用いて約30時間学習しています。
「FuguMT model ver.202011.1」のライセンスはCC BY-SA 4.0 です。fine tuningを行う場合も本モデルのライセンスに従った取扱いをお願いいたします。 (zipファイル内のreadmeもご確認ください。)
本モデルは研究用を目的に公開しています。 作者(Satoshi Takahashi)は本モデルの動作を保証せず、本モデルを使用して発生したあらゆる結果について一切の責任を負いません。
※ FuguMT model ver.202011.1ではTatoeba、CCAlignedは使用しておらず、ver.202101.1以降のモデルで使用予定です。
※ 出典を書く際はBlogのURL記載またはリンクをお願いします。 https://staka.jp/wordpress/
13 commits
Python
95.9%
Dockerfile
4.1%