CoolFace
Modelpublic

JacobLinCool/Qwen3-Embedding-4B-GIR-1

sourceHugging Faceupdated 1y agoView on Hugging Face
1likes90downloads
Model Card

SentenceTransformer based on Qwen/Qwen3-Embedding-4B

This is a sentence-transformers model finetuned from Qwen/Qwen3-Embedding-4B. It maps sentences & paragraphs to a 2560-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.

Model Details

Model Description

  • —Model Type: Sentence Transformer
  • —Base model: Qwen/Qwen3-Embedding-4B <!-- at revision 5cf2132abc99cad020ac570b19d031efec650f2b -->
  • —Maximum Sequence Length: 40960 tokens
  • —Output Dimensionality: 2560 dimensions
  • —Similarity Function: Cosine Similarity <!-- - Training Dataset: Unknown --> <!-- - Language: Unknown --> <!-- - License: Unknown -->

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 40960, 'do_lower_case': False, 'architecture': 'Qwen3Model'})
  (1): Pooling({'word_embedding_dimension': 2560, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': False, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': True, 'include_prompt': True})
  (2): Normalize()
)

Usage

Direct Usage (Sentence Transformers)

First install the Sentence Transformers library:

bash
pip install -U sentence-transformers

Then you can load this model and run inference.

python
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("JacobLinCool/Qwen3-Embedding-4B-GIR-1")
# Run inference
queries = [
    "Generates samples of text from the provided vocabulary.\n\n  Args:\n    plain_vocab: vocabulary.\n    distribution: distribution.\n    train_samples: samples for training.\n    length: length.\n\n  Returns:\n    train_indices (np.array of Integers): random integers for training.\n      shape = [num_samples, length]\n    test_indices (np.array of Integers): random integers for testing.\n      shape = [num_samples, length]\n    plain_vocab   (list of Integers): unique vocabularies.",
]
documents = [
    'def generate_plaintext_random(plain_vocab, distribution, train_samples,\n                              length):\n  \n  if distribution is not None:\n    assert len(distribution) == len(plain_vocab)\n\n  train_indices = np.random.choice(\n      range(len(plain_vocab)), (train_samples, length), p=distribution)\n\n  return train_indices',
    'def switch(self, name):\n        \n        try:\n            switch = self.storage[self.__namespaced(name)]\n        except KeyError:\n            if not self.autocreate:\n                raise ValueError("No switch named  registered in " % (name, self.namespace))\n\n            switch = self.__create_and_register_disabled_switch(name)\n\n        switch.manager = self\n        return switch',
    'def late_filling(target, pressure=,\n                 Pc_star=,\n                 Swp_star=0.2, eta=3):\n    r\n    element = pressure.split()[0]\n    network = target.project.network\n    phase = target.project.find_phase(target)\n    pc_star = phase[Pc_star]\n    Pc = phase[pressure]\n    \n        Ts = network.map_throats(throats=target.Ts, origin=target)\n        values = values[Ts]\n    else:\n        Ps = network.map_pores(pores=target.Ps, origin=target)\n        values = values[Ps]\n    return values',
]
query_embeddings = model.encode_query(queries)
document_embeddings = model.encode_document(documents)
print(query_embeddings.shape, document_embeddings.shape)
# [1, 2560] [3, 2560]

# Get the similarity scores for the embeddings
similarities = model.similarity(query_embeddings, document_embeddings)
print(similarities)
# tensor([[0.9089, 0.0727, 0.1346]])

<!--

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. -->

Evaluation

Metrics

Information Retrieval
MetricValue
cosine_accuracy@10.98
cosine_accuracy@51.0
cosine_accuracy@101.0
cosine_precision@10.98
cosine_precision@30.3333
cosine_precision@50.2
cosine_precision@100.1
cosine_recall@10.98
cosine_recall@31.0
cosine_recall@51.0
cosine_recall@101.0
cosine_ndcg@10.98
cosine_ndcg@50.9926
cosine_ndcg@100.9926
cosine_mrr@10.98
cosine_mrr@50.99
cosine_mrr@100.99
cosine_map@1000.99

