Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Japanese-Dialog-Transformerの応答候補に対して、KenLMによるN-gram言語モデルでスコアリングし、フィルタリング若しくはリランキングを行う。

License

NotificationsYou must be signed in to change notification settings

TUT-SLP-lab/JDT-with-KenLM-scoring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Japanese-Dialog-Transformerの応答候補に対して、KenLMによるN-gram言語モデルでスコアリングし、フィルタリング若しくはリランキングを行う。スコアリングの性能だけ見たい場合は、依存ライブラリのインストールを行い本プログラム群をダウンロードし、scoringディレクトリ下でREADME.md最下部のコマンドを実行してください。

https://github.com/nttcslab/japanese-dialog-transformers

model(checkpoint)は上記のURLの通りにお願いします。

KenLMのインストール

適当なディレクトリに移動後以下のコマンドを実行する。

sudo apt-get install build-essential libboost-all-dev cmake zlib1g-dev libbz2-dev liblzma-devwget -O - https://kheafield.com/code/kenlm.tar.gz |tar xzmkdir kenlm/buildcd kenlm/buildcmake ..make -j2

Anaconda環境で使用する際には、仮想環境を立ち上げた上でkenlm下にあるsetup.pyを以下のコマンドにて実行する必要がある。

python setup.py install

Usage

ntt の Japapanese-Dialog-Transformer/scripts に内容物をコピー。scripts内で以下のLinuxコマンドを実行する。

MeCab + unidic-csj-3.0.1.1のダウンロード

apt-get install -y mecab libmecab-devpip install mecab-python3cd scoringwget https://clrd.ninjal.ac.jp/unidic_archive/csj/3.0.1.1/unidic-csj-3.0.1.1.zipunzip unidic-csj-3.0.1.1.zip

bccwj-csj-np.3g.kn.gzのダウンロード

mkdir models & cd modelspip install gdowngdown --id 1P642KJRMUdXX3t2g3MQZnZ9BGovTLKiEgunzip bccwj-csj-np.3g.kn.gzmv bccwj-csj-np.3g.kn bccwj-csj-np.bin

Run

Japanese-Dialog-Transformer ディレクトリ下に移動し以下を実行する。

python scripts/dialog.py data/sample/bin/  --path checkpoints/japanese-dialog-transformer-1.6B.pt  --beam 80  --min-len 10  --source-lang src  --target-lang dst  --tokenizer space  --bpe sentencepiece  --sentencepiece-model data/dicts/sp_oall_32k.model  --no-repeat-ngram-size 3  --nbest 80  --sampling  --sampling-topp 0.9  --temperature 1.0  --show-nbest 5  --filter-type depth-harmonic  --filter-threshold -4.8  --used-ngram-model scripts/scoring/models/bccwj-csj-np.bin  --display-ngram-score  --display-modified-ngram  --starting-phrase 松丸さんはお休みは何をしてますか?

もし、N-gram言語モデルによるリランキングを行う場合はオプションに以下を追加する。

--ngram-reranking

新たに三河が追加した引数は以下の通り。

  --filter-type FILTER_TYPE                        application KenLM filter  --filter-threshold FILTER_THRESHOLD                        threshold of filter  --used-ngram-model USED_NGRAM_MODEL                        n-gram model for KenLM scoring  --display-ngram-score                        display n-gram score by KenLM  --ngram-reranking     re-ranking by n-gram score  --remove-contain-oov  remove sentence which hava oov word  --display-modified-ngram                        display moified ngram analisys

Scoring-Test

scoring ディレクトリ下に移動し以下を実行する。

python scripts/scoring/scoring_test.py --filter-type depth-harmonic --filter-threshold -1.5 --used-ngram-model scripts/scoring/models/bccwj-csj-np.bin --display-ngram-score --remove-contain-oov

このソースコードはscore_sentence.py内に存在する関数を試験するためのものである。

About

Japanese-Dialog-Transformerの応答候補に対して、KenLMによるN-gram言語モデルでスコアリングし、フィルタリング若しくはリランキングを行う。

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp