Spaces:
Runtime error
Runtime error
EC2 Default User
commited on
Commit
Β·
64bec8f
1
Parent(s):
3eefa8c
PROMPT relocate
Browse files
InstructionTextGenerationPipeline.py
CHANGED
|
@@ -13,6 +13,21 @@ from threading import Event, Thread
|
|
| 13 |
import torch
|
| 14 |
from transformers import AutoModelForCausalLM, AutoTokenizer, StoppingCriteria, StoppingCriteriaList, TextIteratorStreamer
|
| 15 |
import config
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
class InstructionTextGenerationPipeline:
|
| 18 |
def __init__(
|
|
|
|
| 13 |
import torch
|
| 14 |
from transformers import AutoModelForCausalLM, AutoTokenizer, StoppingCriteria, StoppingCriteriaList, TextIteratorStreamer
|
| 15 |
import config
|
| 16 |
+
INSTRUCTION_KEY = "### Instruction:"
|
| 17 |
+
RESPONSE_KEY = "### Response:"
|
| 18 |
+
END_KEY = "### End"
|
| 19 |
+
INTRO_BLURB = "Below is an instruction that describes a task. Write a response that appropriately completes the request."
|
| 20 |
+
PROMPT_FOR_GENERATION_FORMAT = """{intro}
|
| 21 |
+
{instruction_key}
|
| 22 |
+
{instruction}
|
| 23 |
+
{response_key}
|
| 24 |
+
""".format(
|
| 25 |
+
intro=INTRO_BLURB,
|
| 26 |
+
instruction_key=INSTRUCTION_KEY,
|
| 27 |
+
instruction="{instruction}",
|
| 28 |
+
response_key=RESPONSE_KEY,
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
|
| 32 |
class InstructionTextGenerationPipeline:
|
| 33 |
def __init__(
|