Several improvements: page flow, faster sample, etc.
Browse files
src/distilabel_dataset_generator/pipelines/sft.py
CHANGED
@@ -116,19 +116,19 @@ User dataset description:
|
|
116 |
|
117 |
MODEL = "meta-llama/Meta-Llama-3.1-70B-Instruct"
|
118 |
DEFAULT_DATASET_DESCRIPTIONS = (
|
119 |
-
"A chemistry
|
120 |
-
"
|
121 |
-
"
|
122 |
-
"
|
123 |
)
|
124 |
-
DEFAULT_SYSTEM_PROMPT = "You are an AI assistant
|
125 |
DEFAULT_DATASET = pd.DataFrame(
|
126 |
{
|
127 |
-
"
|
128 |
-
"What is the
|
129 |
],
|
130 |
-
"
|
131 |
-
"""The
|
132 |
],
|
133 |
}
|
134 |
)
|
@@ -138,7 +138,7 @@ _STOP_SEQUENCES = [
|
|
138 |
"assistant",
|
139 |
" \n\n",
|
140 |
]
|
141 |
-
DEFAULT_BATCH_SIZE =
|
142 |
TOKEN_INDEX = 0
|
143 |
|
144 |
|
@@ -190,12 +190,14 @@ if __name__ == "__main__":
|
|
190 |
return code
|
191 |
|
192 |
|
193 |
-
def get_pipeline(num_turns, num_rows, system_prompt):
|
194 |
global TOKEN_INDEX
|
195 |
input_mappings = _get_output_mappings(num_turns)
|
196 |
output_mappings = input_mappings
|
197 |
api_key = HF_TOKENS[TOKEN_INDEX % len(HF_TOKENS)]
|
198 |
TOKEN_INDEX += 1
|
|
|
|
|
199 |
if num_turns == 1:
|
200 |
with Pipeline(name="sft") as pipeline:
|
201 |
magpie = MagpieGenerator(
|
@@ -207,7 +209,7 @@ def get_pipeline(num_turns, num_rows, system_prompt):
|
|
207 |
generation_kwargs={
|
208 |
"temperature": 0.8, # it's the best value for Llama 3.1 70B Instruct
|
209 |
"do_sample": True,
|
210 |
-
"max_new_tokens": 256,
|
211 |
"stop_sequences": _STOP_SEQUENCES,
|
212 |
},
|
213 |
),
|
@@ -224,7 +226,7 @@ def get_pipeline(num_turns, num_rows, system_prompt):
|
|
224 |
model_id=MODEL,
|
225 |
tokenizer_id=MODEL,
|
226 |
api_key=api_key,
|
227 |
-
generation_kwargs={"temperature": 0.8, "max_new_tokens": 256},
|
228 |
),
|
229 |
system_prompt=system_prompt,
|
230 |
output_mappings={"generation": "completion"},
|
|
|
116 |
|
117 |
MODEL = "meta-llama/Meta-Llama-3.1-70B-Instruct"
|
118 |
DEFAULT_DATASET_DESCRIPTIONS = (
|
119 |
+
"A chemistry expert assistant that explains chemical reactions and formulas.",
|
120 |
+
"highly proficient assistant for PyTorch and CUDA expert developers to resolve complex issues",
|
121 |
+
"skilled high school math assistant who helps students solve problems",
|
122 |
+
"attentive and well-educated customer service assistant for a clothes e-commerce platform",
|
123 |
)
|
124 |
+
DEFAULT_SYSTEM_PROMPT = "You are an AI assistant specialized in chemistry, providing detailed explanations of chemical reactions, formulas, and processes. Your purpose is to assist users in understanding complex chemical concepts, breaking down reactions into step-by-step explanations, and helping users balance chemical equations. Offer examples of real-world applications, provide explanations of laboratory procedures, and support users in understanding the underlying principles of chemistry."
|
125 |
DEFAULT_DATASET = pd.DataFrame(
|
126 |
{
|
127 |
+
"prompt": [
|
128 |
+
"What is the chemical equation for the reaction between sodium metal and water?"
|
129 |
],
|
130 |
+
"completion": [
|
131 |
+
"""The reaction between sodium metal (Na) and water (H2O) is a highly exothermic reaction that releases hydrogen gas. The chemical equation for this reaction is: 2Na (sodium metal) + 2H2O (water) → 2NaOH (sodium hydroxide) + H2 (hydrogen gas) This can be broken down into two steps: 1. 2Na (sodium metal) + 2H2O (water) → 2Na+ (sodium ions) + 2OH- (hydroxide ions) + H2 (hydrogen gas) In the first step, the sodium metal reacts with the water to form sodium ions and hydroxide ions. 2Na+ (sodium ions) + 2OH- (hydroxide ions) → 2NaOH (sodium hydroxide) In the final step, the sodium ions and hydroxide ions combine to form sodium hydroxide. In this reaction, the sodium metal reduces the water, releasing hydrogen gas. This reaction is highly exothermic and generates a significant amount of heat, making it a self-sustaining reaction once it begins. The reaction is very violent, releasing a significant amount of"""
|
132 |
],
|
133 |
}
|
134 |
)
|
|
|
138 |
"assistant",
|
139 |
" \n\n",
|
140 |
]
|
141 |
+
DEFAULT_BATCH_SIZE = 50
|
142 |
TOKEN_INDEX = 0
|
143 |
|
144 |
|
|
|
190 |
return code
|
191 |
|
192 |
|
193 |
+
def get_pipeline(num_turns, num_rows, system_prompt, is_sample):
|
194 |
global TOKEN_INDEX
|
195 |
input_mappings = _get_output_mappings(num_turns)
|
196 |
output_mappings = input_mappings
|
197 |
api_key = HF_TOKENS[TOKEN_INDEX % len(HF_TOKENS)]
|
198 |
TOKEN_INDEX += 1
|
199 |
+
MODEL = "meta-llama/Meta-Llama-3.1-8B-Instruct"
|
200 |
+
print("is sample?", is_sample)
|
201 |
if num_turns == 1:
|
202 |
with Pipeline(name="sft") as pipeline:
|
203 |
magpie = MagpieGenerator(
|
|
|
209 |
generation_kwargs={
|
210 |
"temperature": 0.8, # it's the best value for Llama 3.1 70B Instruct
|
211 |
"do_sample": True,
|
212 |
+
"max_new_tokens": 256 if is_sample else 512,
|
213 |
"stop_sequences": _STOP_SEQUENCES,
|
214 |
},
|
215 |
),
|
|
|
226 |
model_id=MODEL,
|
227 |
tokenizer_id=MODEL,
|
228 |
api_key=api_key,
|
229 |
+
generation_kwargs={"temperature": 0.8, "max_new_tokens": 256 if is_sample else 1024},
|
230 |
),
|
231 |
system_prompt=system_prompt,
|
232 |
output_mappings={"generation": "completion"},
|