Views
No views yet
pip install -U sentence-transformers1from sentence_transformers import CrossEncoder
2
3# Download from the 🤗 Hub
4model = CrossEncoder("redis/langcache-reranker-v2-softmnrl-triplet")
5# Get scores for pairs of texts
6pairs = [
7 [' What high potential jobs are there other than computer science?', ' What high potential jobs are there other than computer science?'],
8 [' Would India ever be able to develop a missile system like S300 or S400 missile?', ' Would India ever be able to develop a missile system like S300 or S400 missile?'],
9 [' water from the faucet is being drunk by a yellow dog', 'A yellow dog is drinking water from the faucet'],
10 [' water from the faucet is being drunk by a yellow dog', 'The yellow dog is drinking water from a bottle'],
11 ['! colspan = `` 14 `` `` Players who appeared for Colchester who left during the season ``', '! colspan = `` 14 `` `` Players who appeared for Colchester who left during the season ``'],
12]
13scores = model.predict(pairs)
14print(scores.shape)
15# (5,)
16
17# Or rank different texts based on similarity to a single text
18ranks = model.rank(
19 ' What high potential jobs are there other than computer science?',
20 [
21 ' What high potential jobs are there other than computer science?',
22 ' Would India ever be able to develop a missile system like S300 or S400 missile?',
23 'A yellow dog is drinking water from the faucet',
24 'The yellow dog is drinking water from a bottle',
25 '! colspan = `` 14 `` `` Players who appeared for Colchester who left during the season ``',
26 ]
27)
28# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]anchor, positive, and negative_1| anchor | positive | negative_1 | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| anchor | positive | negative_1 |
|---|---|---|
[object Object]"There aren't many places in Gold Coast where you can find a wide variety of wedding dresses." | [object Object]"There aren't many places in Gold Coast where you can find a wide variety of wedding dresses." | Where can I get a wide variety of wedding dresses in Gold Coast? |
[object Object]It's easy to say it's good having siblings, but people often suggest it as a universal truth without considering that not everyone enjoys sibling relationships. Having siblings can lead to conflicts, competition, and stress, which might overshadow any potential benefits like companionship or support. Additionally, individual experiences with siblings can vary greatly depending on personality, family dynamics, and cultural background. | [object Object]It's easy to say it's good having siblings, but people often suggest it as a universal truth without considering that not everyone enjoys sibling relationships. Having siblings can lead to conflicts, competition, and stress, which might overshadow any potential benefits like companionship or support. Additionally, individual experiences with siblings can vary greatly depending on personality, family dynamics, and cultural background. | What's it like having siblings? |
[object Object]To reconcile the idea that 'Education is the Key to Success' with the presence of underemployed graduates and successful criminals, it's important to emphasize that education is one among many factors that contribute to success. Education equips individuals with knowledge, critical thinking skills, and problem-solving abilities, which are essential tools for navigating life's challenges and seizing opportunities. However, success is also influenced by other elements such as personal drive, social connections, opportunities presented, and sometimes sheer luck. Education does not guarantee success on its own; rather, it provides a foundation upon which individuals can build their careers and personal lives. Additionally, the definition of success can be subjective and varies across different cultures and individuals. It's crucial to address practical considerations like ensuring that educational curricula are relevant to the current job market and fostering environments where both hard ... | [object Object]To reconcile the idea that 'Education is the Key to Success' with the presence of underemployed graduates and successful criminals, it's important to emphasize that education is one among many factors that contribute to success. Education equips individuals with knowledge, critical thinking skills, and problem-solving abilities, which are essential tools for navigating life's challenges and seizing opportunities. However, success is also influenced by other elements such as personal drive, social connections, opportunities presented, and sometimes sheer luck. Education does not guarantee success on its own; rather, it provides a foundation upon which individuals can build their careers and personal lives. Additionally, the definition of success can be subjective and varies across different cultures and individuals. It's crucial to address practical considerations like ensuring that educational curricula are relevant to the current job market and fostering environments where both hard ... | How do you convince the upcoming generation that "Education is The Key of Success " when we are surrounded by poor graduates and rich criminals? |
MultipleNegativesRankingLoss with these parameters:
1{
2 "scale": 20.0,
3 "num_negatives": 1,
4 "activation_fn": "torch.nn.modules.activation.Sigmoid"
5}anchor, positive, and negative_1| anchor | positive | negative_1 | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| anchor | positive | negative_1 |
|---|---|---|
What high potential jobs are there other than computer science? | What high potential jobs are there other than computer science? | Why IT or Computer Science jobs are being over rated than other Engineering jobs? |
Would India ever be able to develop a missile system like S300 or S400 missile? | Would India ever be able to develop a missile system like S300 or S400 missile? | Should India buy the Russian S400 air defence missile system? |
water from the faucet is being drunk by a yellow dog | A yellow dog is drinking water from the faucet | Childlessness is low in Eastern European countries. |
MultipleNegativesRankingLoss with these parameters:
1{
2 "scale": 20.0,
3 "num_negatives": 1,
4 "activation_fn": "torch.nn.modules.activation.Sigmoid"
5}1@inproceedings{reimers-2019-sentence-bert,
2 title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
3 author = "Reimers, Nils and Gurevych, Iryna",
4 booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
5 month = "11",
6 year = "2019",
7 publisher = "Association for Computational Linguistics",
8 url = "https://arxiv.org/abs/1908.10084",
9}