언어 모델을위한 통합 코퍼스 구축 환경.
langumo 는 언어 모델을위한 통합 코퍼스 구축 환경 입니다. langumo 텍스트 기반 데이터 세트를 구축하기위한 파이프 라인을 제공합니다. 데이터 세트를 구성하려면 복잡한 파이프 라인 (예 : 구문 분석, 셔플 링 및 토큰 화)이 필요합니다. 또한 Corpora가 다른 소스에서 수집되면 다양한 형식에서 데이터를 추출하는 것이 문제가됩니다. langumo 한 번에 다양한 형식의 데이터 세트를 구축하는 데 도움이됩니다.
langumo 다음과 같이 pip 사용하여 설치할 수 있습니다.
$ pip install langumo 저장소를 복제하고 실행하여 소스에서 langumo 설치할 수 있습니다.
$ git clone https://github.com/affjljoo3581/langumo.git
$ cd langumo
$ python setup.py install Wikipedia 데이터 세트를 작성합시다. 먼저 가상 환경에 langumo 설치하십시오.
$ pip install langumo langumo 설치 한 후 빌드에서 사용할 작업 공간을 만듭니다.
$ mkdir workspace
$ cd workspace 데이터 세트를 만들기 전에 Wikipedia 덤프 파일 (데이터 세트 소스)이 필요합니다. 여기에서 다양한 버전의 Wikipedia 덤프 파일을 얻을 수 있습니다. 이 자습서에서는 Wikipedia 덤프 파일의 일부를 사용합니다. 브라우저로 파일을 다운로드하고 workspace/src 로 이동하십시오. 또는 wget 사용하여 파일을 터미널에서 간단히 가져옵니다.
$ wget -P src https://dumps.wikimedia.org/enwiki/20200901/enwiki-20200901-pages-articles1.xml-p1p30303.bz2 langumo 데이터 세트의 세부 사항이 포함 된 빌드 구성 파일이 필요합니다. build.yml 파일을 workspace 으로 만들고 벨로우를 작성하십시오.
langumo :
inputs :
- path : src/enwiki-20200901-pages-articles1.xml-p1p30303.bz2
parser : langumo.parsers.WikipediaParser
build :
parsing :
num-workers : 8 # The number of CPU cores you have.
tokenization :
vocab-size : 32000 # The vocabulary size. 이제 우리는 첫 번째 데이터 세트를 만들 준비가되었습니다. langumo 실행하십시오!
$ langumo그런 다음 아래 출력을 볼 수 있습니다.
[*] import file from src/enwiki-20200901-pages-articles1.xml-p1p30303.bz2
[*] parse raw-formatted corpus file with WikipediaParser
[*] merge 1 files into one
[*] shuffle raw corpus file: 100%|██████████████████████████████| 118042/118042 [00:01<00:00, 96965.15it/s]
[00:00:10] Reading files (256 Mo) ███████████████████████████████████ 100
[00:00:00] Tokenize words ███████████████████████████████████ 418863 / 418863
[00:00:01] Count pairs ███████████████████████████████████ 418863 / 418863
[00:00:02] Compute merges ███████████████████████████████████ 28942 / 28942
[*] export the processed file to build/vocab.txt
[*] tokenize sentences with WordPiece model: 100%|███████████████| 236084/236084 [00:23<00:00, 9846.67it/s]
[*] split validation corpus - 23609 of 236084 lines
[*] export the processed file to build/corpus.train.txt
[*] export the processed file to build/corpus.eval.txt
데이터 세트를 구축 한 후 workspace 아래 파일이 포함됩니다.
workspace
├── build
│ ├── corpus.eval.txt
│ ├── corpus.train.txt
│ └── vocab.txt
├── src
│ └── enwiki-20200901-pages-articles1.xml-p1p30303.bz2
└── build.yml
usage: langumo [-h] [config]
The unified corpus building environment for Language Models.
positional arguments:
config langumo build configuration
optional arguments:
-h, --help show this help message and exit
웹 사이트에서 langumo 문서를 찾을 수 있습니다.
langumo 는 Apache-2.0 라이센스입니다.