Update README.md
Browse files
README.md
CHANGED
|
@@ -54,38 +54,38 @@ tags:
|
|
| 54 |
|
| 55 |
**Query**
|
| 56 |
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
제시하는 context에서만 대답하고 context에 없는 내용은 모르겠다고 대답해'''
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
|
| 90 |
```
|
| 91 |
|
|
|
|
| 54 |
|
| 55 |
**Query**
|
| 56 |
|
| 57 |
+
```python
|
| 58 |
+
from transformers import TextStreamer
|
| 59 |
+
PROMPT = '''Below is an instruction that describes a task. Write a response that appropriately completes the request.
|
| 60 |
제시하는 context에서만 대답하고 context에 없는 내용은 모르겠다고 대답해'''
|
| 61 |
+
|
| 62 |
+
messages = [
|
| 63 |
+
{"role": "system", "content": f"{PROMPT}"},
|
| 64 |
+
{"role": "user", "content": f"{instruction}"}
|
| 65 |
+
]
|
| 66 |
+
|
| 67 |
+
input_ids = tokenizer.apply_chat_template(
|
| 68 |
+
messages,
|
| 69 |
+
add_generation_prompt=True,
|
| 70 |
+
return_tensors="pt"
|
| 71 |
+
).to(model.device)
|
| 72 |
+
|
| 73 |
+
terminators = [
|
| 74 |
+
tokenizer.eos_token_id,
|
| 75 |
+
tokenizer.convert_tokens_to_ids("<|eot_id|>")
|
| 76 |
+
]
|
| 77 |
+
|
| 78 |
+
text_streamer = TextStreamer(tokenizer)
|
| 79 |
+
_ = model.generate(
|
| 80 |
+
input_ids,
|
| 81 |
+
max_new_tokens=4096,
|
| 82 |
+
eos_token_id=terminators,
|
| 83 |
+
do_sample=True,
|
| 84 |
+
streamer = text_streamer,
|
| 85 |
+
temperature=0.6,
|
| 86 |
+
top_p=0.9,
|
| 87 |
+
repetition_penalty = 1.1
|
| 88 |
+
)
|
| 89 |
|
| 90 |
```
|
| 91 |
|