abdoelsayed commited on
Commit
f7ed37f
·
verified ·
1 Parent(s): 046f113

Correct usage: no task-instruction prefix (matches how the model was trained and evaluated)

Browse files
Files changed (1) hide show
  1. README.md +22 -12
README.md CHANGED
@@ -58,23 +58,33 @@ from sentence_transformers import SentenceTransformer
58
 
59
  model = SentenceTransformer("DataScience-UIBK/OBLIQ-IR-3B", trust_remote_code=True)
60
 
61
- # A per-task instruction prefix is prepended to the QUERY only.
62
- INSTRUCTIONS = {
63
- "writing": "Given a prose snippet, retrieve other snippets by the same author across different topics, based on stylistic fingerprint.",
64
- "math": "Given an example problem, retrieve other math problems whose solutions share the same abstract reasoning technique.",
65
- "twitter": "Retrieve tweets that implicitly express the latent stance described in the query, without surface mention of the topic.",
66
- "congress": "Retrieve the specific Congressional hearing passage matching the user's lossy recollection of the exchange.",
67
- }
68
 
69
- q = model.encode(["query: " + INSTRUCTIONS["writing"] + " " + "Your query text here."])
70
- d = model.encode(["passage: " + "Your document text here."])
71
 
72
- # rank by cosine similarity
73
  scores = model.similarity(q, d)
74
  ```
75
 
76
- **The `query: ` / `passage: ` prefixes are required** — the model was trained with them.
77
- Documents take no instruction prefix.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
 
79
  ## How it was trained
80
 
 
58
 
59
  model = SentenceTransformer("DataScience-UIBK/OBLIQ-IR-3B", trust_remote_code=True)
60
 
61
+ queries = ["A passage written with the same restless, aphoristic voice as this one."]
62
+ documents = ["...your corpus documents..."]
 
 
 
 
 
63
 
64
+ q = model.encode(["query: " + x for x in queries])
65
+ d = model.encode(["passage: " + x for x in documents])
66
 
 
67
  scores = model.similarity(q, d)
68
  ```
69
 
70
+ **The `query: ` and `passage: ` prefixes are required** — the model was trained with them, and dropping
71
+ them changes the embedding. Queries take no other prefix.
72
+
73
+ > **Note on task instructions.** The training file carries a per-task instruction string alongside each
74
+ > query, but the training script consumes only the query text, and the evaluation that produced every
75
+ > number in the paper encodes the raw benchmark query with the `query: ` prefix alone. **Do not prepend a
76
+ > task instruction** — the released checkpoint was neither trained nor evaluated with one, so adding one
77
+ > moves you off-distribution. Task identity is carried by the mixture the model was trained on, not by a
78
+ > runtime prefix.
79
+
80
+ Truncate documents at 1024 tokens and queries at 256 to match the paper's evaluation:
81
+
82
+ ```python
83
+ model.max_seq_length = 1024 # documents
84
+ d = model.encode(["passage: " + x for x in documents])
85
+ model.max_seq_length = 256 # queries
86
+ q = model.encode(["query: " + x for x in queries])
87
+ ```
88
 
89
  ## How it was trained
90