SamuelYang commited on
Commit
0562c8d
·
verified ·
1 Parent(s): 81b87db

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +26 -1
README.md CHANGED
@@ -24,6 +24,31 @@ It is built upon the [gte-Qwen2-7B-instruct](https://huggingface.co/Alibaba-NLP/
24
 
25
  ## Usage
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  ### Transformers
28
  ```python
29
  import torch
@@ -89,4 +114,4 @@ print(scores.tolist())
89
  | [BGE-M3](https://huggingface.co/BAAI/bge-m3) | 46.65 | 60.49 | 62.36 | 47.35 | 50.38 | 49.1 | **42.38** | 26.68 | 40.76 | 48.04 | 40.75 | 51.52 | 32.18 | 54.4 |
90
  | [BGE-Multilingual-Gemma2](https://huggingface.co/BAAI/bge-multilingual-gemma2) | 46.83 | 63.71 | 67.3 | 50.38 | 53.24 | 47.24 | 42.13 | 22.58 | 23.28 | 50.91 | 44.02 | 49.3 | 31.6 | **63.14** |
91
  | [GTE-Qwen2-7B-instruct](https://huggingface.co/Alibaba-NLP/gte-Qwen2-7B-instruct) | 48.38 | 63.46 | 66.44 | 51.2 | 51.98 | 54.2 | 38.82 | 22.31 | 40.27 | **54.07** | 43.03 | 58.2 | 26.63 | 58.39 |
92
- | **INF-Retriever-v1** | **52.56** | **65.25** | **68.44** | **52.13** | **56.6** | **56.96** | 42.03 | **34.51** | **50.62** | 53.32 | **50.02** | **58.34** | **35.42** | 59.64 |
 
24
 
25
  ## Usage
26
 
27
+ ### Sentence Transformers
28
+ ```python
29
+ from sentence_transformers import SentenceTransformer
30
+
31
+ model = SentenceTransformer("infly/inf-retriever-v1", trust_remote_code=True)
32
+ # In case you want to reduce the maximum length:
33
+ model.max_seq_length = 8192
34
+
35
+ queries = [
36
+ "how much protein should a female eat",
37
+ "summit define",
38
+ ]
39
+ documents = [
40
+ "As a general guideline, the CDC's average requirement of protein for women ages 19 to 70 is 46 grams per day. But, as you can see from this chart, you'll need to increase that if you're expecting or training for a marathon. Check out the chart below to see how much protein you should be eating each day.",
41
+ "Definition of summit for English Language Learners. : 1 the highest point of a mountain : the top of a mountain. : 2 the highest level. : 3 a meeting or series of meetings between the leaders of two or more governments.",
42
+ ]
43
+
44
+ query_embeddings = model.encode(queries, prompt_name="query")
45
+ document_embeddings = model.encode(documents)
46
+
47
+ scores = (query_embeddings @ document_embeddings.T) * 100
48
+ print(scores.tolist())
49
+ # [[86.8702392578125, 67.82366180419922], [59.5101432800293, 82.33667755126953]]
50
+ ```
51
+
52
  ### Transformers
53
  ```python
54
  import torch
 
114
  | [BGE-M3](https://huggingface.co/BAAI/bge-m3) | 46.65 | 60.49 | 62.36 | 47.35 | 50.38 | 49.1 | **42.38** | 26.68 | 40.76 | 48.04 | 40.75 | 51.52 | 32.18 | 54.4 |
115
  | [BGE-Multilingual-Gemma2](https://huggingface.co/BAAI/bge-multilingual-gemma2) | 46.83 | 63.71 | 67.3 | 50.38 | 53.24 | 47.24 | 42.13 | 22.58 | 23.28 | 50.91 | 44.02 | 49.3 | 31.6 | **63.14** |
116
  | [GTE-Qwen2-7B-instruct](https://huggingface.co/Alibaba-NLP/gte-Qwen2-7B-instruct) | 48.38 | 63.46 | 66.44 | 51.2 | 51.98 | 54.2 | 38.82 | 22.31 | 40.27 | **54.07** | 43.03 | 58.2 | 26.63 | 58.39 |
117
+ | **INF-Retriever-v1** | **52.56** | **65.25** | **68.44** | **52.13** | **56.6** | **56.96** | 42.03 | **34.51** | **50.62** | 53.32 | **50.02** | **58.34** | **35.42** | 59.64 |