Commit
路
16e5a28
1
Parent(s):
41e2d13
Update README.md
Browse files
README.md
CHANGED
@@ -102,8 +102,9 @@ encoding = tokenizer(text,question,add_special_tokens = True,
|
|
102 |
truncation = 'only_first',
|
103 |
max_length = 32)
|
104 |
out = model(encoding['input_ids'].to(device),encoding['attention_mask'].to(device), encoding['token_type_ids'].to(device))
|
105 |
-
#we had to change some pieces of code to make it compatible
|
106 |
-
#
|
|
|
107 |
answer_start_index, answer_end_index = generate_indexes(out['start_logits'][0][1:], out['end_logits'][0][1:], 5, 0)
|
108 |
print(tokenizer.tokenize(text + question))
|
109 |
print(tokenizer.tokenize(text + question)[answer_start_index : (answer_end_index + 1)])
|
|
|
102 |
truncation = 'only_first',
|
103 |
max_length = 32)
|
104 |
out = model(encoding['input_ids'].to(device),encoding['attention_mask'].to(device), encoding['token_type_ids'].to(device))
|
105 |
+
#we had to change some pieces of code to make it compatible with one answer generation at a time
|
106 |
+
#If you have unanswerable questions, use out['start_logits'][0][0:] and out['end_logits'][0][0:] because <s> (the 1st token) is for this situation and must be compared with other tokens.
|
107 |
+
#you can initialize min_index_list in generate_indexes() to put force on tokens being chosen to be within the context(start index must be bigger than the seperator token.
|
108 |
answer_start_index, answer_end_index = generate_indexes(out['start_logits'][0][1:], out['end_logits'][0][1:], 5, 0)
|
109 |
print(tokenizer.tokenize(text + question))
|
110 |
print(tokenizer.tokenize(text + question)[answer_start_index : (answer_end_index + 1)])
|