Downloads · 30 days
69
19% of all-time downloads
nahinfarhan/hadith-retriever-bn-v2
hadith-retriever-bn-v2 is a sentence similarity model from nahinfarhan. Use it when you need a score for how close two texts are. It is set up for sentence-transformers.
This is a sentence-transformers model finetuned from intfloat/multilingual-e5-base. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for retrieval.
Downloads · 30 days
69
19% of all-time downloads
All-time downloads
367
Public
Parameters
278M
1.1 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors1.1 GB · 98%
From the Hugging Face model README
This is a sentence-transformers model finetuned from intfloat/multilingual-e5-base. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for retrieval.
SentenceTransformer(
(0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'XLMRobertaModel'})
(1): Pooling({'embedding_dimension': 768, 'pooling_mode': 'mean', 'include_prompt': True})
(2): Normalize({})
)
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("sentence_transformers_model_id")
# Run inference
sentences = [
'query: নিষিদ্ধ ছবি বলতে কী বোঝায়?',
'passage: নবী (ﷺ) বলেছেন, ‘যে বাড়িতে প্রাণীর ছবি থাকে সেখানে ফেরেশতা প্রবেশ করে না।’\n\nবুসর (রহঃ) বলেন, অতঃপর যায়িদ ইবন খালিদ (রাঃ) রোগাক্রান্ত হন। আমরা তাঁর সেবার জন্য গেলাম। তখন আমরা তাঁর ঘরে একটি পর্দায় কিছু ছবি দেখতে পেলাম। তখন আমি (বুসর) উবাইদুল্লাহ খাওলানি (রহঃ)-কে জিজ্ঞেস করলাম, ইনি কি আমাদের কাছে ছবি সম্পর্কীয় হাদীস বর্ণনা করেননি? তখন তিনি বলেছেন, প্রাণীর; তবে কাপড়ের মধ্যে কিছু অঙ্কন করা নিষিদ্ধ নয়, তুমি কি তা শুননি? আমি বললাম, না। তিনি বললেন, হ্যাঁ, তিনি তা বর্ণনা করেছেন।',
'passage: লোকজন যখন নবী (ﷺ)-এর নিকট নিজেদের সদকা নিয়ে উপস্থিত হতো তখন তিনি বলতেনঃ আল্লাহ! অমুকের প্রতি রহমত বর্ষণ করুন। একদা আমার পিতা সদকা নিয়ে হাজির হলে তিনি বললেনঃ হে আল্লাহ! আবু আওফার বংশধরের প্রতি রহমত বর্ষণ করুন।',
]
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.5619, -0.0843],
# [ 0.5619, 1.0000, 0.0230],
# [-0.0843, 0.0230, 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.*
-->
| anchor | positive | |
|---|---|---|
| type | string | string |
| modality | text | text |
| details | <ul><li>min: 10 tokens</li><li>mean: 18.71 tokens</li><li>max: 31 tokens</li></ul> | <ul><li>min: 19 tokens</li><li>mean: 108.47 tokens</li><li>max: 256 tokens</li></ul> |
| anchor | positive |
|---|---|
| <code>query: রমজান মাসে রোজা অবস্থায় সহবাস করলে কাফফারা কী?</code> | <code>passage: বর্ণিত। এক ব্যক্তি রমজান মাসে তার স্ত্রীর সাথে সহবাস করে এবং এ সম্পর্কে রাসূলুল্লাহ (ﷺ)-এর নিকট প্রশ্ন করল। তখন তিনি বললেন, “তোমার কোন ক্রীতদাস আছে কি?” সে বলল, না। তিনি আবার বললেন, “তুমি দুই মাস সাওম পালন করতে পারবে কি?” সে বলল, না। তখন তিনি বললেন, “তাহলে ষাটজন মিসকীনকে আহার করাও।”</code> |
| <code>query: ইহরাম অবস্থায় কষ্টের কারণ কী?</code> | <code>passage: রসূলুল্লাহ (ﷺ) আয়িশা (রাঃ)-এর কাছে উপস্থিত হলেন, তখন তিনি কাঁদছিলেন। হাদীসের অবশিষ্ট অংশ পূর্বোক্ত লায়স (রহঃ)-এর হাদীসের অনুরূপ। অবশ্য উক্ত হাদীসের প্রথমাংশ এ হাদীসে বর্ণনা করা হয়নি।</code> |
| <code>query: জানাজার নামাজ পড়লে কতটুকু সওয়াব পাওয়া যায়?</code> | <code>passage: একই সূত্রে অনুরূপ বর্ণনা করেছেন। সা‘ঈদ ও হিশাম-এর বর্ণিত হাদীসে আছে, নবী (ﷺ)-কে কীরাত সম্পর্কে জিজ্ঞেস করা হলে তিনি বললেন, তা উহুদ পাহাড় সমতুল্য।</code> |
{
"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
}
| anchor | positive | |
|---|---|---|
| type | string | string |
| modality | text | text |
| details | <ul><li>min: 11 tokens</li><li>mean: 18.61 tokens</li><li>max: 33 tokens</li></ul> | <ul><li>min: 17 tokens</li><li>mean: 106.16 tokens</li><li>max: 256 tokens</li></ul> |
| anchor | positive |
|---|---|
| <code>query: শপথ করে কাউকে মাফ না করার ঘোষণা দেওয়া কি জায়েজ?</code> | <code>passage: রাসূলুল্লাহ (ﷺ) বলেছেন: এক লোক বলল, আল্লাহর শপথ! আল্লাহ অমুক লোককে মাফ করবেন না। আর আল্লাহ তা‘আলা বলেন, সে লোক কে? যে শপথ খেয়ে বলে যে, আমি অমুককে মাফ করব না? আমি তাকে মাফ করে দিলাম এবং তোমার আমল (শপথ)-কে নষ্ট করে দিলাম, কিংবা তিনি যেমন বলেছেন।</code> |
| <code>query: তিন দিনের বেশি কথা না বলার পরিণাম কী?</code> | <code>passage: রাসূলুল্লাহ (ﷺ) বলেছেন: কোন মুসলিমের জন্য তার ভাইয়ের সঙ্গে তিন দিনের অধিক সময় সম্পর্ক ছিন্ন রাখা বৈধ নয়। দুই জনের সাক্ষাৎ ঘটলে একজন এদিকে মুখ ফিরিয়ে থাকে, অন্যজন ঐদিকে ঘাড় বাঁকিয়ে থাকে। তবে তাদের মধ্যে সে-ই উত্তম, যে প্রথমে সালাম করে।</code> |
| <code>query: চাটুকার বা অতিরিক্ত প্রশংসাকারীদের প্রতি কী আচরণ করতে হয়?</code> | <code>passage: এক ব্যক্তি দণ্ডায়মান অবস্থায় কোন এক আমীরের বা নেতার ভূয়সী প্রশংসা করতে শুরু করলে মিকদাদ (রাঃ) তার মুখে মাটি ছুঁড়ে মারলেন এবং বললেন, রাসূলুল্লাহ (ﷺ) আমাদেরকে নির্দেশ দিয়েছেন অতিমাত্রায় প্রশংসাকারীদের মুখে মাটি ছুঁড়ে মারার জন্য।</code> |
{
"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
}
per_device_train_batch_size: 40num_train_epochs: 7warmup_steps: 205fp16: Trueper_device_eval_batch_size: 32load_best_model_at_end: Truebatch_sampler: no_duplicatesper_device_train_batch_size: 40num_train_epochs: 7max_steps: -1learning_rate: 5e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 205optim: adamw_torch_fusedoptim_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: Truebf16_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: Falseproject: huggingfacetrackio_space_id: Nonetrackio_bucket_id: Nonetrackio_static_space_id: Noneper_device_eval_batch_size: 32prediction_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: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}parallelism_config: Nonedataloader_drop_last: Falsedataloader_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: Nonefsdp_config: Nonedeepspeed: 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: {}| Epoch | Step | Training Loss | Validation Loss |
|---|---|---|---|
| 0.1139 | 50 | 2.4714 | - |
| 0.2278 | 100 | 1.0811 | - |
| 0.3417 | 150 | 0.9245 | - |
| 0.4556 | 200 | 0.8543 | - |
| 0.5695 | 250 | 0.7318 | - |
| 0.6834 | 300 | 0.7735 | - |
| 0.7973 | 350 | 0.6780 | - |
| 0.9112 | 400 | 0.6857 | - |
| 1.0 | 439 | - | 0.3795 |
| 1.0251 | 450 | 0.5903 | - |
| 1.1390 | 500 | 0.4597 | - |
| 1.2528 | 550 | 0.4653 | - |
| 1.3667 | 600 | 0.4502 | - |
| 1.4806 | 650 | 0.4248 | - |
| 1.5945 | 700 | 0.4181 | - |
| 1.7084 | 750 | 0.4358 | - |
| 1.8223 | 800 | 0.4075 | - |
| 1.9362 | 850 | 0.4161 | - |
| 2.0 | 878 | - | 0.3011 |
| 2.0501 | 900 | 0.3169 | - |
| 2.1640 | 950 | 0.2595 | - |
| 2.2779 | 1000 | 0.2519 | - |
| 2.3918 | 1050 | 0.2500 | - |
| 2.5057 | 1100 | 0.2486 | - |
| 2.6196 | 1150 | 0.2607 | - |
| 2.7335 | 1200 | 0.2483 | - |
| 2.8474 | 1250 | 0.2644 | - |
| 2.9613 | 1300 | 0.2394 | - |
| 3.0 | 1317 | - | 0.2795 |
| 3.0752 | 1350 | 0.1997 | - |
| 3.1891 | 1400 | 0.1787 | - |
| 3.3030 | 1450 | 0.1552 | - |
| 3.4169 | 1500 | 0.1677 | - |
| 3.5308 | 1550 | 0.1810 | - |
| 3.6446 | 1600 | 0.1853 | - |
| 3.7585 | 1650 | 0.1728 | - |
| 3.8724 | 1700 | 0.1898 | - |
| 3.9863 | 1750 | 0.1766 | - |
| 4.0 | 1756 | - | 0.2534 |
| 4.1002 | 1800 | 0.1294 | - |
| 4.2141 | 1850 | 0.1228 | - |
| 4.3280 | 1900 | 0.1240 | - |
| 4.4419 | 1950 | 0.1276 | - |
| 4.5558 | 2000 | 0.1208 | - |
| 4.6697 | 2050 | 0.1354 | - |
| 4.7836 | 2100 | 0.1350 | - |
| 4.8975 | 2150 | 0.1434 | - |
| 5.0 | 2195 | - | 0.2303 |
| 5.0114 | 2200 | 0.1233 | - |
| 5.1253 | 2250 | 0.0983 | - |
| 5.2392 | 2300 | 0.0966 | - |
| 5.3531 | 2350 | 0.0998 | - |
| 5.4670 | 2400 | 0.0953 | - |
| 5.5809 | 2450 | 0.1038 | - |
| 5.6948 | 2500 | 0.0984 | - |
| 5.8087 | 2550 | 0.1105 | - |
| 5.9226 | 2600 | 0.1058 | - |
| 6.0 | 2634 | - | 0.2122 |
| 6.0364 | 2650 | 0.0884 | - |
| 6.1503 | 2700 | 0.0746 | - |
| 6.2642 | 2750 | 0.0885 | - |
| 6.3781 | 2800 | 0.0806 | - |
| 6.4920 | 2850 | 0.0850 | - |
| 6.6059 | 2900 | 0.0879 | - |
| 6.7198 | 2950 | 0.0821 | - |
| 6.8337 | 3000 | 0.0855 | - |
| 6.9476 | 3050 | 0.0822 | - |
| 7.0 | 3073 | - | 0.2141 |
| 7.0615 | 3100 | 0.0759 | - |
| 7.1754 | 3150 | 0.0744 | - |
| 7.2893 | 3200 | 0.0628 | - |
| 7.4032 | 3250 | 0.0717 | - |
| 7.5171 | 3300 | 0.0705 | - |
| 7.6310 | 3350 | 0.0785 | - |
| 7.7449 | 3400 | 0.0627 | - |
| 7.8588 | 3450 | 0.0797 | - |
| 7.9727 | 3500 | 0.0788 | - |
| 8.0 | 3512 | - | 0.2140 |
| 8.0866 | 3550 | 0.0622 | - |
| 8.2005 | 3600 | 0.0584 | - |
| 8.3144 | 3650 | 0.0623 | - |
| 8.4282 | 3700 | 0.0628 | - |
| 8.5421 | 3750 | 0.0598 | - |
| 8.6560 | 3800 | 0.0670 | - |
| 8.7699 | 3850 | 0.0532 | - |
| 8.8838 | 3900 | 0.0672 | - |
| 8.9977 | 3950 | 0.0552 | - |
| 9.0 | 3951 | - | 0.2133 |
| 9.1116 | 4000 | 0.0549 | - |
| 9.2255 | 4050 | 0.0576 | - |
| 9.3394 | 4100 | 0.0515 | - |
| 9.4533 | 4150 | 0.0635 | - |
| 9.5672 | 4200 | 0.0591 | - |
| 9.6811 | 4250 | 0.0548 | - |
| 9.7950 | 4300 | 0.0487 | - |
| 9.9089 | 4350 | 0.0520 | - |
| 10.0 | 4390 | - | 0.2104 |
| 0.0935 | 50 | 0.4920 | - |
| 0.1869 | 100 | 0.4219 | - |
| 0.2804 | 150 | 0.7412 | - |
| 0.3738 | 200 | 0.7388 | - |
| 0.4673 | 250 | 0.6718 | - |
| 0.5607 | 300 | 0.7205 | - |
| 0.6542 | 350 | 0.6364 | - |
| 0.7477 | 400 | 0.7014 | - |
| 0.8411 | 450 | 0.5826 | - |
| 0.9346 | 500 | 0.5907 | - |
| 1.0 | 535 | - | 0.4140 |
| 1.0280 | 550 | 0.5610 | - |
| 1.1215 | 600 | 0.4059 | - |
| 1.2150 | 650 | 0.4476 | - |
| 1.3084 | 700 | 0.4715 | - |
| 1.4019 | 750 | 0.4063 | - |
| 1.4953 | 800 | 0.4398 | - |
| 1.5888 | 850 | 0.3999 | - |
| 1.6822 | 900 | 0.4094 | - |
| 1.7757 | 950 | 0.4042 | - |
| 1.8692 | 1000 | 0.3744 | - |
| 1.9626 | 1050 | 0.3884 | - |
| 2.0 | 1070 | - | 0.3784 |
| 2.0561 | 1100 | 0.2794 | - |
| 2.1495 | 1150 | 0.2577 | - |
| 2.2430 | 1200 | 0.2341 | - |
| 2.3364 | 1250 | 0.2728 | - |
| 2.4299 | 1300 | 0.2482 | - |
| 2.5234 | 1350 | 0.2611 | - |
| 2.6168 | 1400 | 0.2603 | - |
| 2.7103 | 1450 | 0.2357 | - |
| 2.8037 | 1500 | 0.2590 | - |
| 2.8972 | 1550 | 0.2460 | - |
| 2.9907 | 1600 | 0.2552 | - |
| 3.0 | 1605 | - | 0.3492 |
| 3.0841 | 1650 | 0.1931 | - |
| 3.1776 | 1700 | 0.1713 | - |
| 3.2710 | 1750 | 0.1748 | - |
| 3.3645 | 1800 | 0.1881 | - |
| 3.4579 | 1850 | 0.1819 | - |
| 3.5514 | 1900 | 0.1543 | - |
| 3.6449 | 1950 | 0.1750 | - |
| 3.7383 | 2000 | 0.1984 | - |
| 3.8318 | 2050 | 0.1939 | - |
| 3.9252 | 2100 | 0.1642 | - |
| 4.0 | 2140 | - | 0.3443 |
| 4.0187 | 2150 | 0.1953 | - |
| 4.1121 | 2200 | 0.1343 | - |
| 4.2056 | 2250 | 0.1389 | - |
| 4.2991 | 2300 | 0.1350 | - |
| 4.3925 | 2350 | 0.1256 | - |
| 4.4860 | 2400 | 0.1301 | - |
| 4.5794 | 2450 | 0.1473 | - |
| 4.6729 | 2500 | 0.1269 | - |
| 4.7664 | 2550 | 0.1403 | - |
| 4.8598 | 2600 | 0.1341 | - |
| 4.9533 | 2650 | 0.1180 | - |
| 5.0 | 2675 | - | 0.3170 |
| 5.0467 | 2700 | 0.1015 | - |
| 5.1402 | 2750 | 0.0959 | - |
| 5.2336 | 2800 | 0.0931 | - |
| 5.3271 | 2850 | 0.1067 | - |
| 5.4206 | 2900 | 0.1007 | - |
| 5.5140 | 2950 | 0.0886 | - |
| 5.6075 | 3000 | 0.1227 | - |
| 5.7009 | 3050 | 0.1205 | - |
| 5.7944 | 3100 | 0.1045 | - |
| 5.8879 | 3150 | 0.0949 | - |
| 5.9813 | 3200 | 0.1142 | - |
| 6.0 | 3210 | - | 0.3132 |
| 6.0748 | 3250 | 0.0896 | - |
| 6.1682 | 3300 | 0.0715 | - |
| 6.2617 | 3350 | 0.1037 | - |
| 6.3551 | 3400 | 0.1017 | - |
| 6.4486 | 3450 | 0.0848 | - |
| 6.5421 | 3500 | 0.0832 | - |
| 6.6355 | 3550 | 0.0812 | - |
| 6.7290 | 3600 | 0.0840 | - |
| 6.8224 | 3650 | 0.0790 | - |
| 6.9159 | 3700 | 0.0873 | - |
| 7.0 | 3745 | - | 0.3123 |
@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",
}
@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.*
-->