Skip to content

Commit 32da458

Browse files
committed
fix prompt -> prompt_name
1 parent ec335dc commit 32da458

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

site/en/gemma/docs/embeddinggemma/fine-tuning-embeddinggemma-with-sentence-transformers.ipynb

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,9 @@
232232
"\n",
233233
"A search for \"tax-free investment\" might have given the following results, with similarity scores:\n",
234234
"\n",
235-
"1. Document: Opening a NISA account (Score: 0.45)\n",
236-
"2. Document: Opening a Regular Saving Account (Score: 0.48) <- *Similar score, potentially confusing*\n",
237-
"3. Document: Home Loan Application Guide (Score: 0.42)\n",
235+
"1. Document: Opening a NISA account (Score: 0.51)\n",
236+
"2. Document: Opening a Regular Saving Account (Score: 0.50) <- *Similar score, potentially confusing*\n",
237+
"3. Document: Home Loan Application Guide (Score: 0.44)\n",
238238
"\n",
239239
"> Note: To generate optimal embeddings with EmbeddingGemma, you should add an \"instructional prompt\" or \"task\" to the beginning of your input text. You will use `STS` for sentence similarity. For details on all available EmbeddingGemma prompts, see the [model card](http://ai.google.dev/gemma/docs/embeddinggemma/model_card#prompt_instructions)."
240240
]
@@ -250,9 +250,9 @@
250250
"name": "stdout",
251251
"output_type": "stream",
252252
"text": [
253-
"Document: Opening a NISA Account -> 🤖 Score: 0.45698774\n",
254-
"Document: Opening a Regular Savings Account -> 🤖 Score: 0.48092696\n",
255-
"Document: Home Loan Application Guide -> 🤖 Score: 0.42127067\n"
253+
"Document: Opening a NISA Account -> 🤖 Score: 0.51571906\n",
254+
"Document: Opening a Regular Savings Account -> 🤖 Score: 0.5035889\n",
255+
"Document: Home Loan Application Guide -> 🤖 Score: 0.4406476\n"
256256
]
257257
}
258258
],
@@ -261,8 +261,8 @@
261261
"\n",
262262
"def get_scores(query, documents):\n",
263263
" # Calculate embeddings by calling model.encode()\n",
264-
" query_embeddings = model.encode(query, prompt=task_name)\n",
265-
" doc_embeddings = model.encode(documents, prompt=task_name)\n",
264+
" query_embeddings = model.encode(query, prompt_name=task_name)\n",
265+
" doc_embeddings = model.encode(documents, prompt_name=task_name)\n",
266266
"\n",
267267
" # Calculate the embedding similarities\n",
268268
" similarities = model.similarity(query_embeddings, doc_embeddings)\n",
@@ -341,35 +341,35 @@
341341
"output_type": "stream",
342342
"text": [
343343
"Step 3 finished. Running evaluation:\n",
344-
"Document: Opening a NISA Account -> 🤖 Score: 0.6449194\n",
345-
"Document: Opening a Regular Savings Account -> 🤖 Score: 0.44123\n",
346-
"Document: Home Loan Application Guide -> 🤖 Score: 0.46752414\n",
344+
"Document: Opening a NISA Account -> 🤖 Score: 0.6459116\n",
345+
"Document: Opening a Regular Savings Account -> 🤖 Score: 0.42690125\n",
346+
"Document: Home Loan Application Guide -> 🤖 Score: 0.40419024\n",
347347
"Step 6 finished. Running evaluation:\n",
348-
"Document: Opening a NISA Account -> 🤖 Score: 0.68873787\n",
349-
"Document: Opening a Regular Savings Account -> 🤖 Score: 0.34069622\n",
350-
"Document: Home Loan Application Guide -> 🤖 Score: 0.50065553\n",
348+
"Document: Opening a NISA Account -> 🤖 Score: 0.68530923\n",
349+
"Document: Opening a Regular Savings Account -> 🤖 Score: 0.3611964\n",
350+
"Document: Home Loan Application Guide -> 🤖 Score: 0.40812016\n",
351351
"Step 9 finished. Running evaluation:\n",
352-
"Document: Opening a NISA Account -> 🤖 Score: 0.7148906\n",
353-
"Document: Opening a Regular Savings Account -> 🤖 Score: 0.30480516\n",
354-
"Document: Home Loan Application Guide -> 🤖 Score: 0.52454984\n",
352+
"Document: Opening a NISA Account -> 🤖 Score: 0.7168733\n",
353+
"Document: Opening a Regular Savings Account -> 🤖 Score: 0.3449782\n",
354+
"Document: Home Loan Application Guide -> 🤖 Score: 0.44477722\n",
355355
"Step 12 finished. Running evaluation:\n",
356-
"Document: Opening a NISA Account -> 🤖 Score: 0.72614634\n",
357-
"Document: Opening a Regular Savings Account -> 🤖 Score: 0.29255486\n",
358-
"Document: Home Loan Application Guide -> 🤖 Score: 0.5370023\n",
356+
"Document: Opening a NISA Account -> 🤖 Score: 0.73008573\n",
357+
"Document: Opening a Regular Savings Account -> 🤖 Score: 0.34124148\n",
358+
"Document: Home Loan Application Guide -> 🤖 Score: 0.4676212\n",
359359
"Step 15 finished. Running evaluation:\n",
360-
"Document: Opening a NISA Account -> 🤖 Score: 0.7294032\n",
361-
"Document: Opening a Regular Savings Account -> 🤖 Score: 0.2893038\n",
362-
"Document: Home Loan Application Guide -> 🤖 Score: 0.54087913\n",
360+
"Document: Opening a NISA Account -> 🤖 Score: 0.73378766\n",
361+
"Document: Opening a Regular Savings Account -> 🤖 Score: 0.34055778\n",
362+
"Document: Home Loan Application Guide -> 🤖 Score: 0.47503752\n",
363363
"Step 15 finished. Running evaluation:\n",
364-
"Document: Opening a NISA Account -> 🤖 Score: 0.7294032\n",
365-
"Document: Opening a Regular Savings Account -> 🤖 Score: 0.2893038\n",
366-
"Document: Home Loan Application Guide -> 🤖 Score: 0.54087913\n"
364+
"Document: Opening a NISA Account -> 🤖 Score: 0.73378766\n",
365+
"Document: Opening a Regular Savings Account -> 🤖 Score: 0.34055778\n",
366+
"Document: Home Loan Application Guide -> 🤖 Score: 0.47503752\n"
367367
]
368368
},
369369
{
370370
"data": {
371371
"text/plain": [
372-
"TrainOutput(global_step=15, training_loss=0.009651281436261646, metrics={'train_runtime': 63.2486, 'train_samples_per_second': 0.237, 'train_steps_per_second': 0.237, 'total_flos': 0.0, 'train_loss': 0.009651281436261646, 'epoch': 5.0})"
372+
"TrainOutput(global_step=15, training_loss=0.009651267528511198, metrics={'train_runtime': 195.3004, 'train_samples_per_second': 0.077, 'train_steps_per_second': 0.077, 'total_flos': 0.0, 'train_loss': 0.009651267528511198, 'epoch': 5.0})"
373373
]
374374
},
375375
"execution_count": 8,
@@ -431,9 +431,9 @@
431431
"\n",
432432
"The same search now yields much clearer results:\n",
433433
"\n",
434-
"1. Document: Opening a NISA account (Score: 0.72) <- *Much more confident*\n",
435-
"2. Document: Opening a Regular Saving Account (Score: 0.28) <- *Clearly less relevant*\n",
436-
"3. Document: Home Loan Application Guide (Score: 0.54)"
434+
"1. Document: Opening a NISA account (Score: 0.73) <- *Much more confident*\n",
435+
"2. Document: Opening a Regular Saving Account (Score: 0.34) <- *Clearly less relevant*\n",
436+
"3. Document: Home Loan Application Guide (Score: 0.47)"
437437
]
438438
},
439439
{
@@ -447,9 +447,9 @@
447447
"name": "stdout",
448448
"output_type": "stream",
449449
"text": [
450-
"Document: Opening a NISA Account -> 🤖 Score: 0.7294032\n",
451-
"Document: Opening a Regular Savings Account -> 🤖 Score: 0.2893038\n",
452-
"Document: Home Loan Application Guide -> 🤖 Score: 0.54087913\n"
450+
"Document: Opening a NISA Account -> 🤖 Score: 0.73378766\n",
451+
"Document: Opening a Regular Savings Account -> 🤖 Score: 0.34055778\n",
452+
"Document: Home Loan Application Guide -> 🤖 Score: 0.47503752\n"
453453
]
454454
}
455455
],

0 commit comments

Comments
 (0)