<!--

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: 400 training samples
  • —Columns: <code>query</code> and <code>code</code>
  • —Approximate statistics based on the first 400 samples: | | query | code | |:--------|:------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------| | type | string | string | | details | <ul><li>min: 2 tokens</li><li>mean: 67.12 tokens</li><li>max: 3156 tokens</li></ul> | <ul><li>min: 24 tokens</li><li>mean: 126.98 tokens</li><li>max: 1236 tokens</li></ul> |
  • —Samples: | query | code | |:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>For memory actions, get a list of addresses it operates on.<br><br> :param SimAction action: The action object to work with.<br> :return: A list of addresses that are accessed with that action.<br> :rtype: list</code> | <code>def getactualaddrs(action, state):<br> <br><br> if action.actualaddrs is None:<br> <br> addrlist = {0x60000000} <br> else:<br> addrlist = set(action.actualaddrs)<br><br> return addrlist</code> | | <code>Construct the input file of the calculation.</code> | <code>def makeinput(self, withheader=False):<br> <br> s = str(self.input)<br> if withheader: s = str(self) + "\n" + s<br> return s</code> | | <code>Check worker status route</code> | <code>def checkworkerstatus():<br> <br> if not in request.args:<br> resp = {"status": "bad request"}<br> return jsonify(**resp)<br> else:<br> workerid = request.args[]<br> assignmentid = request.args[]<br> allowrepeats = CONFIG.getboolean(, )<br> if allowrepeats: <br> try:<br> part = Participant.query.\<br> filter(Participant.workerid == workerid).\<br> filter(Participant.assignmentid == assignmentid).one()<br> status = part.status<br> except exc.SQLAlchemyError:<br> status = NOTACCEPTED<br> else: <br> try:<br> matches = Participant.query.\<br> filter(Participant.workerid == workerid).all()<br> numrecs = len(matches)<br> if numrecs==0: <br> status = NOTACCEPTED<br> else:<br> status = max([record.status for record in matches])<br> except exc.SQLAlchemyError:<br> ...</code> |
  • —Loss: <code>CachedMultipleNegativesRankingLoss</code> with these parameters:
json
  {
      "scale": 20.0,
      "similarity_fct": "cos_sim",
      "mini_batch_size": 4,
      "gather_across_devices": false
  }

Evaluation Dataset

