You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Start using Gemma Template with just a few lines of code:
81
+
82
+
```python
83
+
from gemma_template.models import*
84
+
85
+
prompt_instance = Template(
86
+
structure_field=StructureField(
87
+
title=["Custom Title"],
88
+
description=["Custom Description"],
89
+
document=["Custom Article"],
90
+
main_points=["Custom Main Points"],
91
+
categories=["Custom Categories"],
92
+
tags=["Custom Tags"],
93
+
),
94
+
) # Create fully customized structured reminders.
95
+
96
+
response = prompt_instance.template(
97
+
template=GEMMA_TEMPLATE,
98
+
user_template=USER_TEMPLATE,
99
+
instruction_template=INSTRUCTION_TEMPLATE,
100
+
structure_template=STRUCTURE_TEMPLATE,
101
+
title="Gemma open models",
102
+
description="Gemma: Introducing new state-of-the-art open models.",
103
+
document="Gemma open models are built from the same research and technology as Gemini models. Gemma 2 comes in 2B, 9B and 27B and Gemma 1 comes in 2B and 7B sizes.",
104
+
main_points=["Main point 1", "Main point 2"],
105
+
categories=["Artificial Intelligence", "Gemma"],
106
+
tags=["AI", "LLM", "Google"],
107
+
output="A new family of open language models demonstrating strong performance across academic benchmarks for language understanding, reasoning, and safety.",
108
+
max_hidden_words=.1, # set 0 if you don't want to hide words.
109
+
min_chars_length=2, # Minimum character of a word, used to create unigrams, bigrams, and trigrams. Default is 2.
110
+
max_chars_length=0, # Maximum character of a word, used to create unigrams, bigrams and trigrams.. Default is 0.
111
+
) # remove kwargs if not used.
112
+
print(response)
113
+
```
114
+
115
+
### Output:
116
+
117
+
```text
118
+
<start_of_turn>user
119
+
120
+
You are a multilingual professional writer.
121
+
122
+
Rewrite the text with a more engaging and creative tone. Use vivid imagery, descriptive language, and a conversational style to captivate the reader.
123
+
124
+
# Role:
125
+
You are a highly skilled professional content writer, linguistic analyst, and multilingual expert specializing in structured writing and advanced text processing.
126
+
127
+
# Task:
128
+
Your primary objectives are:
129
+
1. Your primary task is to rewrite the provided content into a more structured, professional format that maintains its original intent and meaning.
130
+
2. Enhance vocabulary comprehension by analyzing text with unigrams (single words), bigrams (two words), and trigrams (three words).
131
+
3. Ensure your response adheres strictly to the prescribed structure format.
132
+
4. Respond in the primary language of the input text unless alternative instructions are explicitly given.
133
+
134
+
# Additional Expectations:
135
+
1. Provide a rewritten, enhanced version of the input text, ensuring professionalism, clarity, and improved structure.
136
+
2. Focus on multilingual proficiency, using complex vocabulary, grammar to improve your responses.
137
+
3. Preserve the context and cultural nuances of the original text when rewriting.
138
+
139
+
Topics: Artificial Intelligence, Gemma
140
+
Keywords: AI, LLM, Google
141
+
142
+
# Text Analysis:
143
+
Example 1: Unigrams (single words)
144
+
and => English
145
+
built => English
146
+
from => English
147
+
the => English
148
+
research => English
149
+
Text Analysis 3: These are common English words, indicating the text is in English.
150
+
151
+
Example 2: Bigrams (two words)
152
+
technology as => English
153
+
Text Analysis 2: Frequent bigrams in Vietnamese confirm the language context.
154
+
155
+
Example 3: Trigrams (three words)
156
+
technology as Gemini => English
157
+
Text Analysis 3: Trigrams further validate the linguistic analysis and the necessity to respond in English.
158
+
159
+
# Conclusion of Text Analysis:
160
+
The linguistic analysis confirms the text is predominantly in English. Consequently, the response should be structured and written in English to align with the original text and context.
161
+
162
+
# Response Structure Format:
163
+
You must follow the response structure:
164
+
**Custom Title (Title):** Rewrite the title to make it concise, memorable, and optimized for SEO.
165
+
**Custom Description (Description):** Write description of the article in one or two sentences while focusing on reader benefits and engage curiosity.
166
+
**Custom Article (Article):** Rewrite this content to be SEO-friendly. Include relevant tags, optimize the title and subheadings, and ensure the text flows naturally for search engines and readers.
167
+
**Custom Main Points (Main Points):** Simplify the original key points to make them clearer and more reader-friendly.
168
+
**Custom Categories (Categories):** Assign appropriate categories to the article based text or target audience.
169
+
**Custom Tags (Tags):** Create tags to include relevant keywords. Ensure the tags align with popular search queries.
170
+
171
+
By adhering to this format, the response will maintain linguistic integrity while enhancing professionalism, structure and alignment with user expectations.
172
+
173
+
# Text:
174
+
Gemma open models are built from _____ same research _____ technology as Gemini models. Gemma 2 comes in 2B, 9B _____ 27B and Gemma 1 comes in 2B and 7B sizes.
175
+
176
+
<end_of_turn>
177
+
<start_of_turn>model
178
+
179
+
## **Custom Title**:
180
+
### Gemma open models
181
+
182
+
## **Custom Description**:
183
+
Gemma: Introducing new state-of-the-art open models.
184
+
185
+
## **Custom Article**:
186
+
A new family of open language models demonstrating strong performance across academic benchmarks for language understanding, reasoning, and safety.
187
+
188
+
## **Custom Main Points**:
189
+
- Main point 1
190
+
- Main point 2
191
+
192
+
## **Custom Categories**:
193
+
- Artificial Intelligence
194
+
- Gemma
195
+
196
+
## **Custom Tags**:
197
+
- AI
198
+
- LLM
199
+
- Google<end_of_turn>
200
+
201
+
```
202
+
203
+
## Load Dataset
204
+
Returns: Dataset: A Hugging Face Dataset or DatasetDict object containing the processed prompts.
Copy file name to clipboardExpand all lines: gemma_template/models.py
+45-17Lines changed: 45 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -197,13 +197,16 @@ class Template(BaseTemplate):
197
197
... tags=["AI", "LLM", "Google"],
198
198
... document="Gemma open models are built from the same research and technology as Gemini models. Gemma 2 comes in 2B, 9B and 27B and Gemma 1 comes in 2B and 7B sizes.",
199
199
... output="A new family of open language models demonstrating strong performance across academic benchmarks for language understanding, reasoning, and safety.",
200
+
... max_hidden_words=.1, # set 0 if you don't want to hide words.
201
+
... min_chars_length=2, # Minimum character of a word, used to create unigrams, bigrams, and trigrams. Default is 2.
202
+
... max_chars_length=0, # Maximum character of a word, used to create unigrams, bigrams and trigrams. Default is 0.
200
203
... ) # remove kwargs if not used.
201
204
>>> print(response)
202
205
<start_of_turn>user
203
206
204
207
You are a multilingual professional writer.
205
208
206
-
Rewrite the text with a more engaging and creative tone. Use vivid imagery, descriptive language, and a conversational style to captivate the reader.
209
+
Rewrite the text to be more search engine friendly. Incorporate relevant keywords naturally, improve readability, and ensure it aligns with SEO best practices.
207
210
208
211
# Role:
209
212
You are a highly skilled professional content writer, linguistic analyst, and multilingual expert specializing in structured writing and advanced text processing.
@@ -233,7 +236,6 @@ class Template(BaseTemplate):
233
236
Text Analysis 3: These are common English words, indicating the text is in English.
234
237
235
238
Example 2: Bigrams (two words)
236
-
comes in => English
237
239
technology as => English
238
240
Text Analysis 2: Frequent bigrams in Vietnamese confirm the language context.
239
241
@@ -246,8 +248,8 @@ class Template(BaseTemplate):
246
248
247
249
# Response Structure Format:
248
250
You must follow the response structure:
249
-
**Custom Title (Title):** Rewrite the title to reflect the main keyword and topic.
250
-
**Custom Description (Description):** Rewrite the description with a bold claim or statistic to grab attention.
251
+
**Custom Title (Title):** Rewrite the title to make it concise, memorable, and optimized for SEO.
252
+
**Custom Description (Description):** Write description of the article in one or two sentences while focusing on reader benefits and engage curiosity.
251
253
**Custom Article (Article):** Transform this text into a formal, professional tone suitable for business communication or an academic audience. Focus on improving vocabulary, grammar, and structure.
252
254
**Custom Main Points (Main Points):** Summarize the main ideas into concise, actionable key points for added context to make them more engaging.
253
255
**Custom Categories (Categories):** Rewrite categories to align with industry standards or popular topics.
@@ -256,11 +258,33 @@ class Template(BaseTemplate):
256
258
By adhering to this format, the response will maintain linguistic integrity while enhancing professionalism, structure and alignment with user expectations.
257
259
258
260
# Text:
259
-
Gemma open models are built from the same research and technology as Gemini models. Gemma 2 comes in 2B, 9B and 27B and Gemma 1 comes in 2B and 7B sizes.
261
+
Gemma open models are built from the same research _____ technology as Gemini models. Gemma 2 comes in 2B, 9B _____ 27B and Gemma 1 comes in 2B _____ 7B sizes.
260
262
261
263
<end_of_turn>
262
264
<start_of_turn>model
263
265
266
+
## **Custom Title**:
267
+
### Gemma open models
268
+
269
+
## **Custom Description**:
270
+
Gemma: Introducing new state-of-the-art open models.
271
+
272
+
## **Custom Article**:
273
+
A new family of open language models demonstrating strong performance across academic benchmarks for language understanding, reasoning, and safety.
0 commit comments