language:-enlicense:apache-2.0tags:-sentence-transformers-sentence-similarity-feature-extraction-generated_from_trainer-dataset_size:5146-loss:MatryoshkaLoss-loss:MultipleNegativesRankingLossbase_model:sentence-transformers/all-mpnet-base-v2widget:-source_sentence:>- import subprocesszen_of_python=subprocess.check_output(["python","-c","import this"])corpus=zen_of_python.split()num_partitions=3chunk=len(corpus)//num_partitionspartitions= [
corpus[i*chunk:(i+1)*chunk] foriinrange(num_partitions)
]
MappingData#Todeterminethemapphase,werequireamapfunctiontouseoneachdocument.Theoutputisthepair(word,1)foreverywordfoundinadocument.ForbasictextdocumentsweloadasPythonstrings,theprocessisasfollows:defmap_function(document):forwordindocument.lower().split():yieldword,1Weusetheapply_mapfunctiononalargecollectionofdocumentsbymarkingitasataskinRayusingthe@ray.remotedecorator.Whenwecallapply_map,weapplyittothreesetsofdocumentdata(num_partitions=3).Theapply_mapfunctionreturnsthreelists,oneforeachpartitionsothatRaycanrearrangetheresultsofthemapphaseanddistributethemtotheappropriatenodes.importraysentences:-Whatdoesthemap_functionyieldforeachwordinadocument?->- What does PBT do differently from traditional hyperparameter tuning methods?->- What is returned by task_with_static_multiple_returns_good in the Actor class?-source_sentence:>- 192.168.0.15 7241 Worker ffffffffffffffffffffffffffffffffffffffff0100000001000000 10 MiB PINNED_IN_MEMORY (deserialize task arg)__main__.f192.168.0.157207 Driverffffffffffffffffffffffffffffffffffffffff010000000100000015MiBUSED_BY_PENDING_TASK(putobject)test.py:<module>:28Whilethetaskisrunning,weseethatraymemoryshowsbothaLOCAL_REFERENCEandaUSED_BY_PENDING_TASKreferencefortheobjectinthedriverprocess.TheworkerprocessalsoholdsareferencetotheobjectbecausethePythonargisdirectlyreferencingthememoryintheplasma,soitcan’tbeevicted;thereforeitisPINNED_IN_MEMORY.4.SerializedObjectRefreferences@ray.remotedeff(arg):while True:passa=ray.put(None)b=f.remote([a])sentences:-Howcanadatasetbecreatedfromin-memorydata?-WhatdoesAlgorithm.training_stepreturnforthenewAPIstack?->- Why can't the object be evicted while the worker process holds a reference?-source_sentence:>- For distributed systems engineers, Ray automatically handles key processes:Orchestration–Managingthevariouscomponentsofadistributedsystem.Scheduling–Coordinatingwhenandwheretasksareexecuted.Faulttolerance–Ensuringtaskscompleteregardlessofinevitablepointsoffailure.Auto-scaling–Adjustingthenumberofresourcesallocatedtodynamicdemand.WhatyoucandowithRay#ThesearesomecommonMLworkloadsthatindividuals,organizations,andcompanies leverage Ray to build their AI applications:BatchinferenceonCPUsandGPUsModelservingDistributedtrainingoflargemodelsParallelhyperparametertuningexperimentsReinforcementlearningMLplatformRayframework#StackofRaylibraries-unifiedtoolkitforMLworkloads.Ray’sunified compute framework consists of three layers:sentences:-Whatdoesremote_worker_envscontrolwhennum_envs_per_env_runner>1?-Howisthelearningratesetintheconfig?->- According to the excerpt, what does Ray automatically handle for distributed systems engineers?-source_sentence:>- RLlib component tree#ThefollowingisthestructureoftheRLlibcomponenttree,showingunderwhichnameyoucanaccessasubcomponent’sowncheckpointwithinthehigher-levelcheckpoint.Atthehighestlevelis the Algorithm class:algorithm/learner_group/learner/rl_module/default_policy/# <- single-agent case
[moduleID1]/# <- multi-agent case
[moduleID2]/# ...env_runner/env_to_module_connector/module_to_env_connector/NoteTheenv_runner/subcomponentcurrentlydoesn’tholdacopyoftheRLModulecheckpointbecauseit’salreadysavedunderlearner/.TheRayteamisworkingonresolvingthisissue,probablythroughsoft-linkingtoavoidduplicatefilesandunnecessarydiskusage.Creatinginstancesfromacheckpointwithfrom_checkpoint#OnceyouhaveacheckpointofeitheratrainedAlgorithmoranyofitssubcomponents,youcanrecreatenewobjectsdirectlyfromthischeckpoint.The following are two examples:sentences:-WhydoesRLlibconverteachrowintoasingle-stepepisodebydefault?-WhatisatthehighestleveloftheRLlibcomponenttree?->- What is recommended regarding AOF when using storage options that do not support append operations?-source_sentence:>- Option 2: Manually Create URL (slower to implement, but recommended for production environments)#ThesecondoptionistomanuallycreatethisURLbypattern-matchingyourspecificusecasewithoneofthefollowingexamples.Thisisrecommendedbecauseitprovidesfiner-grainedcontroloverwhichrepositorybranchandcommittousewhengeneratingyourdependencyzipfile.TheseoptionspreventconsistencyissuesonRayClusters(seethewarningaboveformoreinfo).TocreatetheURL,pickaURLtemplatebelowthatfitsyourusecase,andfillinallparametersinbrackets(e.g. [username], [repository],etc.)withthespecificvaluesfromyourrepository.Forinstance,supposeyourGitHubusernameisexample_user,therepository’snameisexample_repository,andthedesiredcommithashisabcdefg.Ifexample_repositoryispublicandyouwanttoretrievetheabcdefgcommit(whichmatchesthefirstexampleusecase),the URL would be:sentences:-WhatcanRayTrainandRayTunebeusedtogetherfor?-HowdoyoucreatetheURLforOption2?->- Which function can you use to read a CSV file for batch processing in Ray?pipeline_tag:sentence-similaritylibrary_name:sentence-transformersmetrics:-cosine_accuracy@1-cosine_accuracy@3-cosine_accuracy@5-cosine_accuracy@10-cosine_precision@1-cosine_precision@3-cosine_precision@5-cosine_precision@10-cosine_recall@1-cosine_recall@3-cosine_recall@5-cosine_recall@10-cosine_ndcg@10-cosine_mrr@10-cosine_map@100model-index:-name:Fine-tune-all-mpnet-base-v2results:-task:type:information-retrievalname:InformationRetrievaldataset:name:dim768type:dim_768metrics:-type:cosine_accuracy@1value:0.5874125874125874name:CosineAccuracy@1-type:cosine_accuracy@3value:0.6818181818181818name:CosineAccuracy@3-type:cosine_accuracy@5value:0.7954545454545454name:CosineAccuracy@5-type:cosine_accuracy@10value:0.8863636363636364name:CosineAccuracy@10-type:cosine_precision@1value:0.5874125874125874name:CosinePrecision@1-type:cosine_precision@3value:0.5180652680652681name:CosinePrecision@3-type:cosine_precision@5value:0.3944055944055945name:CosinePrecision@5-type:cosine_precision@10value:0.23199300699300698name:CosinePrecision@10-type:cosine_recall@1value:0.263986013986014name:CosineRecall@1-type:cosine_recall@3value:0.6073717948717948name:CosineRecall@3-type:cosine_recall@5value:0.7521853146853147name:CosineRecall@5-type:cosine_recall@10value:0.8780594405594405name:CosineRecall@10-type:cosine_ndcg@10value:0.7386606603331115name:CosineNdcg@10-type:cosine_mrr@10value:0.6635614385614379name:CosineMrr@10-type:cosine_map@100value:0.6988731642119342name:CosineMap@100-task:type:information-retrievalname:InformationRetrievaldataset:name:dim512type:dim_512metrics:-type:cosine_accuracy@1value:0.5734265734265734name:CosineAccuracy@1-type:cosine_accuracy@3value:0.666083916083916name:CosineAccuracy@3-type:cosine_accuracy@5value:0.8006993006993007name:CosineAccuracy@5-type:cosine_accuracy@10value:0.8811188811188811name:CosineAccuracy@10-type:cosine_precision@1value:0.5734265734265734name:CosinePrecision@1-type:cosine_precision@3value:0.5052447552447552name:CosinePrecision@3-type:cosine_precision@5value:0.39370629370629373name:CosinePrecision@5-type:cosine_precision@10value:0.23094405594405593name:CosinePrecision@10-type:cosine_recall@1value:0.26005244755244755name:CosineRecall@1-type:cosine_recall@3value:0.5914918414918414name:CosineRecall@3-type:cosine_recall@5value:0.7543706293706294name:CosineRecall@5-type:cosine_recall@10value:0.8726689976689977name:CosineRecall@10-type:cosine_ndcg@10value:0.7303335650898982name:CosineNdcg@10-type:cosine_mrr@10value:0.652235958485958name:CosineMrr@10-type:cosine_map@100value:0.689387057080973name:CosineMap@100-task:type:information-retrievalname:InformationRetrievaldataset:name:dim256type:dim_256metrics:-type:cosine_accuracy@1value:0.5664335664335665name:CosineAccuracy@1-type:cosine_accuracy@3value:0.666083916083916name:CosineAccuracy@3-type:cosine_accuracy@5value:0.7797202797202797name:CosineAccuracy@5-type:cosine_accuracy@10value:0.8583916083916084name:CosineAccuracy@10-type:cosine_precision@1value:0.5664335664335665name:CosinePrecision@1-type:cosine_precision@3value:0.5011655011655011name:CosinePrecision@3-type:cosine_precision@5value:0.38636363636363635name:CosinePrecision@5-type:cosine_precision@10value:0.22534965034965035name:CosinePrecision@10-type:cosine_recall@1value:0.2577214452214452name:CosineRecall@1-type:cosine_recall@3value:0.5893065268065268name:CosineRecall@3-type:cosine_recall@5value:0.7354312354312353name:CosineRecall@5-type:cosine_recall@10value:0.8487762237762237name:CosineRecall@10-type:cosine_ndcg@10value:0.7167871578299232name:CosineNdcg@10-type:cosine_mrr@10value:0.6432942057942053name:CosineMrr@10-type:cosine_map@100value:0.6823584299690649name:CosineMap@100-task:type:information-retrievalname:InformationRetrievaldataset:name:dim128type:dim_128metrics:-type:cosine_accuracy@1value:0.5402097902097902name:CosineAccuracy@1-type:cosine_accuracy@3value:0.6398601398601399name:CosineAccuracy@3-type:cosine_accuracy@5value:0.743006993006993name:CosineAccuracy@5-type:cosine_accuracy@10value:0.8304195804195804name:CosineAccuracy@10-type:cosine_precision@1value:0.5402097902097902name:CosinePrecision@1-type:cosine_precision@3value:0.47960372960372966name:CosinePrecision@3-type:cosine_precision@5value:0.3678321678321678name:CosinePrecision@5-type:cosine_precision@10value:0.2181818181818182name:CosinePrecision@10-type:cosine_recall@1value:0.24519230769230768name:CosineRecall@1-type:cosine_recall@3value:0.5623543123543123name:CosineRecall@3-type:cosine_recall@5value:0.701048951048951name:CosineRecall@5-type:cosine_recall@10value:0.8228438228438228name:CosineRecall@10-type:cosine_ndcg@10value:0.6886328428362513name:CosineNdcg@10-type:cosine_mrr@10value:0.6146582584082584name:CosineMrr@10-type:cosine_map@100value:0.6543671947827556name:CosineMap@100-task:type:information-retrievalname:InformationRetrievaldataset:name:dim64type:dim_64metrics:-type:cosine_accuracy@1value:0.4353146853146853name:CosineAccuracy@1-type:cosine_accuracy@3value:0.5332167832167832name:CosineAccuracy@3-type:cosine_accuracy@5value:0.6311188811188811name:CosineAccuracy@5-type:cosine_accuracy@10value:0.7622377622377622name:CosineAccuracy@10-type:cosine_precision@1value:0.4353146853146853name:CosinePrecision@1-type:cosine_precision@3value:0.3945221445221445name:CosinePrecision@3-type:cosine_precision@5value:0.3094405594405594name:CosinePrecision@5-type:cosine_precision@10value:0.19825174825174827name:CosinePrecision@10-type:cosine_recall@1value:0.19842657342657344name:CosineRecall@1-type:cosine_recall@3value:0.46547202797202797name:CosineRecall@3-type:cosine_recall@5value:0.5910547785547785name:CosineRecall@5-type:cosine_recall@10value:0.7467948717948718name:CosineRecall@10-type:cosine_ndcg@10value:0.5953015131317417name:CosineNdcg@10-type:cosine_mrr@10value:0.5138784826284825name:CosineMrr@10-type:cosine_map@100value:0.559206100539383name:CosineMap@100
Fine-tune-all-mpnet-base-v2
This is a sentence-transformers model finetuned from sentence-transformers/all-mpnet-base-v2 on the json dataset. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
from sentence_transformers import SentenceTransformer
# Download from the 🤗 Hub
model = SentenceTransformer("thanhpham1/Fine-tune-all-mpnet-base-v2")
# Run inference
sentences = [
'Option 2: Manually Create URL (slower to implement, but recommended for production environments)#\nThe second option is to manually create this URL by pattern-matching your specific use case with one of the following examples.\nThis is recommended because it provides finer-grained control over which repository branch and commit to use when generating your dependency zip file.\nThese options prevent consistency issues on Ray Clusters (see the warning above for more info).\nTo create the URL, pick a URL template below that fits your use case, and fill in all parameters in brackets (e.g. [username], [repository], etc.) with the specific values from your repository.\nFor instance, suppose your GitHub username is example_user, the repository’s name is example_repository, and the desired commit hash is abcdefg.\nIf example_repository is public and you want to retrieve the abcdefg commit (which matches the first example use case), the URL would be:',
'How do you create the URL for Option 2?',
'What can Ray Train and Ray Tune be used together for?',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
Approximate statistics based on the first 1000 samples:
anchor
positive
type
string
string
details
min: 8 tokens
mean: 17.8 tokens
max: 41 tokens
min: 66 tokens
mean: 225.02 tokens
max: 384 tokens
Samples:
anchor
positive
Does Ray Train work with vanilla TensorFlow in addition to TensorFlow with Keras?
Get Started with Distributed Training using TensorFlow/Keras# Ray Train’s TensorFlow integration enables you to scale your TensorFlow and Keras training functions to many machines and GPUs. On a technical level, Ray Train schedules your training workers and configures TF_CONFIG for you, allowing you to run your MultiWorkerMirroredStrategy training script. See Distributed training with TensorFlow for more information. Most of the examples in this guide use TensorFlow with Keras, but Ray Train also works with vanilla TensorFlow.
Quickstart# import ray import tensorflow as tf
from ray import train from ray.train import ScalingConfig from ray.train.tensorflow import TensorflowTrainer from ray.train.tensorflow.keras import ReportCheckpointCallback
# If using GPUs, set this to True. use_gpu = False
a = 5 b = 10 size = 100
What type of failure can Ray automatically recover from?
Ray can automatically recover from data loss but not owner failure.
Recovering from data loss# When an object value is lost from the object store, such as during node failures, Ray will use lineage reconstruction to recover the object. Ray will first automatically attempt to recover the value by looking for copies of the same object on other nodes. If none are found, then Ray will automatically recover the value by re-executing the task that previously created the value. Arguments to the task are recursively reconstructed through the same mechanism. Lineage reconstruction currently has the following limitations:
From which directory should you run the zip command to ensure the proper zip file structure?
Suppose instead you want to host your files in your /some_path/example_dir directory remotely and provide a remote URI. You would need to first compress the example_dir directory into a zip file. There should be no other files or directories at the top level of the zip file, other than example_dir. You can use the following command in the Terminal to do this: cd /some_path zip -r zip_file_name.zip example_dir
Note that this command must be run from the parent directory of the desired working_dir to ensure that the resulting zip file contains a single top-level directory. In general, the zip file’s name and the top-level directory’s name can be anything. The top-level directory’s contents will be used as the working_dir (or py_module). You can check that the zip file contains a single top-level directory by running the following command in the Terminal: zipinfo -1 zip_file_name.zip # example_dir/ # example_dir/my_file_1.txt # example_dir/subdir/my_file_2.txt
@inproceedings{reimers-2019-sentence-bert,
title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
author = "Reimers, Nils and Gurevych, Iryna",
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
month = "11",
year = "2019",
publisher = "Association for Computational Linguistics",
url = "https://arxiv.org/abs/1908.10084",
}
MatryoshkaLoss
@misc{kusupati2024matryoshka,
title={Matryoshka Representation Learning},
author={Aditya Kusupati and Gantavya Bhatt and Aniket Rege and Matthew Wallingford and Aditya Sinha and Vivek Ramanujan and William Howard-Snyder and Kaifeng Chen and Sham Kakade and Prateek Jain and Ali Farhadi},
year={2024},
eprint={2205.13147},
archivePrefix={arXiv},
primaryClass={cs.LG}
}
MultipleNegativesRankingLoss
@misc{henderson2017efficient,
title={Efficient Natural Language Response Suggestion for Smart Reply},
author={Matthew Henderson and Rami Al-Rfou and Brian Strope and Yun-hsuan Sung and Laszlo Lukacs and Ruiqi Guo and Sanjiv Kumar and Balint Miklos and Ray Kurzweil},
year={2017},
eprint={1705.00652},
archivePrefix={arXiv},
primaryClass={cs.CL}
}