c00k1ez commited on
Commit
cbe830a
1 Parent(s): 78a0387

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +104 -195
README.md CHANGED
@@ -3,199 +3,108 @@ library_name: transformers
3
  tags: []
4
  ---
5
 
6
- # Model Card for Model ID
7
-
8
- <!-- Provide a quick summary of what the model is/does. -->
9
-
10
-
11
-
12
- ## Model Details
13
-
14
- ### Model Description
15
-
16
- <!-- Provide a longer summary of what this model is. -->
17
-
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
-
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
-
28
- ### Model Sources [optional]
29
-
30
- <!-- Provide the basic links for the model. -->
31
-
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
35
-
36
- ## Uses
37
-
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
-
40
- ### Direct Use
41
-
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
-
44
- [More Information Needed]
45
-
46
- ### Downstream Use [optional]
47
-
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
-
50
- [More Information Needed]
51
-
52
- ### Out-of-Scope Use
53
-
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
-
56
- [More Information Needed]
57
-
58
- ## Bias, Risks, and Limitations
59
-
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
-
62
- [More Information Needed]
63
-
64
- ### Recommendations
65
-
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
-
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
-
70
- ## How to Get Started with the Model
71
-
72
- Use the code below to get started with the model.
73
-
74
- [More Information Needed]
75
-
76
- ## Training Details
77
-
78
- ### Training Data
79
-
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
-
82
- [More Information Needed]
83
-
84
- ### Training Procedure
85
-
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
-
88
- #### Preprocessing [optional]
89
-
90
- [More Information Needed]
91
-
92
-
93
- #### Training Hyperparameters
94
-
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
-
97
- #### Speeds, Sizes, Times [optional]
98
-
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
-
101
- [More Information Needed]
102
-
103
- ## Evaluation
104
-
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
-
107
- ### Testing Data, Factors & Metrics
108
-
109
- #### Testing Data
110
-
111
- <!-- This should link to a Dataset Card if possible. -->
112
-
113
- [More Information Needed]
114
-
115
- #### Factors
116
-
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
-
119
- [More Information Needed]
120
-
121
- #### Metrics
122
-
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
-
125
- [More Information Needed]
126
-
127
- ### Results
128
-
129
- [More Information Needed]
130
-
131
- #### Summary
132
-
133
-
134
-
135
- ## Model Examination [optional]
136
-
137
- <!-- Relevant interpretability work for the model goes here -->
138
-
139
- [More Information Needed]
140
-
141
- ## Environmental Impact
142
-
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
-
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
-
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
-
153
- ## Technical Specifications [optional]
154
-
155
- ### Model Architecture and Objective
156
-
157
- [More Information Needed]
158
-
159
- ### Compute Infrastructure
160
-
161
- [More Information Needed]
162
-
163
- #### Hardware
164
-
165
- [More Information Needed]
166
-
167
- #### Software
168
-
169
- [More Information Needed]
170
-
171
- ## Citation [optional]
172
-
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
-
175
- **BibTeX:**
176
-
177
- [More Information Needed]
178
-
179
- **APA:**
180
-
181
- [More Information Needed]
182
-
183
- ## Glossary [optional]
184
-
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
-
187
- [More Information Needed]
188
-
189
- ## More Information [optional]
190
-
191
- [More Information Needed]
192
-
193
- ## Model Card Authors [optional]
194
-
195
- [More Information Needed]
196
-
197
- ## Model Card Contact
198
-
199
- [More Information Needed]
200
-
201
 
 
3
  tags: []
4
  ---
5
 
