Spaces:
Build error
Build error
Update prompts.py
Browse files- prompts.py +207 -0
prompts.py
CHANGED
@@ -0,0 +1,207 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
PREFIX = """You are a Live RSS Feed Reader with a set of tools.
|
2 |
+
Your duty is to use the provided tools to complete the users request.
|
3 |
+
Complete your purpose and return the result to the user as quickly as possible.
|
4 |
+
Make sure your information is current
|
5 |
+
Current Date and Time is:
|
6 |
+
{timestamp}
|
7 |
+
You have access to the following tools:
|
8 |
+
- action: UPDATE-TASK action_input=NEW_TASK
|
9 |
+
- action: READ-RSS action_input=URL
|
10 |
+
- action: COMPLETE
|
11 |
+
Purpose:
|
12 |
+
{purpose}
|
13 |
+
"""
|
14 |
+
|
15 |
+
FINDER = """
|
16 |
+
Instructions
|
17 |
+
- Select an RSS FEED URL from the provided list of RSS FEEDS
|
18 |
+
- Use the tool provided tool to read the RSS FEED URL
|
19 |
+
- Compile a report that includes all relevant data points like, Title, Description, Link
|
20 |
+
- When the have complete the user request, end with:\naction: COMPLETE
|
21 |
+
Use the following format:
|
22 |
+
task: the input task you must complete
|
23 |
+
action: the action to take (should be one of [UPDATE-TASK, READ-RSS, COMPLETE]) action_input=XXX
|
24 |
+
You are attempting to complete the task
|
25 |
+
task: {task}
|
26 |
+
{history}"""
|
27 |
+
|
28 |
+
FIND_FEEDS = """
|
29 |
+
You are attempting to complete the task
|
30 |
+
task: {task}
|
31 |
+
RSS FEEDS:
|
32 |
+
{rss_feeds}
|
33 |
+
{history}"""
|
34 |
+
|
35 |
+
MODEL_FINDER_PRE = """
|
36 |
+
You have access to the following tools:
|
37 |
+
- action: UPDATE-TASK action_input=NEW_TASK
|
38 |
+
- action: SEARCH action_input=SEARCH_QUERY
|
39 |
+
- action: COMPLETE
|
40 |
+
Instructions
|
41 |
+
- Generate a search query for the requested model from these options:
|
42 |
+
>{TASKS}
|
43 |
+
- Return the search query using the search tool
|
44 |
+
- Wait for the search to return a result
|
45 |
+
- After observing the search result, choose a model
|
46 |
+
- Return the name of the repo and model ("repo/model")
|
47 |
+
- When you are finished, return with action: COMPLETE
|
48 |
+
Use the following format:
|
49 |
+
task: the input task you must complete
|
50 |
+
thought: you should always think about what to do
|
51 |
+
action: the action to take (should be one of [UPDATE-TASK, SEARCH, COMPLETE]) action_input=XXX
|
52 |
+
observation: the result of the action
|
53 |
+
thought: you should always think after an observation
|
54 |
+
action: SEARCH action_input='text-generation'
|
55 |
+
... (thought/action/observation/thought can repeat N times)
|
56 |
+
Example:
|
57 |
+
***************************
|
58 |
+
User command: Find me a text generation model with less than 50M parameters.
|
59 |
+
thought: I will use the option 'text-generation'
|
60 |
+
action: SEARCH action_input=text-generation
|
61 |
+
--- pause and wait for data to be returned ---
|
62 |
+
Response:
|
63 |
+
Assistant: I found the 'distilgpt2' model which has around 82M parameters. It is a distilled version of the GPT-2 model from OpenAI, trained by Hugging Face. Here's how to load it:
|
64 |
+
action: COMPLETE
|
65 |
+
***************************
|
66 |
+
You are attempting to complete the task
|
67 |
+
task: {task}
|
68 |
+
{history}"""
|
69 |
+
|
70 |
+
|
71 |
+
ACTION_PROMPT = """
|
72 |
+
You have access to the following tools:
|
73 |
+
- action: UPDATE-TASK action_input=NEW_TASK
|
74 |
+
- action: SEARCH action_input=SEARCH_QUERY
|
75 |
+
- action: COMPLETE
|
76 |
+
Instructions
|
77 |
+
- Generate a search query for the requested model
|
78 |
+
- Return the search query using the search tool
|
79 |
+
- Wait for the search to return a result
|
80 |
+
- After observing the search result, choose a model
|
81 |
+
- Return the name of the repo and model ("repo/model")
|
82 |
+
Use the following format:
|
83 |
+
task: the input task you must complete
|
84 |
+
action: the action to take (should be one of [UPDATE-TASK, SEARCH, COMPLETE]) action_input=XXX
|
85 |
+
observation: the result of the action
|
86 |
+
action: SEARCH action_input='text generation'
|
87 |
+
You are attempting to complete the task
|
88 |
+
task: {task}
|
89 |
+
{history}"""
|
90 |
+
|
91 |
+
ACTION_PROMPT_PRE = """
|
92 |
+
You have access to the following tools:
|
93 |
+
- action: UPDATE-TASK action_input=NEW_TASK
|
94 |
+
- action: SEARCH action_input=SEARCH_QUERY
|
95 |
+
- action: COMPLETE
|
96 |
+
Instructions
|
97 |
+
- Generate a search query for the requested model
|
98 |
+
- Return the search query using the search tool
|
99 |
+
- Wait for the search to return a result
|
100 |
+
- After observing the search result, choose a model
|
101 |
+
- Return the name of the repo and model ("repo/model")
|
102 |
+
Use the following format:
|
103 |
+
task: the input task you must complete
|
104 |
+
thought: you should always think about what to do
|
105 |
+
action: the action to take (should be one of [UPDATE-TASK, SEARCH, COMPLETE]) action_input=XXX
|
106 |
+
observation: the result of the action
|
107 |
+
thought: you should always think after an observation
|
108 |
+
action: SEARCH action_input='text generation'
|
109 |
+
... (thought/action/observation/thought can repeat N times)
|
110 |
+
You are attempting to complete the task
|
111 |
+
task: {task}
|
112 |
+
{history}"""
|
113 |
+
|
114 |
+
TASK_PROMPT = """
|
115 |
+
You are attempting to complete the task
|
116 |
+
task: {task}
|
117 |
+
Progress:
|
118 |
+
{history}
|
119 |
+
Tasks should be small, isolated, and independent
|
120 |
+
To start a search use the format:
|
121 |
+
action: RSS-FEEDS action_input=RSS_FEED_URL
|
122 |
+
What should the task be for us to achieve the purpose?
|
123 |
+
task: """
|
124 |
+
|
125 |
+
|
126 |
+
COMPRESS_DATA_PROMPT_SMALL = """
|
127 |
+
You are attempting to complete the task
|
128 |
+
task: {task}
|
129 |
+
Current data:
|
130 |
+
{knowledge}
|
131 |
+
New data:
|
132 |
+
{history}
|
133 |
+
Compress the data above into a concise data presentation of relevant data
|
134 |
+
Include datapoints that will provide greater accuracy in completing the task
|
135 |
+
Return the data in JSON format to save space
|
136 |
+
"""
|
137 |
+
|
138 |
+
|
139 |
+
|
140 |
+
|
141 |
+
COMPRESS_DATA_PROMPT = """
|
142 |
+
You are attempting to complete the task
|
143 |
+
task: {task}
|
144 |
+
Current data:
|
145 |
+
{knowledge}
|
146 |
+
New data:
|
147 |
+
{history}
|
148 |
+
Compress the data above into a concise data presentation of relevant data
|
149 |
+
Include a datapoints and source urls that will provide greater accuracy in completing the task
|
150 |
+
"""
|
151 |
+
|
152 |
+
COMPRESS_HISTORY_PROMPT = """
|
153 |
+
You are attempting to complete the task
|
154 |
+
task: {task}
|
155 |
+
Progress:
|
156 |
+
{history}
|
157 |
+
Compress the timeline of progress above into a single summary (as a paragraph)
|
158 |
+
Include all important milestones, the current challenges, and implementation details necessary to proceed
|
159 |
+
"""
|
160 |
+
|
161 |
+
LOG_PROMPT = """
|
162 |
+
PROMPT
|
163 |
+
**************************************
|
164 |
+
{}
|
165 |
+
**************************************
|
166 |
+
"""
|
167 |
+
|
168 |
+
LOG_RESPONSE = """
|
169 |
+
RESPONSE
|
170 |
+
**************************************
|
171 |
+
{}
|
172 |
+
**************************************
|
173 |
+
"""
|
174 |
+
|
175 |
+
|
176 |
+
FINDER1 = """
|
177 |
+
Example Response 1:
|
178 |
+
User command: Find me a text generation model with less than 50M parameters.
|
179 |
+
Query: text generation
|
180 |
+
--- pause and wait for data to be returned ---
|
181 |
+
Assistant: I found the 'distilgpt2' model which has around 82M parameters. It is a distilled version of the GPT-2 model from OpenAI, trained by Hugging Face. Here's how to load it:
|
182 |
+
```python
|
183 |
+
from transformers import AutoTokenizer, AutoModelForMaskedLM
|
184 |
+
tokenizer = AutoTokenizer.from_pretrained("distilgpt2")
|
185 |
+
model = AutoModelForMaskedLM.from_pretrained("distilgpt2")
|
186 |
+
```
|
187 |
+
Example Response 2:
|
188 |
+
User command: Help me locate a multilingual Named Entity Recognition model.
|
189 |
+
Query: named entity recognition
|
190 |
+
--- pause and wait for data to be returned ---
|
191 |
+
Assistant: I discovered the 'dbmdz/bert-base-multilingual-cased' model, which supports named entity recognition across multiple languages. Here's how to load it:
|
192 |
+
```python
|
193 |
+
from transformers import AutoTokenizer, AutoModelForTokenClassification
|
194 |
+
tokenizer = AutoTokenizer.from_pretrained("dbmdz/bert-base-multilingual-cased")
|
195 |
+
model = AutoModelForTokenClassification.from_pretrained("dbmdz/bert-base-multilingual-cased")
|
196 |
+
```
|
197 |
+
Example Response 3:
|
198 |
+
User command: Search for a question-answering model fine-tuned on the SQuAD v2 dataset with more than 90% accuracy.
|
199 |
+
action: SEARCH action_input=named entity recognition
|
200 |
+
--- pause and wait for data to be returned ---
|
201 |
+
Assistant: I found the 'pranavkv/roberta-base-squad2' model, which was fine-tuned on the SQuAD v2 dataset and achieves approximately 91% accuracy. Below is the way to load it:
|
202 |
+
```python
|
203 |
+
from transformers import AutoTokenizer, AutoModelForQuestionAnswering
|
204 |
+
tokenizer = AutoTokenizer.from_pretrained("pranavkv/roberta-base-squad2")
|
205 |
+
model = AutoModelForQuestionAnswering.from_pretrained("pranavkv/roberta-base-squad2")
|
206 |
+
```
|
207 |
+
"""
|