Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
#### Klue-bert base for Common Sense QA
|
3 |
+
|
4 |
+
#### Klue-CommonSense-model DEMO: [Ainize DEMO](https://main-klue-common-sense-qa-east-h-shin.endpoint.ainize.ai/)
|
5 |
+
|
6 |
+
#### Klue-CommonSense-model API: [Ainize API](https://ainize.ai/EastHShin/Klue-CommonSense_QA?branch=main)
|
7 |
+
|
8 |
+
### Overview
|
9 |
+
|
10 |
+
#### Language model: klue/bert-base
|
11 |
+
#### Language: Korean
|
12 |
+
#### Downstream-task: Extractive QA
|
13 |
+
#### Training data: Common sense Data from [Mindslab](https://mindslab.ai:8080/kr/company)
|
14 |
+
#### Eval data: Common sense Data from [Mindslab](https://mindslab.ai:8080/kr/company)
|
15 |
+
#### Code: See [Ainize Workspace](https://ainize.ai/workspace/create?imageId=hnj95592adzr02xPTqss&git=https://github.com/EastHShin/Klue-CommonSense-workspace)
|
16 |
+
|
17 |
+
### Usage
|
18 |
+
|
19 |
+
### In Transformers
|
20 |
+
```
|
21 |
+
from transformers import AutoModelForQuestionAnswering, AutoTokenizer
|
22 |
+
|
23 |
+
tokenizer = AutoTokenizer.from_pretrained("EasthShin/Klue-CommonSense-model")
|
24 |
+
model = AutoModelForQuestionAnswering.from_pretrained("EasthShin/Klue-CommonSense-model")
|
25 |
+
|
26 |
+
context = "your context"
|
27 |
+
question = "your question"
|
28 |
+
|
29 |
+
encodings = tokenizer(context, question, max_length=512, truncation=True,
|
30 |
+
padding="max_length", return_token_type_ids=False)
|
31 |
+
encodings = {key: torch.tensor([val]) for key, val in encodings.items()}
|
32 |
+
|
33 |
+
input_ids = encodings["input_ids"]
|
34 |
+
attention_mask = encodings["attention_mask"]
|
35 |
+
|
36 |
+
pred = model(input_ids, attention_mask=attention_mask)
|
37 |
+
|
38 |
+
start_logits, end_logits = pred.start_logits, pred.end_logits
|
39 |
+
|
40 |
+
token_start_index, token_end_index = start_logits.argmax(dim=-1), end_logits.argmax(dim=-1)
|
41 |
+
|
42 |
+
pred_ids = input_ids[0][token_start_index: token_end_index + 1]
|
43 |
+
|
44 |
+
prediction = tokenizer.decode(pred_ids)
|
45 |
+
```
|