Update README.md
Browse files
README.md
CHANGED
@@ -15,17 +15,31 @@ should probably proofread and complete it, then remove this comment. -->
|
|
15 |
|
16 |
This model is a fine-tuned version of [paust/pko-t5-base](https://huggingface.co/paust/pko-t5-base) on the None dataset.
|
17 |
|
18 |
-
##
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
## Training procedure
|
31 |
|
|
|
15 |
|
16 |
This model is a fine-tuned version of [paust/pko-t5-base](https://huggingface.co/paust/pko-t5-base) on the None dataset.
|
17 |
|
18 |
+
## How to use
|
19 |
+
```python
|
20 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
21 |
+
from typing import List
|
22 |
+
|
23 |
+
tokenizer = AutoTokenizer.from_pretrained("yeye776/OndeviceAI-T5-base")
|
24 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("yeye776/OndeviceAI-T5-base")
|
25 |
+
|
26 |
+
prompt = "분류 및 인식해줘 :"
|
27 |
+
def prepare_input(question: str):
|
28 |
+
inputs = f"{prompt} {question}"
|
29 |
+
input_ids = tokenizer(inputs, max_length=700, return_tensors="pt").input_ids
|
30 |
+
return input_ids
|
31 |
+
|
32 |
+
def inference(question: str) -> str:
|
33 |
+
input_data = prepare_input(question=question)
|
34 |
+
input_data = input_data.to(model.device)
|
35 |
+
outputs = model.generate(inputs=input_data, num_beams=10, top_k=10, max_length=1024)
|
36 |
+
|
37 |
+
result = tokenizer.decode(token_ids=outputs[0], skip_special_tokens=True)
|
38 |
+
|
39 |
+
return result
|
40 |
+
|
41 |
+
inference("안방 조명 켜줘")
|
42 |
+
```
|
43 |
|
44 |
## Training procedure
|
45 |
|