|
232 | 232 | "\n", |
233 | 233 | "A search for \"tax-free investment\" might have given the following results, with similarity scores:\n", |
234 | 234 | "\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", |
238 | 238 | "\n", |
239 | 239 | "> 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)." |
240 | 240 | ] |
|
250 | 250 | "name": "stdout", |
251 | 251 | "output_type": "stream", |
252 | 252 | "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" |
256 | 256 | ] |
257 | 257 | } |
258 | 258 | ], |
|
261 | 261 | "\n", |
262 | 262 | "def get_scores(query, documents):\n", |
263 | 263 | " # 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", |
266 | 266 | "\n", |
267 | 267 | " # Calculate the embedding similarities\n", |
268 | 268 | " similarities = model.similarity(query_embeddings, doc_embeddings)\n", |
|
341 | 341 | "output_type": "stream", |
342 | 342 | "text": [ |
343 | 343 | "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", |
347 | 347 | "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", |
351 | 351 | "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", |
355 | 355 | "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", |
359 | 359 | "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", |
363 | 363 | "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" |
367 | 367 | ] |
368 | 368 | }, |
369 | 369 | { |
370 | 370 | "data": { |
371 | 371 | "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})" |
373 | 373 | ] |
374 | 374 | }, |
375 | 375 | "execution_count": 8, |
|
431 | 431 | "\n", |
432 | 432 | "The same search now yields much clearer results:\n", |
433 | 433 | "\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)" |
437 | 437 | ] |
438 | 438 | }, |
439 | 439 | { |
|
447 | 447 | "name": "stdout", |
448 | 448 | "output_type": "stream", |
449 | 449 | "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" |
453 | 453 | ] |
454 | 454 | } |
455 | 455 | ], |
|
0 commit comments