Unnamed Dataset
  • —Size: 100 evaluation samples
  • —Columns: <code>query</code> and <code>code</code>
  • —Approximate statistics based on the first 100 samples: | | query | code | |:--------|:-----------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------| | type | string | string | | details | <ul><li>min: 5 tokens</li><li>mean: 66.56 tokens</li><li>max: 548 tokens</li></ul> | <ul><li>min: 24 tokens</li><li>mean: 142.11 tokens</li><li>max: 901 tokens</li></ul> |
  • —Samples: | query | code | |:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>Return the value of the android prefixed attribute in a specific tag.<br><br> This function will always try to get the attribute with a android: prefix first,<br> and will try to return the attribute without the prefix, if the attribute could not be found.<br> This is useful for some broken AndroidManifest.xml, where no android namespace is set,<br> but could also indicate malicious activity (i.e. wrongly repackaged files).<br> A warning is printed if the attribute is found without a namespace prefix.<br><br> If you require to get the exact result you need to query the tag directly:<br><br> example::<br> >>> from lxml.etree import Element<br> >>> tag = Element('bar', nsmap={'android': 'http://schemas.android.com/apk/res/android'})<br> >>> tag.set('{http://schemas.android.com/apk/res/android}foobar', 'barfoo')<br> >>> tag.set('name', 'baz')<br> # Assume that a is some APK object<br> >>> a.getvaluefromtag(tag, 'name'...</code> | <code>def getvaluefromtag(self, tag, attribute):<br> <br><br> <br> <br> value = tag.get(self.ns(attribute))<br> if value is None:<br> value = tag.get(attribute)<br><br> if value:<br> <br> log.warning("Failed to get the attribute on tag with namespace. "<br> "But found the same attribute without namespace!".format(attribute, tag.tag))<br> return value</code> | | <code>Get information about this object as a dictionary. Used by WebSocket interface to pass some<br> relevant information to client applications.</code> | <code>def getasdatadict(self):<br> <br> return dict(type=self.class.name, tags=list(self.tags))</code> | | <code>Makes forecast with the estimated model<br><br> Parameters<br> ----------<br> h : int (default : 5)<br> How many steps ahead would you like to forecast?<br><br> pastvalues : int (default : 20)<br> How many past observations to show on the forecast graph?<br><br> intervals : Boolean<br> Would you like to show 95% prediction intervals for the forecast?<br><br> Returns<br> ----------<br> - Plot of the forecast</code> | <code>def plotpredict(self,h=5,pastvalues=20,intervals=True,*kwargs): <br> <br> import matplotlib.pyplot as plt<br> import seaborn as sns<br><br> figsize = kwargs.get(,(10,7))<br><br> if self.latent_variables.estimated is False:<br> raise Exception("No latent variables estimated!")<br> else:<br> <br> scale, shape, skewness = self._get_scale_and_shape(self.latent_variables.get_z_values(transformed=True))<br> previous_value = self.data[-1] <br> forecasted_values = np.ones(h)self.states[-1] <br> dateindex = self.shiftdates(h)<br> simulations = 10000<br> simvector = np.zeros([simulations,h])<br> tparams = self.transformz()<br><br> for n in range(0,simulations): <br> rndq = np.random.normal(0,np.sqrt(self.latentvariables.getzvalues(transformed=True)[0]),h) <br> exp = forecastedvalues.copy()<br><br> for t in range(0,h):<br> if t == 0:...</code> |
  • —Loss: <code>CachedMultipleNegativesRankingLoss</code> with these parameters:
json
  {
      "scale": 20.0,
      "similarity_fct": "cos_sim",
      "mini_batch_size": 4,
      "gather_across_devices": false
  }

Training Hyperparameters

Non-Default Hyperparameters
  • —eval_strategy: epoch
  • —per_device_train_batch_size: 64
  • —per_device_eval_batch_size: 64
  • —num_train_epochs: 1
  • —warmup_ratio: 0.1
  • —seed: 2025
  • —bf16: True
  • —load_best_model_at_end: True
  • —optim: adamw_torch
  • —push_to_hub: True
  • —hub_model_id: JacobLinCool/Qwen3-Embedding-4B-GIR-1
  • —hub_private_repo: False
  • —gradient_checkpointing: True
  • —eval_on_start: True
  • —batch_sampler: no_duplicates
All Hyperparameters