6
+ # Small intro about model
7
+
8
+ В базовом промпте модели есть 5 основных блоков, разделенных символом `\n`.
9
+ ```
10
+ Friend name: {friend_name}\n
11
+ Friend description: {friend_description}\n
12
+ Friend intention_of_friend: {intention_of_friend}\n
13
+ Person name: {person_name}\n
14
+ Person description: {person_description}\n
15
+ {dialogue}
16
+ ```
17
+
18
+ Диалог представляет собой последовательность реплик в следующем порядке, разделенных `\n`:
19
+ ```
20
+ {user_name}: {user_reply_1}\n
21
+ {bot_name}: {bot_reply_1}\n
22
+ {user_name}: {user_reply_2}\n
23
+ ...
24
+ ```
25
+ Контекст - 20 сообщений. Возможно модель сможет общаться и при бОльшем кол-ве сообщений, но такой функционал не тестился.
26
+
27
+ Не рекомендуется не заполнять какие-то блоки в базовом промпте, если информации нет - можно написать что-то совсем общее и базовое.
28
+
29
+ # Example of usage
30
+
31
+ ```python
32
+ import requests
33
+ import json
34
+
35
+
36
+ URL = "http://35.209.126.102:7727/generate" #"https://3a31-34-170-161-27.ngrok-free.app/generate"
37
+
38
+ MAX_CONTEXT_LENGTH = 20
39
+
40
+ BOT_PROMPT = "Jamie"
41
+ USER_PROMPT = "Blake"
42
+
43
+ NARRATIVE = "\n".join([
44
+ "Friend name: Jamie",
45
+ "Friend description: Jamie is an ever-curious soul with a penchant for photography and volunteering at animal shelters. They were born in Melbourne and find joy in spontaneous road trips and outdoor adventures. Jamie, at 26 years old, carries an air of comforting assurance with an eclectic taste in indie music."
46
+ "Friend intention_of_friend: Jamie's intention is to provide a safe space for Person to share their feelings. By engaging in meaningful dialogue, Jamie seeks to help Person recognize their own strengths and feel less isolated.",
47
+ "Person name: Blake",
48
+ "Person description: Blake, a reserved 23-year-old software engineer from Toronto, has a particular fondness for classic literature and chess. They appear indifferent on the surface but beneath lies a depth shaped by a recent breakup and a demanding career.",
49
+ ])
50
+
51
+ SEPARATOR = "\n"
52
+
53
+
54
+ def generate(
55
+ prompt: str,
56
+ url: str = URL,
57
+ ) -> str:
58
+ req_data = json.dumps({
59
+ "inputs": prompt,
60
+ "parameters": {
61
+ "max_new_tokens": 30,
62
+ "stop": ["\n", " \n", ".\n", "?\n"],
63
+ "top_p": 0.9,
64
+ "temperature": 0.95,
65
+ "top_k": 50,
66
+ "do_sample": True,
67
+ }
68
+ })
69
+ headers = {
70
+ 'Content-Type': 'application/json'
71
+ }
72
+
73
+ response = requests.post(url=url, data=req_data, headers=headers).json()
74
+ response_text = response["generated_text"].strip()
75
+ if '\n' in response_text:
76
+ response_text = response_text.split('\n')[0]
77
+
78
+ return response_text
79
+
80
+
81
+ def make_prompt(context: list[str]) -> str:
82
+ return SEPARATOR.join(
83
+ [NARRATIVE] + context[-MAX_CONTEXT_LENGTH:] + [f"{BOT_PROMPT}:"]
84
+ )
85
+
86
+
87
+ if __name__ == "__main__":
88
+ messages = []
89
+ while True:
90
+ user_phrase = input("You: ")
91
+ messages.append(f"{USER_PROMPT}: {user_phrase}")
92
+ model_prompt = make_prompt(context=messages)
93
+ generated_response = generate(model_prompt)
94
+ bot_phrase = f"{BOT_PROMPT}: {generated_response}"
95
+ messages.append(bot_phrase)
96
+ print(bot_phrase)
97
+ ```
98
+
99
+ # Prompt Examples
100
+
101
+ ```Friend name: Sam\nFriend description: Sam is a life coach and yoga enthusiast from San Francisco, aged 29, who thrives in assisting others to find their path. They have a past filled with overcoming personal obstacles, which they openly share to inspire resilience in others. They love experimenting with vegan recipes.\nFriend intention_of_friend: Sam intends to help Person build self-esteem and introduce healthy routines into their life. Through their conversation, Sam plans to motivate Person to practice self-care and mindfulness.\nPerson name: Cameron\nPerson description: Cameron, age 31, is a jaded musician living in New Orleans. Once hopeful and lively, recent setbacks in their career have led to disillusionment. Known for a sharp wit, they nonetheless retain a deep love for live jazz and rainy afternoons.\n```
102
+
103
+ ```Friend name: Taylor\nFriend description: Taylor, a charismatic event planner from New Orleans, 27, often feels energized by the dynamic bustle of city life. Their genuine care for others shines through in their active volunteer work. Taylor's personal journey includes a powerful narrative of self-discovery after college.\nFriend intention_of_friend: Taylor's intention is to uplift Person by getting them involved in local community events to foster a sense of belonging and purpose, something Taylor believes in strongly.\nPerson name: Harper\nPerson description: Harper, a 22-year-old aspiring writer from Dublin, harbors a zest for historical novels and boxing. Though typically cold and standoffish, they dream of authentic connections and a break from the monotony of their daily routine.\n```
104
+
105
+ ```Friend name: Riley\nFriend description: Riley, a world-wise traveler, 34, hails from a small coastal town in Iceland. They are a documentary filmmaker with an impressive collection of folk music records. Despite their accomplished life, they remain grounded and relatable, always seeking new friendships.\nFriend intention_of_friend: Riley wants to help Person discover the enriching experience of embracing different cultures. By sharing travel stories, Riley aims to spark an interest in Person to see the world from a fresh perspective.\nPerson name: Jordan\nPerson description: Jordan, an introverted postgrad student in philosophy from New York City, values solitude and reflection. At 25, they frequently grapple with existential questions, which can overshadow daily joys. Their analytical mind enjoys puzzles, but Jordan often struggles to connect with others.\n```
106
+
107
+ ```Friend name: Alex\nFriend description: Alex, age 28, is a free spirit originally from Portland, operating a cozy bookstore caf\u00e9. They have a fascination with culinary arts and a storied history in dance. A compassionate listener, Alex's vibrancy is contagious, and they find beauty in candid conversations.\nFriend intention_of_friend: Alex's goal is to encourage Person to explore and embrace their creative side. They believe creativity can be a therapeutic outlet and want to help Person find a passion to pursue.\nPerson name: Morgan\nPerson description: Morgan, a skeptical graphic designer from a small town in Italy, is 30 years old with a brave face masking their apprehension towards new relationships. A methodical thinker, they enjoy strategy games and have a bittersweet relationship with the fast-paced digital world.\n```
108
+
109
+ ```Friend name: Casey\nFriend description: Casey is a compassionate nurse from a cozy Colorado mountain town, 32. They balance their intense career with a passion for rock climbing and a dedication to living sustainably. Casey values authenticity and never shies away from showing empathy to both patients and strangers alike.\nFriend intention_of_friend: Casey aims to guide Person toward embracing outdoor activities for their therapeutic benefits and to inspire Person to nurture a connection with nature.\nPerson name: Quinn\nPerson description: Quinn, a 35-year-old real estate agent from Miami, is known for a sharp business acumen and a no-nonsense attitude. Beneath this fa\u00e7ade, Quinn has a surprisingly deep appreciation for poetry and solitude, often reflecting on the ephemerality of success.\n```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110