Text Ranking
sentence-transformers
Safetensors
Transformers
Polish
roberta
text-classification
information-retrieval
text-embeddings-inference
Instructions to use sdadas/polish-reranker-roberta-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use sdadas/polish-reranker-roberta-v2 with sentence-transformers:
from sentence_transformers import CrossEncoder model = CrossEncoder("sdadas/polish-reranker-roberta-v2") query = "Which planet is known as the Red Planet?" passages = [ "Venus is often called Earth's twin because of its similar size and proximity.", "Mars, known for its reddish appearance, is often referred to as the Red Planet.", "Jupiter, the largest planet in our solar system, has a prominent red spot.", "Saturn, famous for its rings, is sometimes mistaken for the Red Planet." ] scores = model.predict([(query, passage) for passage in passages]) print(scores) - Transformers
How to use sdadas/polish-reranker-roberta-v2 with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("sdadas/polish-reranker-roberta-v2") model = AutoModelForSequenceClassification.from_pretrained("sdadas/polish-reranker-roberta-v2", device_map="auto") - Notebooks
- Google Colab
- Kaggle
fix: invalid variable
Browse filesBefore: If user tries to run the code with float32 setting and flash_attention, they will encounter an undefined variable error, due to misspelling of `self.query`.
After: If user tries to run the code with float32 setting and flash_attention, they will correctly get a `float32 not supported `error
- modeling_roberta.py +1 -1
modeling_roberta.py
CHANGED
|
@@ -408,7 +408,7 @@ class RobertaFlashAttention2(RobertaSelfAttention):
|
|
| 408 |
elif hasattr(self.config, "_pre_quantization_dtype"):
|
| 409 |
target_dtype = self.config._pre_quantization_dtype
|
| 410 |
else:
|
| 411 |
-
target_dtype = self.
|
| 412 |
|
| 413 |
logger.warning_once(
|
| 414 |
f"The input hidden states seems to be silently casted in float32, this might be related to"
|
|
|
|
| 408 |
elif hasattr(self.config, "_pre_quantization_dtype"):
|
| 409 |
target_dtype = self.config._pre_quantization_dtype
|
| 410 |
else:
|
| 411 |
+
target_dtype = self.query.weight.dtype
|
| 412 |
|
| 413 |
logger.warning_once(
|
| 414 |
f"The input hidden states seems to be silently casted in float32, this might be related to"
|