<details><summary>Click to expand</summary>

  • —overwrite_output_dir: False
  • —do_predict: False
  • —eval_strategy: epoch
  • —prediction_loss_only: True
  • —per_device_train_batch_size: 64
  • —per_device_eval_batch_size: 64
  • —per_gpu_train_batch_size: None
  • —per_gpu_eval_batch_size: None
  • —gradient_accumulation_steps: 1
  • —eval_accumulation_steps: None
  • —torch_empty_cache_steps: None
  • —learning_rate: 5e-05
  • —weight_decay: 0.0
  • —adam_beta1: 0.9
  • —adam_beta2: 0.999
  • —adam_epsilon: 1e-08
  • —max_grad_norm: 1.0
  • —num_train_epochs: 1
  • —max_steps: -1
  • —lr_scheduler_type: linear
  • —lr_scheduler_kwargs: {}
  • —warmup_ratio: 0.1
  • —warmup_steps: 0
  • —log_level: passive
  • —log_level_replica: warning
  • —log_on_each_node: True
  • —logging_nan_inf_filter: True
  • —save_safetensors: True
  • —save_on_each_node: False
  • —save_only_model: False
  • —restore_callback_states_from_checkpoint: False
  • —no_cuda: False
  • —use_cpu: False
  • —use_mps_device: False
  • —seed: 2025
  • —data_seed: None
  • —jit_mode_eval: False
  • —use_ipex: False
  • —bf16: True
  • —fp16: False
  • —fp16_opt_level: O1
  • —half_precision_backend: auto
  • —bf16_full_eval: False
  • —fp16_full_eval: False
  • —tf32: None
  • —local_rank: 0
  • —ddp_backend: None
  • —tpu_num_cores: None
  • —tpu_metrics_debug: False
  • —debug: []
  • —dataloader_drop_last: False
  • —dataloader_num_workers: 0
  • —dataloader_prefetch_factor: None
  • —past_index: -1
  • —disable_tqdm: False
  • —remove_unused_columns: True
  • —label_names: None
  • —load_best_model_at_end: True
  • —ignore_data_skip: False
  • —fsdp: []
  • —fsdp_min_num_params: 0
  • —fsdp_config: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}
  • —fsdp_transformer_layer_cls_to_wrap: None
  • —accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': None}
  • —parallelism_config: None
  • —deepspeed: None
  • —label_smoothing_factor: 0.0
  • —optim: adamw_torch
  • —optim_args: None
  • —adafactor: False
  • —group_by_length: False
  • —length_column_name: length
  • —ddp_find_unused_parameters: None
  • —ddp_bucket_cap_mb: None
  • —ddp_broadcast_buffers: False
  • —dataloader_pin_memory: True
  • —dataloader_persistent_workers: False
  • —skip_memory_metrics: True
  • —use_legacy_prediction_loop: False
  • —push_to_hub: True
  • —resume_from_checkpoint: None
  • —hub_model_id: JacobLinCool/Qwen3-Embedding-4B-GIR-1
  • —hub_strategy: every_save
  • —hub_private_repo: False
  • —hub_always_push: False
  • —hub_revision: None
  • —gradient_checkpointing: True
  • —gradient_checkpointing_kwargs: None
  • —include_inputs_for_metrics: False
  • —include_for_metrics: []
  • —eval_do_concat_batches: True
  • —fp16_backend: auto
  • —push_to_hub_model_id: None
  • —push_to_hub_organization: None
  • —mp_parameters:
  • —auto_find_batch_size: False
  • —full_determinism: False
  • —torchdynamo: None
  • —ray_scope: last
  • —ddp_timeout: 1800
  • —torch_compile: False
  • —torch_compile_backend: None
  • —torch_compile_mode: None
  • —include_tokens_per_second: False
  • —include_num_input_tokens_seen: False
  • —neftune_noise_alpha: None
  • —optim_target_modules: None
  • —batch_eval_metrics: False
  • —eval_on_start: True
  • —use_liger_kernel: False
  • —liger_kernel_config: None
  • —eval_use_gather_object: False
  • —average_tokens_across_devices: False
  • —prompts: None
  • —batch_sampler: no_duplicates
  • —multi_dataset_batch_sampler: proportional
  • —router_mapping: {}
  • —learning_rate_mapping: {}

</details>

Training Logs

EpochStepValidation Losscosine_ndcg@10
000.06630.9889
1.070.05940.9926
  • —The bold row denotes the saved checkpoint.

Framework Versions

  • —Python: 3.11.11
  • —Sentence Transformers: 5.1.1
  • —Transformers: 4.56.2
  • —PyTorch: 2.8.0+cu128
  • —Accelerate: 1.10.1
  • —Datasets: 4.1.1
  • —Tokenizers: 0.22.1

Citation

BibTeX

Sentence Transformers
bibtex
@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",
}
CachedMultipleNegativesRankingLoss
bibtex
@misc{gao2021scaling,
    title={Scaling Deep Contrastive Learning Batch Size under Memory Limited Setup},
    author={Luyu Gao and Yunyi Zhang and Jiawei Han and Jamie Callan},
    year={2021},
    eprint={2101.06983},
    archivePrefix={arXiv},
    primaryClass={cs.LG}
}

<!--

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. -->