AI4free/JARVIS-tool-search-v1
SentenceTransformer based on minishlab/potion-base-8M
This is a sentence-transformers model finetuned from minishlab/potion-base-8M. It maps sentences & paragraphs to a 256-dimensional dense vector space and can be used for retrieval.
Model Details
Model Description
- Model Type: Sentence Transformer
- Base model: minishlab/potion-base-8M <!-- at revision bf8b056651a2c21b8d2565580b8569da283cab23 -->
- Maximum Sequence Length: inf tokens
- Output Dimensionality: 256 dimensions
- Similarity Function: Cosine Similarity
- Supported Modality: Text <!-- - Training Dataset: Unknown --> <!-- - Language: Unknown --> <!-- - License: Unknown -->
Model Sources
- Documentation: Sentence Transformers Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face: Sentence Transformers on Hugging Face
Full Model Architecture
SentenceTransformer(
(0): StaticEmbedding({})
)Usage
Direct Usage (Sentence Transformers)
First install the Sentence Transformers library:
pip install -U sentence-transformersThen you can load this model and run inference.
from sentence_transformers import SentenceTransformer
# Download from the 🤗 Hub
model = SentenceTransformer("sentence_transformers_model_id")
# Run inference
sentences = [
'Find python code: Convert the SDP relaxation to a human-readable format.\n\n :param sdp: The SDP relaxation to write.\n :type sdp: :class:`ncpol2sdpa.sdp`.\n :returns: tuple of the objective function in a string and a matrix of\n strings as the symbolic representation of the moment matrix',
'python function `convert_to_human_readable`:\ndef convert_to_human_readable(sdp):\n """Convert the SDP relaxation to a human-readable format.\n\n :param sdp: The SDP relaxation to write.\n :type sdp: :class:`ncpol2sdpa.sdp`.\n :returns: tuple of the objective function in a string and a matrix of\n strings as the symbolic representation of the moment matrix\n """\n\n objective = ""\n indices_in_objective = []\n for i, tmp in enumerate(sdp.obj_facvar):\n candidates = [key for key, v in\n sdp.monomial_index.items() if v == i+1]\n if len(candidates) > 0:\n monomial = convert_monomial_to_string(candidates[0])\n else:\n monomial = ""\n if tmp > 0:\n objective += "+"+str(tmp)+monomial\n indices_in_objective.append(i)\n elif tmp < 0:\n objective += str(tmp)+monomial\n indices_in_objective.append(i)\n\n matrix_size = 0\n cumulative_sum = 0\n row_offsets = [0]\n block_offset = [0]\n for bs in sdp.block_struct:\n matrix_size += abs(bs)\n cumulative_sum += bs ** 2\n row_offsets.append(cumulative_sum)\n block_offset.append(matrix_size)\n\n matrix = []\n for i in range(matrix_size):\n matrix_line = ["0"] * matrix_size\n matrix.append(matrix_line)\n\n for row in range(len(sdp.F.rows)):\n if len(sdp.F.rows[row]) > 0:\n col_index = 0\n for k in sdp.F.rows[row]:\n value = sdp.F.data[row][col_index]\n col',
'Solution (swift):\nCustom Collection View Layout Class:\n```swift\nimport UIKit\n\nclass CustomCollectionViewLayout: UICollectionViewLayout {\n let sectionInset = UIEdgeInsets(top: 20, left: 2, bottom: 20, right: 2)\n var itemSize: CGFloat = 50 // Replace with the desired item size\n\n override func prepare() {\n // Implement layout preparation logic here\n }\n\n override var collectionViewContentSize: CGSize {\n // Calculate and return the total content size of the collection view\n return CGSize.zero\n }\n\n override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {\n // Calculate and return the layout attributes for the items that intersect with the given rect\n return nil\n }\n}\n```\n\nView Controller:\n```swift\nimport UIKit\n\nclass MedicalRecordsViewController: UIViewController {\n let collectionView = UICollectionView(frame: .zero, collectionViewLayout: CustomCollectionViewLayout())\n let patient = Patient() // Assume Patient class is defined elsewhere\n\n override func viewDidLoad() {\n super.viewDidLoad()\n let layout = collectionView.collectionViewLayout as! CustomCollectionViewLayout\n layout.sectionInset = UIEdgeInsets(top: 20, left: 2, bottom: 20, right: 2)\n layout.itemSize = CGSize(width: layout.itemSize, height: layout.itemSize)\n layout.minimumInteritemSpacing = 5\n layout.minimumLineSpacing = 5\n self.collectionView.collectionViewLayout = layout\n }\n\n o',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 256]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[ 1.0000, 0.6170, -0.1287],
# [ 0.6170, 1.0000, -0.0954],
# [-0.1287, -0.0954, 1.0000]])<!--
Direct Usage (Transformers)
<details><summary>Click to see the direct usage in Transformers</summary>
</details> -->
<!--
Downstream Usage (Sentence Transformers)
You can finetune this model on your own dataset.
<details><summary>Click to expand</summary>
</details> -->
<!--
Out-of-Scope Use
List how the model may foreseeably be misused and address what users ought not to do with the model. -->
<!--
Bias, Risks and Limitations
What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model. -->
<!--
Recommendations
What are recommendations with respect to the foreseeable issues? For example, filtering explicit content. -->
Training Details
Training Dataset
Unnamed Dataset
- Size: 421,264 training samples
- Columns: <code>anchor</code> and <code>positive</code>
- Approximate statistics based on the first 100 samples: | | anchor | positive | |:---------|:--------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------| | type | string | string | | modality | text | text | | details | <ul><li>min: 29 characters</li><li>mean: 238.62 characters</li><li>max: 2706 characters</li></ul> | <ul><li>min: 63 characters</li><li>mean: 533.32 characters</li><li>max: 1573 characters</li></ul> |
- Samples: | anchor | positive | |:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>Find go code: // SetPriority sets the Priority field's value.</code> | <code>go function
SetPriority:<br>func (s UpdateMaintenanceWindowTaskInput) SetPriority(v int64) UpdateMaintenanceWindowTaskInput {<br> s.Priority = &v<br> return s<br>}</code> | | <code>Find php code: Prepare a has-one-deep or has-many-deep relationship from an existing has-many-through relationship.<br><br>@param \Illuminate\Database\Eloquent\Relations\HasManyThrough $relation<br>@param \Illuminate\Database\Eloquent\Model[] $through<br>@param array $foreignKeys<br>@param array $localKeys<br>@return array</code> | <code>php functionConcatenatesRelationships.hasOneOrManyDeepFromHasManyThrough:<br>protected function hasOneOrManyDeepFromHasManyThrough(HasManyThrough $relation, array $through, array $foreignKeys, array $localKeys)<br> {<br> $through[] = get_class($relation->getParent());<br><br> $foreignKeys[] = $relation->getFirstKeyName();<br> $foreignKeys[] = $relation->getForeignKeyName();<br><br> $localKeys[] = $relation->getLocalKeyName();<br> $localKeys[] = $relation->getSecondLocalKeyName();<br><br> return [$through, $foreignKeys, $localKeys];<br> }</code> | | <code>Find go code: // GetServiceInstances returns back a list of managed Service Instances based<br>// off of the provided filters.</code> | <code>go functionGetServiceInstances:<br>func (client *Client) GetServiceInstances(filters ...Filter) ([]ServiceInstance, Warnings, error) {<br> request, err := client.newHTTPRequest(requestOptions{<br> RequestName: internal.GetServiceInstancesRequest,<br> Query: ConvertFilterParameters(filters),<br> })<br> if err != nil {<br> return nil, nil, err<br> }<br><br> var fullInstancesList []ServiceInstance<br> warnings, err := client.paginate(request, ServiceInstance{}, func(item interface{}) error {<br> if instance, ok := item.(ServiceInstance); ok {<br> fullInstancesList = append(fullInstancesList, instance)<br> } else {<br> return ccerror.UnknownObjectInListError{<br> Expected: ServiceInstance{},<br> Unexpected: item,<br> }<br> }<br> return nil<br> })<br><br> return fullInstancesList, warnings, err<br>}</code> | - Loss: <code>MultipleNegativesRankingLoss</code> with these parameters:
{
"scale": 20.0,
"similarity_fct": "cos_sim",
"gather_across_devices": false,
"directions": [
"query_to_doc"
],
"partition_mode": "joint",
"hardness_mode": null,
"hardness_strength": 0.0
}Evaluation Dataset
Unnamed Dataset
- Size: 2,000 evaluation samples
- Columns: <code>anchor</code> and <code>positive</code>
- Approximate statistics based on the first 100 samples: | | anchor | positive | |:---------|:--------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------| | type | string | string | | modality | text | text | | details | <ul><li>min: 28 characters</li><li>mean: 206.54 characters</li><li>max: 1078 characters</li></ul> | <ul><li>min: 76 characters</li><li>mean: 713.74 characters</li><li>max: 1556 characters</li></ul> |
- Samples: | anchor | positive | |:--------------------------------------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>Find php code: {@inheritDoc}</code> | <code>php function
BuildConfigsPass.process:<br>public function process(ContainerBuilder $container)<br> {<br> $configs = $this->processTagData($container->findTaggedServiceIds('payum.action'), 'payum.action.', 'payum.prependactions');<br> $configs = arrayreplacerecursive(<br> $configs,<br> $this->processTagData($container->findTaggedServiceIds('payum.api'), 'payum.api.', 'payum.prependapis')<br> );<br> $configs = arrayreplacerecursive(<br> $configs,<br> $this->processTagData($container->findTaggedServiceIds('payum.extension'), 'payum.extension.', 'payum.prepend_extensions')<br> );<br><br> $builder = $container->getDefinition('payum.builder');<br> if ($container->hasDefinition('twig')) {<br> $config = ['twig.env' => '@twig'];<br><br> $builder->addMethodCall('addCoreGatewayFactoryConfig', [$config]);<br> }<br><br> if (false == empty($configs[0])) {<br> $builder->addMethodCall('addCoreGatewayFactoryConfig',...</code> | | <code>Code search (javascript): This function returns the index where we need to split the menu</code> | <code>javascript code:<br>function calculateNumberOfItemsInMenu(menuWidth, items, moreMenuItem){ <br> <br> var itemsWidth = 0; <br> var itemsWidthGrowth = []; <br> var splitMenuAt; <br> items.each(function(i){ <br> var item = jQuery(this); <br> if (item.is(':visible')) { <br> itemsWidth += item.children('a').outerWidth(); <br> } else { <br> item.show(); <br> itemsWidth += item.children('a').outerWidth(); <br> item.hide(); <br> } <br> if (i > 0) { <br> itemsWidth -= 6; <br> } <br> itemsWidthGrowth[i] = itemsWidth; <br> }); <br> <br> //Test if there is room without more-btn <br> if((menuWidth - moreMenuItem.outerWidth(true)) > itemsWidthGrowth[items.length - 1] && moreMenuItem.is(":visible")){ <br> ...</code> | | <code>Find javascript code: get ast of template<br>@param {String} [name] xtemplate name<br>@param {String} tplContent<br>@return {Object}</code> | <code>javascript function ``:<br>function (tplContent, name) {<br> if (tplContent) {<br> var ret;<br> try {<br> ret = parser.parse(tplContent, name);<br> } catch (err) {<br> var e;<br> if (err instanceof Error) {<br> e = err;<br> } else {<br> e = new Error(err);<br> }<br> var errorStr = 'XTemplate error ';<br> e.stack = errorStr + e.stack;<br> e.message = errorStr + e.message;<br> throw e;<br> }<br> return ret;<br> } else {<br> return {<br> statements: []<br> };<br> }<br> }</code> | - Loss: <code>MultipleNegativesRankingLoss</code> with these parameters:
{
"scale": 20.0,
"similarity_fct": "cos_sim",
"gather_across_devices": false,
"directions": [
"query_to_doc"
],
"partition_mode": "joint",
"hardness_mode": null,
"hardness_strength": 0.0
}Training Hyperparameters
Non-Default Hyperparameters
per_device_train_batch_size: 512num_train_epochs: 10learning_rate: 0.03lr_scheduler_type: cosinewarmup_steps: 0.1disable_tqdm: Trueper_device_eval_batch_size: 512load_best_model_at_end: Truedataloader_drop_last: Truebatch_sampler: no_duplicates
All Hyperparameters
<details><summary>Click to expand</summary>
per_device_train_batch_size: 512num_train_epochs: 10max_steps: -1learning_rate: 0.03lr_scheduler_type: cosinelr_scheduler_kwargs: Nonewarmup_steps: 0.1optim: adamwtorchfusedoptim_args: Noneweight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08optim_target_modules: Nonegradient_accumulation_steps: 1average_tokens_across_devices: Truemax_grad_norm: 1.0label_smoothing_factor: 0.0bf16: Falsefp16: Falsebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Nonetorch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneuse_liger_kernel: Falseliger_kernel_config: Noneuse_cache: Falseneftune_noise_alpha: Nonetorch_empty_cache_steps: Noneauto_find_batch_size: Falselog_on_each_node: Truelogging_nan_inf_filter: Trueinclude_num_input_tokens_seen: nolog_level: passivelog_level_replica: warningdisable_tqdm: Trueproject: huggingfacetrackio_space_id: Nonetrackio_bucket_id: Nonetrackio_static_space_id: Noneper_device_eval_batch_size: 512prediction_loss_only: Trueeval_on_start: Falseeval_do_concat_batches: Trueeval_use_gather_object: Falseeval_accumulation_steps: Noneinclude_for_metrics: []batch_eval_metrics: Falsesave_only_model: Falsesave_on_each_node: Falseenable_jit_checkpoint: Falsepush_to_hub: Falsehub_private_repo: Nonehub_model_id: Nonehub_strategy: every_savehub_always_push: Falsehub_revision: Noneload_best_model_at_end: Trueignore_data_skip: Falserestore_callback_states_from_checkpoint: Falsefull_determinism: Falseseed: 42data_seed: Noneuse_cpu: Falseaccelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': None}parallelism_config: Nonedataloader_drop_last: Truedataloader_num_workers: 0dataloader_pin_memory: Truedataloader_persistent_workers: Falsedataloader_prefetch_factor: Noneremove_unused_columns: Truelabel_names: Nonetrain_sampling_strategy: randomlength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falseddp_static_graph: Noneddp_backend: Noneddp_timeout: 1800fsdp: []fsdp_config: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}deepspeed: Nonedebug: []skip_memory_metrics: Truedo_predict: Falseresume_from_checkpoint: Nonewarmup_ratio: Nonelocal_rank: -1prompts: Nonebatch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}
</details>
Training Logs
<details><summary>Click to expand</summary>
- The bold row denotes the saved checkpoint. </details>
Training Time
- Training: 6.5 hours
- Evaluation: 21.0 seconds
- Total: 6.5 hours
Framework Versions
- Python: 3.13.13
- Sentence Transformers: 5.5.1
- Transformers: 5.9.0
- PyTorch: 2.12.0+cu130
- Accelerate: 1.13.0
- Datasets: 4.8.5
- Tokenizers: 0.22.2
Citation
BibTeX
Sentence Transformers
@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",
}MultipleNegativesRankingLoss
@misc{oord2019representationlearningcontrastivepredictive,
title={Representation Learning with Contrastive Predictive Coding},
author={Aaron van den Oord and Yazhe Li and Oriol Vinyals},
year={2019},
eprint={1807.03748},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/1807.03748},
}<!--
Glossary
Clearly define terms in order to be accessible across audiences. -->
<!--
Model Card Authors
Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction. -->
<!--
Model Card Contact
Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors. -->
