Text Ranking
sentence-transformers
Safetensors
PyTorch
English
qwen3_vl
reranking
retrieval
rag
cross-encoder
qwen3-vl
Instructions to use Surpem/Supertron2-Reranker-8B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use Surpem/Supertron2-Reranker-8B with sentence-transformers:
from sentence_transformers import CrossEncoder model = CrossEncoder("Surpem/Supertron2-Reranker-8B") 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) - Notebooks
- Google Colab
- Kaggle
File size: 2,443 Bytes
e946ffc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | {%- set default_instruction = "Given a search query, retrieve relevant candidates that answer the query." -%}
{%- set ns = namespace(instruction="", found_instruction=false) -%}
{%- for message in messages -%}
{%- if message.role == "system" -%}
{%- if message.content is string -%}
{%- set ns.instruction = message.content -%}
{%- else -%}
{%- for content in message.content -%}
{%- if 'text' in content -%}
{%- set ns.instruction = ns.instruction + content.text -%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- set ns.found_instruction = true -%}
{%- endif -%}
{%- endfor -%}
{%- if not ns.found_instruction -%}
{%- set ns.instruction = default_instruction -%}
{%- endif -%}
{%- set image_count = namespace(value=0) -%}
{%- set video_count = namespace(value=0) -%}
{%- macro render_multimodal(message) -%}
{%- if message.content is string -%}
{{- message.content -}}
{%- else -%}
{%- for content in message.content -%}
{%- if content.type == 'image' or 'image' in content or 'image_url' in content -%}
{%- set image_count.value = image_count.value + 1 -%}
{%- if add_vision_id %}Picture {{ image_count.value }}: {% endif -%}
<|vision_start|><|image_pad|><|vision_end|>
{%- elif content.type == 'video' or 'video' in content -%}
{%- set video_count.value = video_count.value + 1 -%}
{%- if add_vision_id %}Video {{ video_count.value }}: {% endif -%}
<|vision_start|><|video_pad|><|vision_end|>
{%- elif 'text' in content -%}
{{- content.text -}}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- endmacro -%}
{{- '<|im_start|>system\nJudge whether the Document meets the requirements based on the Query and the Instruct provided. Note that the answer can only be "yes" or "no".<|im_end|>\n<|im_start|>user\n<Instruct>: ' + ns.instruction + '<Query>:' -}}
{%- for message in messages if message.role == "query" -%}
{{- render_multimodal(message) -}}
{%- endfor -%}
{{- '\n<Document>:' -}}
{%- for message in messages if message.role == "document" -%}
{{- render_multimodal(message) -}}
{%- endfor -%}
{{- '<|im_end|>\n' -}}
{%- if add_generation_prompt -%}
{{- '<|im_start|>assistant\n' -}}
{%- endif -%} |