NLG (자연 언어 생성)에 대한 다양한 비 감독 자동 메트릭에 대한 평가 코드. 가설 파일을 입력하는 것으로, 하나 이상의 참조는 메트릭의 파일 및 출력 값을 출력합니다. 이 파일의 행은 동일한 예제에 해당해야합니다.
Java 1.8.0 (이상)을 설치하십시오.
파이썬 종속성을 설치하고 실행하십시오.
pip install git+https://github.com/Maluuba/nlg-eval.git@masterMacOS High Sierra 이상을 사용하는 경우 멀티 스레딩을 허용하도록이를 실행하십시오.
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES간단한 설정 (필요한 데이터 다운로드 (예 : 모델, 임베딩) 및 외부 코드 파일), 실행 :
nlg-eval --setup 소스 코드에서 설정하거나 Windows에 있고 Bash 터미널을 사용하지 않는 경우 nlg-eval 대한 오류가 발생하지 않을 수 있습니다. nlg-eval 스크립트를 찾아야합니다. 자세한 내용은 여기를 참조하십시오.
# If you don't like the default path (~/.cache/nlgeval) for the downloaded data,
# then specify a path where you want the files to be downloaded.
# The value for the data path is stored in ~/.config/nlgeval/rc.json and can be overwritten by
# setting the NLGEVAL_DATA environment variable.
nlg-eval --setup ${data_path}(이 예는 창에 git bash로 만들어졌습니다)
모든 데이터 파일이 다운로드 되었으나 다음과 같은 크기가 표시되어야합니다.
$ ls -l ~/.cache/nlgeval/
total 6003048
-rw-r--r-- 1 ... 289340074 Sep 12 2018 bi_skip.npz
-rw-r--r-- 1 ... 689 Sep 12 2018 bi_skip.npz.pkl
-rw-r--r-- 1 ... 2342138474 Sep 12 2018 btable.npy
-rw-r--r-- 1 ... 7996547 Sep 12 2018 dictionary.txt
-rw-r--r-- 1 ... 21494787 Jan 22 2019 glove.6B.300d.model.bin
-rw-r--r-- 1 ... 480000128 Jan 22 2019 glove.6B.300d.model.bin.vectors.npy
-rw-r--r-- 1 ... 663989216 Sep 12 2018 uni_skip.npz
-rw-r--r-- 1 ... 693 Sep 12 2018 uni_skip.npz.pkl
-rw-r--r-- 1 ... 2342138474 Sep 12 2018 utable.npy
일부 체크섬을 확인할 수도 있습니다.
$ cd ~/.cache/nlgeval/
$ md5sum *
9a15429d694a0e035f9ee1efcb1406f3 *bi_skip.npz
c9b86840e1dedb05837735d8bf94cee2 *bi_skip.npz.pkl
022b5b15f53a84c785e3153a2c383df6 *btable.npy
26d8a3e6458500013723b380a4b4b55e *dictionary.txt
f561ab0b379e23cbf827a054f0e7c28e *glove.6B.300d.model.bin
be5553e91156471fe35a46f7dcdfc44e *glove.6B.300d.model.bin.vectors.npy
8eb7c6948001740c3111d71a2fa446c1 *uni_skip.npz
e1a0ead377877ff3ea5388bb11cfe8d7 *uni_skip.npz.pkl
5871cc62fc01b79788c79c219b175617 *utable.npy
$ sha256sum *
8ab7965d2db5d146a907956d103badfa723b57e0acffb75e10198ba9f124edb0 *bi_skip.npz
d7e81430fcdcbc60b36b92b3f879200919c75d3015505ee76ae3b206634a0eb6 *bi_skip.npz.pkl
4a4ed9d7560bb87f91f241739a8f80d8f2ba787a871da96e1119e913ccd61c53 *btable.npy
4dc5622978a30cddea8c975c871ea8b6382423efb107d27248ed7b6cfa490c7c *dictionary.txt
10c731626e1874effc4b1a08d156482aa602f7f2ca971ae2a2f2cd5d70998397 *glove.6B.300d.model.bin
20dfb1f44719e2d934bfee5d39a6ffb4f248bae2a00a0d59f953ab7d0a39c879 *glove.6B.300d.model.bin.vectors.npy
7f40ff16ff5c54ce9b02bd1a3eb24db3e6adaf7712a7a714f160af3a158899c8 *uni_skip.npz
d58740d46cba28417cbc026af577f530c603d81ac9de43ffd098f207c7dc4411 *uni_skip.npz.pkl
790951d4b08e843e3bca0563570f4134ffd17b6bd4ab8d237d2e5ae15e4febb3 *utable.npy
설정이 성공했는지 확인하면 테스트를 실행할 수 있습니다.
pip install pytest
pytest몇 분이 걸릴 수 있고 경고가 보이지만 통과해야합니다.
설정이 완료되면 Python API 또는 명령 줄에서 메트릭을 평가할 수 있습니다.
Python API의 예는 test_nlgeval.py에서 찾을 수 있습니다.
nlg-eval --hypothesis=examples/hyp.txt --references=examples/ref1.txt --references=examples/ref2.txt
가설 파일의 각 줄은 생성 된 문장이고 참조 파일의 해당 라인은 해당 가설에 대한 지상 진실 참조 문장입니다.
from nlgeval import compute_metrics
metrics_dict = compute_metrics ( hypothesis = 'examples/hyp.txt' ,
references = [ 'examples/ref1.txt' , 'examples/ref2.txt' ]) from nlgeval import compute_individual_metrics
metrics_dict = compute_individual_metrics ( references , hypothesis ) references 지상 진실 참조 텍스트 문자열의 목록이며 hypothesis 가설 텍스트 문자열입니다.
from nlgeval import NLGEval
nlgeval = NLGEval () # loads the models
metrics_dict = nlgeval . compute_individual_metrics ( references , hypothesis ) references 지상 진실 참조 텍스트 문자열의 목록이며 hypothesis 가설 텍스트 문자열입니다.
from nlgeval import NLGEval
nlgeval = NLGEval () # loads the models
metrics_dict = nlgeval . compute_metrics ( references , hypothesis ) references 지상 진실 참조 텍스트 문자열의 목록이며 hypothesis 가설 텍스트 문자열의 목록입니다. references 의 각 내부 목록은 가설에 대한 참조 세트입니다 (동일한 순서로 hypothesis 에서 각 문장에 대한 단일 참조 문자열 목록).
이 코드를 공개 된 연구의 일부로 사용하는 경우 다음 논문을 인용하십시오.
Shikhar Sharma, Layla El Asri, Hannes Schulz 및 Jeremie Zumer. "자연 언어 생성 평가를위한 작업 중심 대화에서 감독되지 않은 메트릭의 관련성" ARXIV PREPRINT ARXIV : 1706.09799 (2017)
@article { sharma2017nlgeval ,
author = { Sharma, Shikhar and El Asri, Layla and Schulz, Hannes and Zumer, Jeremie } ,
title = { Relevance of Unsupervised Metrics in Task-Oriented Dialogue for Evaluating Natural Language Generation } ,
journal = { CoRR } ,
volume = { abs/1706.09799 } ,
year = { 2017 } ,
url = { http://arxiv.org/abs/1706.09799 }
}달리기
nlg-eval --hypothesis=examples/hyp.txt --references=examples/ref1.txt --references=examples/ref2.txt
주어진다
Bleu_1: 0.550000
Bleu_2: 0.428174
Bleu_3: 0.284043
Bleu_4: 0.201143
METEOR: 0.295797
ROUGE_L: 0.522104
CIDEr: 1.242192
SPICE: 0.312331
SkipThoughtsCosineSimilarity: 0.626149
EmbeddingAverageCosineSimilarity: 0.884690
VectorExtremaCosineSimilarity: 0.568696
GreedyMatchingScore: 0.784205
Meteor에 문제가있는 경우 Meteor.py에서 mem 변수를 낮추십시오.
기본적으로 사이다 (IDF 매개 변수가 "코퍼스"모드로 설정 됨)는 제공된 참조 문장을 사용하여 IDF 값을 계산합니다. 따라서 1 개의 이미지 (또는 NLG의 예) 만있는 참조 데이터 세트의 사이다 점수는 0이됩니다. 하나 (또는 적은) 이미지를 사용하여 평가할 때 IDF를 대신 "Coco-Val-DF"로 설정하여 MSCoco VailDation 데이터 세트의 IDF를 사용하여 신뢰할 수있는 결과를 얻으십시오. 이것은이 코드에서 조정되지 않았습니다. 이 사용을 위해서는 VRAMA91/Coco-Caption에서 패치를 적용하십시오.
이미 준비된 데이터 디렉토리를 Docker 컨테이너에 마련하거나 사용자간에 공유하려면 NLGEVAL_DATA 환경 변수를 설정하여 NLG-Eval에게 모델 및 데이터를 찾을 위치를 알 수 있습니다. 예를 들어
NLGEVAL_DATA=~/workspace/nlg-eval/nlgeval/data
이 변수는 설정 중에 제공된 값을 무시합니다 ( ~/.config/nlgeval/rc.json 에 저장)
이 프로젝트는 Microsoft 오픈 소스 행동 강령을 채택했습니다. 자세한 내용은 추가 질문이나 의견이 있으면 행동 강령 FAQ 또는 [email protected]에 문의하십시오.
License.md를 참조하십시오.