Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
AllenNLPを使った開発
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Yasufumi Taniguchi
July 29, 2019
Programming
2.3k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
AllenNLPを使った開発
Yasufumi Taniguchi
July 29, 2019
More Decks by Yasufumi Taniguchi
See All by Yasufumi Taniguchi
Pathologies of Neural Models Make Interpretations Difficult
yasufumy
1
1.8k
Making Neural QA as Simple as Possible but not Simpler
yasufumy
0
110
Other Decks in Programming
See All in Programming
iOSDC Japan 2026 - Swiftで作って学ぼう!データベース自作入門
kaseken
2
170
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
5
3.2k
setup-vp GitLab対応の裏側
naokihaba
0
100
速習iPhone Duo対応
yuukiw00w
1
520
Vibes Containers 〜AIで変わるコンテナ設計と運用〜
tkikuc
3
550
JPUG勉強会 OSSデータベースの内部構造を理解しよう(第2回)
oga5
0
250
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
150
大喜利で理解するLLM as a Judge / Understanding LLM-as-a-Judge through Ogiri
rockname
0
120
そのリトライ、死んだコネクションを使い回していませんか ── GoのHTTPクライアントとHTTP/2を実プロダクト障害から学び直す
myus4a
0
140
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
1.9k
仕様駆動開発による爆速プロダクト開発 / Bakusoku Spec Driven Development
kobakei
0
120
【高い買い物LT会】初任給で話題の国産フィジカルAIを買った話
akagami
PRO
0
160
Featured
See All Featured
Context Engineering - Making Every Token Count
addyosmani
9
1.1k
The Curious Case for Waylosing
cassininazir
1
510
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Chasing Engaging Ingredients in Design
codingconduct
0
310
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
540
Agile that works and the tools we love
rasmusluckow
331
22k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
850
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
590
How STYLIGHT went responsive
nonsquared
100
6.3k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
390
Transcript
AllenNLPを使った開発 ⾕⼝泰史
⽬次 1. AllenNLPとは︖ 2. AllenNLPの概要 3. AllenNLPによる実装例 4. まとめ
1. AllenNLPとは • NLP研究に特化したPyTorchベースのライブラリ • プロトタイプ作成が簡単 • ハイパーパラメータ管理が簡単
1. AllenNLPとは • NLP研究に特化したPyTorchベースのライブラリ • プロトタイプ作成が簡単 • ハイパーパラメータ管理が簡単
1. プロトタイプ作成
1. プロトタイプ作成 論⽂で提案された様々な⼿法が実装済み
1. AllenNLPとは • NLP研究に特化したPyTorchベースのライブラリ • プロトタイプ作成が簡単 • ハイパーパラメータ管理が簡単
1. パラメータ管理 python -m torch.distributed.launch --nproc_per_node=8 ./examples/run_squad.py ¥ --model_type bert
¥ --model_name_or_path bert-large-uncased-whole-word-masking ¥ --do_train ¥ --do_eval ¥ --do_lower_case ¥ --train_file $SQUAD_DIR/train-v1.1.json ¥ --predict_file $SQUAD_DIR/dev-v1.1.json ¥ --learning_rate 3e-5 ¥ --num_train_epochs 2 ¥ --max_seq_length 384 ¥ --doc_stride 128 ¥ --output_dir ../models/wwm_uncased_finetuned_squad/ ¥ --per_gpu_eval_batch_size=3 ¥ --per_gpu_train_batch_size=3 ¥
1. パラメータ管理 allennlp train ¥ --include-package pretrained_bert ¥ model_config/pretrained_bert_large_squad1.1.jsonnet
1. パラメータ管理 allennlp train ¥ --include-package pretrained_bert ¥ model_config/pretrained_bert_large_squad1.1.jsonnet ファイルで指定するのでGit管理可能
2. AllenNLPの概要
Trainer データセットの準備 実験 モデル構築 DatasetReader Model torch.optim, etc Config files
$ allennlp train 2. AllenNLPの概要
2. AllenNLPの概要 DatasetReader Model
2. AllenNLPの概要 DatasetReader Model
2. DatasetReaderの役割 誰が⼀番に着くか私には分かりません。 DatasetReader tensor([88, 19, 226, 3, 151, 25,
18, 14, 3, 1, 273, 34, 17, 37, 26, 0])
2. AllenNLPの概要 DatasetReader Model
2. Modelの役割 tensor([88, 19, 226, 3, 151, 25, 18, 14,
3, 1, 273, 34, 17, 37, 26, 0]) Model {“loss”: tensor([0.1234])}
3. AllenNLPによる実装例
3. AllenNLPによる実装例 • 感情分析タスク (IMDB Dataset) に取り組む • 与えられた⽂書が肯定的か・否定的かを予測する •
DatasetReaderとModelの実装を紹介
3. DatasetReaderの実装 @overrides def text_to_instance(self, string, label): fields = {}
tokens = self._tokenizer.tokenize(string) fields['tokens'] = TextField(tokens, self._token_indexers) fields['label'] = LabelField(label, skip_indexing=True) return Instance(fields) • トークナイゼーション • インデックス化
3. DatasetReaderの実装 • ⽂書のトークナイズを⾏う • トークナイザは設定ファイルで指定する @overrides def text_to_instance(self, string,
label): fields = {} tokens = self._tokenizer.tokenize(string) fields['tokens'] = TextField(tokens, self._token_indexers) fields['label'] = LabelField(label, skip_indexing=True) return Instance(fields)
3. DatasetReaderの実装 • トークナイズした⽂書からTextFieldを⽣成 • インデックス化はTextFieldが実⾏ @overrides def text_to_instance(self, string,
label): fields = {} tokens = self._tokenizer.tokenize(string) fields['tokens'] = TextField(tokens, self._token_indexers) fields['label'] = LabelField(label, skip_indexing=True) return Instance(fields)
3. Modelの実装 def forward(self, tokens, label): embedded_text = self._text_field_embbeder(tokens) mask
= get_text_field_mask(tokens).float() encoded_text = self._dropout( self._seq2vec_encoder(embedded_text, mask=mask) ) logits = self._classification_layer(encoded_text) probs = F.softmax(logits, dim=1) loss = self._loss(logits, label.long().view(-1)) return {“loss”: loss} • ⼊⼒からロスを計算 • dict形式で値を返却
3. 設定ファイル作成 allennlp configure --include-package allennlp_imdb
3. 設定ファイル作成
3. 学習 allennlp train –include-package allennlp_imdb ¥ -s /path/to/serialization ¥
training_config/base_cpu.jsonnet • 設定ファイルを指定して実験を⾏う
3. 学習 allennlp train –include-package allennlp_imdb ¥ -s /path/to/serialization ¥
-o ‘{“trainer”: {“cuda_device”: 0}}’ training_config/base_cpu.jsonnet • 設定ファイルを指定して実験を⾏う • 設定の上書きも可能
4. まとめ • AllenNLPを使えば、必要最低限の実装で実験を⾏える • プロトタイプ作成、ハイパーパラメータの管理も簡単 • コードは下記リンク https://github.com/yasufumy/allennlp_imdb