This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from transformers import DistilBertModel | |
| from transformers import AlbertTokenizer | |
| from transformers import DistilBertForQuestionAnswering | |
| import torch | |
| # Load model | |
| pt_model = DistilBertModel.from_pretrained('laboro-ai/distilbert-base-japanese') | |
| sp_tokenizer = AlbertTokenizer.from_pretrained('laboro-ai/distilbert-base-japanese') | |
| model = DistilBertForQuestionAnswering.from_pretrained('laboro-ai/distilbert-base-japanese-finetuned-ddqa') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| def calc_H_and_L(result): | |
| log_side = np.log2(1./result) | |
| ceil_log_side = np.ceil(log_side) | |
| H = np.sum(result * log_side) | |
| L = np.sum(result * ceil_log_side) | |
| return H, L, ceil_log_side | |
| probs = np.array([1/3, 1/4, 5/12]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| probs = np.array([0.3, 0.2, 0.15, 0.15, 0.1, 0.1]) | |
| result = np.array([]) | |
| for prob in probs: | |
| result = np.append(result, probs * prob) | |
| print(result) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.