Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 16
How to use vivekkopthsd/fiqa-retriever-bge-small with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("vivekkopthsd/fiqa-retriever-bge-small")
sentences = [
"Why are currency forwards needed?",
"According to both Huffington Post and Investopedia: Trying to retire without any savings in the bank can be difficult, and that difficulty is compounded by other factors senior citizens need to keep in mind as they age, like health issues and mobility. If saving money is not possible for you, retirement doesn’t have to pass you by. There are plenty of government-assisted and nonprofit programs that can help you, such as the Commodity Supplemental Food Program, Medicare, senior housing help from Housing and Urban Development and other resources. Therefore, to answer your questions: Is this pretty much the destiny of everyone who cannot save for retirement? Yes, if you do not have help from family (or friends) then you have a chance of ending up homeless and/or on government assistance. Do most people really never retire? There are people who really will never retire. There are stories in the news about Walmart greeters or McDonald's cashiers who are in their 80s and 90s working because they need to support themselves. However, that's not the case for everyone. There's a greeter at my local Costco who is in her 80s and she works because she loves it (her career was in consulting and she doesn't have a lack of retirement money. She just really likes talking to people.). What really happens? I can't answer what really happens because I have never experienced it and don't know people that do. Therefore I have to go off of what the two articles have said.",
"Don't sell. Ever. Well almost. A number of studies have shown that buying equal amounts of shares randomly will beat the market long term, and certainly won't do badly. Starting from this premise then perhaps you can add a tiny bit extra with your skill... maybe, but who knows, you might suck. Point is when buying you have the wind behind you - a monkey would make money. Selling is a different matter. You have the cost of trading out and back in to something else, only to have changed from one monkey portfolio to the other. If you have skill that covers this cost then yes you should do this - but how confident are you? A few studies have been done on anonymised retail broker accounts and they show the same story. Retail investors on average lose money on their switches. Even if you believe you have a real edge on the market, you're strategy still should not just say sell when it drops out of your criteria. Your criteria are positive indicators. Lack of positive is not a negative indicator. Sell when you would happily go short the stock. That is you are really confident it is going down. Otherwise leave it.",
"e.g. a European company has to pay 1 million USD exactly one year from now While that is theoretically possible, that is not a very common case. Mostly likely if they had to make a 1 million USD payment a year from now and they had the cash on hand they would be able to just make the payment today. A more common scenario for currency forwards is for investment hedging. Say that European company wants to buy into a mutual fund of some sort, say FUSEX. That is a USD based mutual fund. You can't buy into it directly with Euros. So if the company wants to buy into the fund they would need to convert their Euros to to USD. But now they have an extra risk parameter. They are not just exposed to the fluctuations of the fund, they are also exposed to the fluctuations of the currency market. Perhaps that fund will make a killing, but the exchange rate will tank and they will lose all their gains. By creating a forward to hedge their currency exposure risk they do not face this risk (flip side: if the exchange rate rises in a favorable rate they also don't get that benefit, unless they use an FX Option, but that is generally more expensive and complicated)."
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model finetuned from BAAI/bge-small-en-v1.5. It maps sentences & paragraphs to a 384-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': 'BertModel'})
(1): Pooling({'embedding_dimension': 384, 'pooling_mode': 'cls', '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("vivekkopthsd/fiqa-retriever-bge-small")
# Run inference
queries = [
'Stock grant, taxes, and the IRS',
]
documents = [
"I went through this too. There's a safe-harbor provision. If you prepay as estimated tax payments, 110% of your previous year's tax liability, there's no penalty for underpayment of the big liquidity-event tax liability. https://www.irs.gov/publications/p17/ch04.html That's with the feds. Your state may have different rules. You would be very wise indeed to hire an accountant to prepare your return this year. If I were you I'd ask your company's CFO or finance chief to suggest somebody. Congratulations, by the way.",
"The value of the asset doesn't change just because of the exchange rate change. If a thing (valued in USD) costs USD $1 and USD $1 = CAN $1 (so the thing is also valued CAN $1) today and tomorrow CAN $1 worth USD $0.5 - the thing will continue being worth USD $1. If the thing is valued in CAN $, after the exchange rate change, the thing will be worth USD $2, but will still be valued CAN $1. What you're talking about is price quotes, not value. Price quotes will very quickly reach the value, since any deviation will be used by the traders to make profits on arbitrage. And algo-traders will make it happen much quicker than you can even notice the arbitrage existence.",
'"Things I would specifically draw your attention to: the contract typically allows for an ""option"" to purchase; it does not typically compel purchase, although this is seen the purchase price is negotiated before anything gets signed the option to buy is typically available to the renter for the period of the lease contract (ie., if it\'s a 12 month contract the renter can opt to buy at any time in that 12 months) the amount of rent paid over time that will be applied to the purchase price is negotiated up-front before anything gets signed rent is paid at a slight premium (as Joe notes, if the rent should be $1000 per month, expect to pay $1200 per month) if the renter walks away they walk away empty handed; they do not get back the premium Having said all that - it\'s a contract negotiated between renter and seller and all of this is negotiable. See also, ehow for a good overview."',
]
query_embeddings = model.encode_query(queries)
document_embeddings = model.encode_document(documents)
print(query_embeddings.shape, document_embeddings.shape)
# [1, 384] [3, 384]
# Get the similarity scores for the embeddings
similarities = model.similarity(query_embeddings, document_embeddings)
print(similarities)
# tensor([[ 0.4181, 0.0066, -0.0466]])
fiqa-testInformationRetrievalEvaluator| Metric | Value |
|---|---|
| cosine_accuracy@1 | 0.3858 |
| cosine_accuracy@3 | 0.5324 |
| cosine_accuracy@5 | 0.5818 |
| cosine_accuracy@10 | 0.6667 |
| cosine_precision@1 | 0.3858 |
| cosine_precision@3 | 0.2382 |
| cosine_precision@5 | 0.1728 |
| cosine_precision@10 | 0.11 |
| cosine_recall@1 | 0.1952 |
| cosine_recall@3 | 0.321 |
| cosine_recall@5 | 0.3716 |
| cosine_recall@10 | 0.4555 |
| cosine_ndcg@10 | 0.3923 |
| cosine_mrr@10 | 0.4731 |
| cosine_map@100 | 0.3345 |
sentence_0 and sentence_1| sentence_0 | sentence_1 | |
|---|---|---|
| type | string | string |
| modality | text | text |
| details |
|
|
| sentence_0 | sentence_1 |
|---|---|
How come I can't sell short certain stocks? My broker says “no shares are available” |
In finance, short selling (also known as shorting or going short) is the practice of selling assets, usually securities, that have been borrowed from a third party (usually a broker) with the intention of buying identical assets back at a later date to return to the lender. Remember your broker has to borrow it from somewhere, other clients or if they hold those specific stocks themselves. So if it isn't possible for them to lend you those stocks, they wouldn't. High P/E stocks would find more sellers than buyers, and if the broker has to deliver them, it would be a nightmare for him to deliver all those stocks, which he had lent you(others) back to whom he had borrowed from, as well as to people who had gone long(buy) when you went short(sell). And if every body is selling there is going to be a dearth of stocks to be borrowed from as everybody around is selling instead of buying. |
How to choose a company for an IRA? |
"I use TIAA-Cref for my 403(b) and Fidelity for my solo 401(k) and IRAs. I have previously used Vanguard and have also used other discount brokers for my IRA. All of these companies will charge you nothing for an IRA, so there's really no point in comparing cost in that respect. They are all the ""cheapest"" in this respect. Each one will allow you to purchase their mutual funds and those of their partners for free. They will charge you some kind of fee to invest in mutual funds of their competitors (like $35 or something). So the real question is this: which of these institutions offers the best mutual and index funds. While they are not the worst out there, you will find that TIAA-Cref are dominated by both Vanguard and Fidelity. The latter two offer far more and larger funds and their funds will always have lower expense ratios than their TIAA-Cref equivalent. If I could take my money out of TIAA-Cref and put it in Fidelity, I'd do so right now. BTW, you may or may not want t... |
Why are currency forwards needed? |
e.g. a European company has to pay 1 million USD exactly one year from now While that is theoretically possible, that is not a very common case. Mostly likely if they had to make a 1 million USD payment a year from now and they had the cash on hand they would be able to just make the payment today. A more common scenario for currency forwards is for investment hedging. Say that European company wants to buy into a mutual fund of some sort, say FUSEX. That is a USD based mutual fund. You can't buy into it directly with Euros. So if the company wants to buy into the fund they would need to convert their Euros to to USD. But now they have an extra risk parameter. They are not just exposed to the fluctuations of the fund, they are also exposed to the fluctuations of the currency market. Perhaps that fund will make a killing, but the exchange rate will tank and they will lose all their gains. By creating a forward to hedge their currency exposure risk they do not face this risk (flip side... |
MultipleNegativesRankingLoss 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
}
per_device_train_batch_size: 256fp16: Trueper_device_eval_batch_size: 256multi_dataset_batch_sampler: round_robinper_device_train_batch_size: 256num_train_epochs: 3max_steps: -1learning_rate: 5e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0optim: 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: 1label_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: 256prediction_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: Falseignore_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: batch_samplermulti_dataset_batch_sampler: round_robinrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | fiqa-test_cosine_ndcg@10 |
|---|---|---|
| -1 | -1 | 0.3923 |
@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},
}
Base model
BAAI/bge-small-en-v1.5