SentenceTransformer based on hkunlp/instructor-xl

This is a sentence-transformers model finetuned from hkunlp/instructor-xl. 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.

Model Details

Model Description

  • Model Type: Sentence Transformer
  • Base model: hkunlp/instructor-xl
  • Maximum Sequence Length: 128 tokens
  • Output Dimensionality: 768 dimensions
  • Similarity Function: Cosine Similarity

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 128, 'do_lower_case': False, 'architecture': 'T5EncoderModel'})
  (1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': False})
  (2): Dense({'in_features': 1024, 'out_features': 768, 'bias': False, 'activation_function': 'torch.nn.modules.linear.Identity'})
  (3): Normalize()
)

Usage

Direct Usage (Sentence Transformers)

First install the Sentence Transformers library:

pip install -U sentence-transformers

Then you can load this model and run inference.

from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("ahmedHamdi/ir-all-en-instructor-xl")
# Run inference
sentences = [
    'Represent the plot: Living a relatively peaceful life in Harlem, Bishop and his gang will try anything to gain the respect they crave. However, they disagree on how to achieve it. Bishop simply wants to earn money and respect by killing... Everything changes the day Bishop tries to join an ongoing robbery, but fails to convince his three companions to back him up. But all this will change when they realize their thirst for recognition is strong enough to drive them to commit crimes. Naturally, Quincy (who goes by "Q") will come to his senses and put an end to the madness Bishop is creating in order to turn the tables. The consequences will be terrible for the four young men...',
    "Represent the plot: Roland Bishop, Quincy Q Powell, Raheem Porter, and Eric Steel Thurman are four teenage African-American friends growing up together in Harlem. They regularly skip school, instead spending their days hanging out at Steel's apartment, at a neighborhood arcade, and also a record store where they steal LPs for Q's DJ interests. They are also harassed daily by the police and a Puerto Rican gang led by Radames. Fed up with the harassment he and his friends have endured, Bishop decides that the group must go on to do bigger things in order to win respect. However, Q is unsure if he wants to become involved in a life of crime. One night, under Bishop's persistence, the friends decide to rob a local convenience store owned by Fernando Quiles. However, Q is unsure of the plan, and also fears that it will affect his chances of participating in a DJ competition which he has yearned to compete in for years, although he is eventually pressured by his friends. During the robbery, Bishop fatally shoots Quiles in the head, and the group flees the scene. The four then gather in an abandoned building where they argue over the evening's events; Q, Raheem and Steel are angry at Bishop for killing Quiles, and Raheem demands that Bishop give the gun to him. However, Bishop resists, and a struggle ensues before Bishop shoots Raheem dead. Raheem was still alive and grabbed Bishop’s arm in an attempt to rob him . Panicking, Bishop, Q and Steel flee to another building, where Bishop threatens to kill Q and Steel if they reveal to anybody that he murdered Raheem. Q and Steel realize that Bishop is beginning to become addicted to the thrill of killing, and they agree to give Bishop as wide a berth as possible. However, while attending Raheem's funeral, they find Bishop there, who goes as far as to comfort Raheem's mother and promises to find his killer. While Q and Steel are mostly able to avoid Bishop, he eventually finds and confronts them, questioning their loyalty. Later, Bishop confronts and kills Radames, then plans to frame Q for his murders in order to cover his tracks. Fearful of Bishop, Q resorts to buying a gun for his own protection. Meanwhile, Bishop confronts Steel in an alley, accusing him of disloyalty, and shoots him. However, Steel survives the attack and is rushed to the hospital, where he informs Q's girlfriend Yolanda about Bishop and his plan to frame Q. Frustrated with the troubles brought upon him, Q throws his gun into the river and decides to confront Bishop unarmed. Q and Bishop meet, where a fight and a chase ensue. Q is subsequently chased into a building where a party is being held, where Bishop begins firing into a group of partygoers in an attempt to hit Q, but Q escapes unharmed. Q manages to disarm Bishop while he is distracted, and he pursues Bishop to a roof of a high-rise building. As the two get into a physical altercation, Bishop eventually falls off the ledge, but is caught by Q. Bishop begs Q not to let go, but Q eventually loses his grip, and Bishop falls to his death. As Q is leaving the rooftop, a crowd from the party gathers to see what happened. One of the people in the crowd turns to Q and says, Yo, you got the juice now, man. Q turns to look at him, shakes his head in disgust, and walks away. The final scene of the movie flashes back to Bishop, Q, Raheem, and Steel in happier times.",
    "Represent the plot: British botanist Dr. Charles Decker comes back from Africa after a year, presumed dead. During that year, he came across a way of growing plants and animals to an enormous size. He brings back a baby chimpanzee, named Konga, to test out his theory. Decker goes insane after he discovers a serum that turns his chimpanzee subject into a ferocious gorilla-sized ape. To further his hideous experiments, he mesmerizes Konga and sends it to London to kill all of his enemies who have more credit in the scientific community than he already has. Among his targets are Dean Foster and Professor Tagore. During a field trip to the woods with a group of his students he makes an inappropriate advance to Sandra. He is later confronted by her boyfriend Bob and, although seeming to concede to Bob, sends Konga to strangle him. Decker's assistant and lover Margaret sees him ask Sandra to become both his new assistant and his lover, then sexually assault Sandra when she refuses. Margaret attempts to get even by hypnotizing Konga into obeying her, then giving him an enormous amount of the strange serum, which turns him into an enormous monster, at which point she becomes Konga's first victim. He keeps growing, and bursts through the roof of the house. Seeing Decker still attacking Sandra in the greenhouse, the super-sized Konga grabs Decker in one of his enormous hands, while Sandra's arm is seized by one of Decker's carnivorous plants (her ultimate fate is not shown). His rampage comes to a stop when he is attacked by heavily armed soldiers. After he throws Decker to his death, Konga falls. Upon his demise, Konga changes back to a baby chimpanzee.",
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[ 1.0000,  0.6569, -0.0137],
#         [ 0.6569,  1.0000,  0.0343],
#         [-0.0137,  0.0343,  1.0000]])

Training Details

Training Dataset

Unnamed Dataset

  • Size: 24,416 training samples
  • Columns: sentence_0 and sentence_1
  • Approximate statistics based on the first 1000 samples:
    sentence_0 sentence_1
    type string string
    details
    • min: 16 tokens
    • mean: 100.84 tokens
    • max: 128 tokens
    • min: 16 tokens
    • mean: 123.23 tokens
    • max: 128 tokens
  • Samples:
    sentence_0 sentence_1
    Represent the plot: Sammy Fabelman grew up in the United States after World War II. He was a shy child who found refuge in filmmaking and made his own movies. While watching one of them, he was devastated to discover that his mother was having an affair with a family friend. Represent the plot: On a January night in 1952, in Haddon Township, New Jersey, Jewish couple Mitzi and Burt Fabelman take their young son Sammy to see his first film: The Greatest Show on Earth. Dazzled by a train scene, Sammy asks for a model set for Hanukkah, which he crashes late one night. Mitzi, understanding Sammy's intentions, allows him to shoot another crash scene using Burt's 8mm camera. Sammy begins filming regularly, sometimes involving his sisters. Burt is offered a new job in Phoenix, Arizona, where he and the family move in early 1957. At Mitzi's insistence, Burt's best friend and business partner Bennie Loewy goes, too. Years later, teenaged Sammy makes films with his friends in the Boy Scouts, begins utilizing post-production effects and earns a badge in photography. Later, the Fabelmans, including Bennie, take a camping trip with Sammy capturing footage of their vacation. Shortly afterwards, Mitzi's mother dies, leaving her distraught. Providing him with film editin...
    Represent the plot: A woman tries to find her place in the world of striptease. Represent the plot: Diana Armstrong gazes at the ruins of the Players Club, a strip club where she used to work. She begins reminiscing about the time she moved out of her parents' home with hopes of attending college. On her own, Diana finds a job at a shoe store, where she meets Ronnie and Tricks, who work for Dollar Bill at the Players Club. They convince Diana she would make better money stripping. Dollar Bill gives Diana a job and the name Diamond. Four years later, her younger cousin Ebony comes to live with her and also starts working at the club. Ebony is soon out of control, drinking excessively, staying out all night, and stripping at private house parties. Several scenes depict episodes in the life of the club: A visit from a famous rapper ends in a fistfight. Diamond deals with a stalker, Myron. And she angrily kicks Ebony out of her house after catching her in bed with Diamond's boyfriend. Dollar Bill is confronted by a man who works for St. Louis, a drug lord and loan sha...
    Represent the plot: Grégoire Canvel is a film producer. He loves his films as much as his family, even though balancing the two seems increasingly difficult, except for the respite of weekends in the countryside. Hyperactive and glued to his phone, even on vacation, charming and persuasive, he appears as solid and self-assured as can be. Yet, around him, difficulties are piling up. His production company, Moon Films, is in trouble. Thus begins a downward spiral, from frustration to weariness, to despair. Burdened with debt, he shoots himself in the head. Represent the plot: Grégoire Canvel is a French film producer who has his own film company. Despite his luxurious country home, apartment in Paris and film company he is drowning in debt. Grégoire continues to take on more work despite his slate of current films continuing to rack up costs. Upon learning that he is 4 million euros in debt and that his catalogue of films, already mortgaged, is only worth less than a million euros and that his bank refuses to extend him any more credit Grégoire burns his bills and then shoots himself in the street. In the wake of his death his wife Sylvia attempts to honour her husband's memory by completing the work currently in production. However her attempts fail and she is forced to liquidate the company. Meanwhile, while waiting for her mother outside of the production office, Grégoire and Sylvia's eldest daughter, Clémence, overhears people talking about her father and how he led a double life and had a son from whom he was estranged. While Sylvi...
  • Loss: MultipleNegativesRankingLoss with these parameters:
    {
        "scale": 20.0,
        "similarity_fct": "cos_sim",
        "gather_across_devices": false
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • multi_dataset_batch_sampler: round_robin

All Hyperparameters

Click to expand
  • overwrite_output_dir: False
  • do_predict: False
  • eval_strategy: no
  • prediction_loss_only: True
  • per_device_train_batch_size: 8
  • per_device_eval_batch_size: 8
  • 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
  • num_train_epochs: 3
  • max_steps: -1
  • lr_scheduler_type: linear
  • lr_scheduler_kwargs: None
  • warmup_ratio: 0.0
  • 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: 42
  • data_seed: None
  • jit_mode_eval: False
  • bf16: False
  • 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: False
  • ignore_data_skip: False
  • fsdp: []
  • fsdp_min_num_params: 0
  • fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
  • fsdp_transformer_layer_cls_to_wrap: None
  • accelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
  • parallelism_config: None
  • deepspeed: None
  • label_smoothing_factor: 0.0
  • optim: adamw_torch_fused
  • optim_args: None
  • adafactor: False
  • group_by_length: False
  • length_column_name: length
  • project: huggingface
  • trackio_space_id: trackio
  • 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: False
  • resume_from_checkpoint: None
  • hub_model_id: None
  • hub_strategy: every_save
  • hub_private_repo: None
  • hub_always_push: False
  • hub_revision: None
  • gradient_checkpointing: False
  • 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: no
  • neftune_noise_alpha: None
  • optim_target_modules: None
  • batch_eval_metrics: False
  • eval_on_start: False
  • use_liger_kernel: False
  • liger_kernel_config: None
  • eval_use_gather_object: False
  • average_tokens_across_devices: True
  • prompts: None
  • batch_sampler: batch_sampler
  • multi_dataset_batch_sampler: round_robin
  • router_mapping: {}
  • learning_rate_mapping: {}

Training Logs

Epoch Step Training Loss
0.1638 500 0.1582
0.3277 1000 0.1056
0.4915 1500 0.1108
0.6553 2000 0.0816
0.8191 2500 0.0973
0.9830 3000 0.1191
1.1468 3500 0.0473
1.3106 4000 0.0407
1.4744 4500 0.0408
1.6383 5000 0.0568
1.8021 5500 0.0358
1.9659 6000 0.0408
2.1298 6500 0.0209
2.2936 7000 0.0186
2.4574 7500 0.0145
2.6212 8000 0.0138
2.7851 8500 0.0133
2.9489 9000 0.0124

Framework Versions

  • Python: 3.9.21
  • Sentence Transformers: 5.1.2
  • Transformers: 4.57.6
  • PyTorch: 2.8.0+cu128
  • Accelerate: 1.10.1
  • Datasets: 4.5.0
  • 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{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}
}
Downloads last month
1
Safetensors
Model size
1B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for ahmedHamdi/ir-all-en-instructor-xl

Finetuned
(16)
this model

Papers for ahmedHamdi/ir-all-en-instructor-xl