marcospiau commited on
Commit
7a47bfe
1 Parent(s): 2271450

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +20 -36
README.md CHANGED
@@ -16,6 +16,7 @@ The easiest way to use our models is through the `rerankers` package. After inst
16
 
17
  ```python
18
  from rerankers import Reranker
 
19
 
20
  query = "O futebol é uma paixão nacional"
21
  docs = [
@@ -24,54 +25,37 @@ docs = [
24
  ]
25
 
26
  ranker = Reranker(
27
- "unicamp-dl/monoptt5-small",
28
  inputs_template="Pergunta: {query} Documento: {text} Relevante:",
 
29
  )
30
- # Relevant logging:
31
- # Loading T5Ranker model unicamp-dl/monoptt5-small
 
 
 
 
 
 
32
  # No device set
33
- # Using device cpu
34
- # No dtype set
35
- # Device set to `cpu`, setting dtype to `float32`
36
  # Using dtype torch.float32
37
- # Loading model unicamp-dl/monoptt5-small, this might take a while...
38
- # Using device cpu.
39
  # Using dtype torch.float32.
 
 
40
  # T5 true token set to ▁Sim
41
  # T5 false token set to ▁Não
42
  # Returning normalised scores...
43
  # Inputs template set to Pergunta: {query} Documento: {text} Relevante:
44
 
45
- results = ranker.rerank(query, docs)
46
- # Results should be something like (can vary depending on the model, the example below uses the "unicamp-dl/monoptt5-small" model)
47
- RankedResults(
48
- results=[
49
- Result(
50
- document=Document(
51
- text="O futebol é uma parte essencial da cultura brasileira e une as pessoas.",
52
- doc_id=1,
53
- metadata={},
54
- ),
55
- score=0.91943359375,
56
- rank=1,
57
- ),
58
- Result(
59
- document=Document(
60
- text="O futebol é superestimado e não deveria receber tanta atenção.",
61
- doc_id=0,
62
- metadata={},
63
- ),
64
- score=0.0267486572265625,
65
- rank=2,
66
- ),
67
- ],
68
- query="O futebol é uma paixão nacional",
69
- has_scores=True,
70
- )
71
-
72
  ```
73
 
74
- For additional configurations and more advanced usage, consult the rerankers documentation.
75
 
76
  # Citation
77
  If you use our models, please cite:
 
16
 
17
  ```python
18
  from rerankers import Reranker
19
+ import torch
20
 
21
  query = "O futebol é uma paixão nacional"
22
  docs = [
 
25
  ]
26
 
27
  ranker = Reranker(
28
+ "unicamp-dl/monoptt5-large",
29
  inputs_template="Pergunta: {query} Documento: {text} Relevante:",
30
+ dtype=torch.float32 # or bfloat16 if supported by your GPU
31
  )
32
+
33
+ results = ranker.rank(query, docs)
34
+
35
+ print("Classification results:")
36
+ for result in results:
37
+ print(result)
38
+
39
+ # Loading T5Ranker model unicamp-dl/monoptt5-large
40
  # No device set
41
+ # Using device cuda
 
 
42
  # Using dtype torch.float32
43
+ # Loading model unicamp-dl/monoptt5-large, this might take a while...
44
+ # Using device cuda.
45
  # Using dtype torch.float32.
46
+ # /usr/local/lib/python3.10/dist-packages/huggingface_hub/file_download.py:1132: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.
47
+ # warnings.warn(
48
  # T5 true token set to ▁Sim
49
  # T5 false token set to ▁Não
50
  # Returning normalised scores...
51
  # Inputs template set to Pergunta: {query} Documento: {text} Relevante:
52
 
53
+ # Classification results:
54
+ # document=Document(text='O futebol é uma parte essencial da cultura brasileira e une as pessoas.', doc_id=1, metadata={}) score=0.923164963722229 rank=1
55
+ # document=Document(text='O futebol é superestimado e não deveria receber tanta atenção.', doc_id=0, metadata={}) score=0.08710747957229614 rank=2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  ```
57
 
58
+ For additional configurations and more advanced usage, consult the `rerankers` [GitHub repository](https://github.com/AnswerDotAI/rerankers).
59
 
60
  # Citation
61
  If you use our models, please cite: