Instructions to use QuantFactory/lb-reranker-0.5B-v1.0-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use QuantFactory/lb-reranker-0.5B-v1.0-GGUF with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="QuantFactory/lb-reranker-0.5B-v1.0-GGUF") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("QuantFactory/lb-reranker-0.5B-v1.0-GGUF", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use QuantFactory/lb-reranker-0.5B-v1.0-GGUF with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf QuantFactory/lb-reranker-0.5B-v1.0-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf QuantFactory/lb-reranker-0.5B-v1.0-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf QuantFactory/lb-reranker-0.5B-v1.0-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf QuantFactory/lb-reranker-0.5B-v1.0-GGUF:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf QuantFactory/lb-reranker-0.5B-v1.0-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf QuantFactory/lb-reranker-0.5B-v1.0-GGUF:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf QuantFactory/lb-reranker-0.5B-v1.0-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf QuantFactory/lb-reranker-0.5B-v1.0-GGUF:Q4_K_M
Use Docker
docker model run hf.co/QuantFactory/lb-reranker-0.5B-v1.0-GGUF:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use QuantFactory/lb-reranker-0.5B-v1.0-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "QuantFactory/lb-reranker-0.5B-v1.0-GGUF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "QuantFactory/lb-reranker-0.5B-v1.0-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/QuantFactory/lb-reranker-0.5B-v1.0-GGUF:Q4_K_M
- SGLang
How to use QuantFactory/lb-reranker-0.5B-v1.0-GGUF with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "QuantFactory/lb-reranker-0.5B-v1.0-GGUF" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "QuantFactory/lb-reranker-0.5B-v1.0-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "QuantFactory/lb-reranker-0.5B-v1.0-GGUF" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "QuantFactory/lb-reranker-0.5B-v1.0-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use QuantFactory/lb-reranker-0.5B-v1.0-GGUF with Ollama:
ollama run hf.co/QuantFactory/lb-reranker-0.5B-v1.0-GGUF:Q4_K_M
- Unsloth Studio
How to use QuantFactory/lb-reranker-0.5B-v1.0-GGUF with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for QuantFactory/lb-reranker-0.5B-v1.0-GGUF to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for QuantFactory/lb-reranker-0.5B-v1.0-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for QuantFactory/lb-reranker-0.5B-v1.0-GGUF to start chatting
- Pi
How to use QuantFactory/lb-reranker-0.5B-v1.0-GGUF with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf QuantFactory/lb-reranker-0.5B-v1.0-GGUF:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "QuantFactory/lb-reranker-0.5B-v1.0-GGUF:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use QuantFactory/lb-reranker-0.5B-v1.0-GGUF with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf QuantFactory/lb-reranker-0.5B-v1.0-GGUF:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default QuantFactory/lb-reranker-0.5B-v1.0-GGUF:Q4_K_M
Run Hermes
hermes
- Atomic Chat new
- OpenClaw new
How to use QuantFactory/lb-reranker-0.5B-v1.0-GGUF with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf QuantFactory/lb-reranker-0.5B-v1.0-GGUF:Q4_K_M
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "QuantFactory/lb-reranker-0.5B-v1.0-GGUF:Q4_K_M" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
- Docker Model Runner
How to use QuantFactory/lb-reranker-0.5B-v1.0-GGUF with Docker Model Runner:
docker model run hf.co/QuantFactory/lb-reranker-0.5B-v1.0-GGUF:Q4_K_M
- Lemonade
How to use QuantFactory/lb-reranker-0.5B-v1.0-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull QuantFactory/lb-reranker-0.5B-v1.0-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.lb-reranker-0.5B-v1.0-GGUF-Q4_K_M
List all available models
lemonade list
QuantFactory/lb-reranker-0.5B-v1.0-GGUF
This is quantized version of lightblue/lb-reranker-0.5B-v1.0 created using llama.cpp
Original Model Card
LB Reranker v1.0
The LB Reranker has been trained to determine the relatedness of a given query to a piece of text, therefore allowing it to be used as a ranker or reranker in various retrieval-based tasks.
This model is fine-tuned from a Qwen/Qwen2.5-0.5B-Instruct model checkpoint and was trained for roughly 5.5 hours using the 8 x L20 instance (ecs.gn8is-8x.32xlarge) on Alibaba Cloud.
The training data for this model can be found at lightblue/reranker_continuous_filt_max7_train and the code for generating this data as well as running the training of the model can be found on our Github repo.
Trained on data in over 95 languages, this model is applicable to a broad range of use cases.
This model has three main benefits over comparable rerankers.
- It has shown slightly higher performance on evaluation benchmarks.
- It has been trained on more languages than any previous model.
- It is a simple Causal LM model trained to output a string between "1" and "7".
This last point means that this model can be used natively with many widely available inference packages, including vLLM and LMDeploy. This in turns allows our reranker to benefit from improvements to inference as and when these packages release them.
Update: We have also found that this model works pretty well as a code snippet reranker too (P@1 of 96%)! See our Colab for more details.
How to use
The model was trained to expect an input such as:
<<<Query>>>
{your_query_here}
<<<Context>>>
{your_context_here}
And to output a string of a number between 1-7.
In order to make a continuous score that can be used for reranking query-context pairs (i.e. a method with few ties), we calculate the expectation value of the scores.
We include scripts to do this in both vLLM and LMDeploy:
vLLM
Install vLLM using pip install vllm.
from vllm import LLM, SamplingParams
import numpy as np
def make_reranker_input(t, q):
return f"<<<Query>>>\n{q}\n\n<<<Context>>>\n{t}"
def make_reranker_training_datum(context, question):
system_message = "Given a query and a piece of text, output a score of 1-7 based on how related the query is to the text. 1 means least related and 7 is most related."
return [
{"role": "system", "content": system_message},
{"role": "user", "content": make_reranker_input(context, question)},
]
def get_prob(logprob_dict, tok_id):
return np.exp(logprob_dict[tok_id].logprob) if tok_id in logprob_dict.keys() else 0
llm = LLM("lightblue/lb-reranker-v1.0")
sampling_params = SamplingParams(temperature=0.0, logprobs=14, max_tokens=1)
tok = llm.llm_engine.tokenizer.tokenizer
idx_tokens = [tok.encode(str(i))[0] for i in range(1, 8)]
query_texts = [
("What is the scientific name of apples?", "An apple is a round, edible fruit produced by an apple tree (Malus spp., among them the domestic or orchard apple; Malus domestica)."),
("What is the Chinese word for 'apple'?", "An apple is a round, edible fruit produced by an apple tree (Malus spp., among them the domestic or orchard apple; Malus domestica)."),
("What is the square root of 999?", "An apple is a round, edible fruit produced by an apple tree (Malus spp., among them the domestic or orchard apple; Malus domestica)."),
]
chats = [make_reranker_training_datum(c, q) for q, c in query_texts]
responses = llm.chat(chats, sampling_params)
probs = np.array([[get_prob(r.outputs[0].logprobs[0], y) for y in idx_tokens] for r in responses])
N = probs.shape[1]
M = probs.shape[0]
idxs = np.tile(np.arange(1, N + 1), M).reshape(M, N)
expected_vals = (probs * idxs).sum(axis=1)
print(expected_vals)
# [6.66570732 1.86686378 1.01102923]
LMDeploy
Install LMDeploy using pip install lmdeploy.
# Un-comment this if running in a Jupyter notebook, Colab etc.
# import nest_asyncio
# nest_asyncio.apply()
from lmdeploy import GenerationConfig, ChatTemplateConfig, pipeline
import numpy as np
def make_reranker_input(t, q):
return f"<<<Query>>>\n{q}\n\n<<<Context>>>\n{t}"
def make_reranker_training_datum(context, question):
system_message = "Given a query and a piece of text, output a score of 1-7 based on how related the query is to the text. 1 means least related and 7 is most related."
return [
{"role": "system", "content": system_message},
{"role": "user", "content": make_reranker_input(context, question)},
]
def get_prob(logprob_dict, tok_id):
return np.exp(logprob_dict[tok_id]) if tok_id in logprob_dict.keys() else 0
pipe = pipeline(
"lightblue/lb-reranker-v1.0",
chat_template_config=ChatTemplateConfig(
model_name='qwen2d5',
capability='chat'
)
)
tok = pipe.tokenizer.model
idx_tokens = [tok.encode(str(i))[0] for i in range(1, 8)]
query_texts = [
("What is the scientific name of apples?", "An apple is a round, edible fruit produced by an apple tree (Malus spp., among them the domestic or orchard apple; Malus domestica)."),
("What is the Chinese word for 'apple'?", "An apple is a round, edible fruit produced by an apple tree (Malus spp., among them the domestic or orchard apple; Malus domestica)."),
("What is the square root of 999?", "An apple is a round, edible fruit produced by an apple tree (Malus spp., among them the domestic or orchard apple; Malus domestica)."),
]
chats = [make_reranker_training_datum(c, q) for q, c in query_texts]
responses = pipe(
chats,
gen_config=GenerationConfig(temperature=1.0, logprobs=14, max_new_tokens=1, do_sample=True)
)
probs = np.array([[get_prob(r.logprobs[0], y) for y in idx_tokens] for r in responses])
N = probs.shape[1]
M = probs.shape[0]
idxs = np.tile(np.arange(1, N + 1), M).reshape(M, N)
expected_vals = (probs * idxs).sum(axis=1)
print(expected_vals)
# [6.66415229 1.84342025 1.01133205]
Evaluation
We perform an evaluation on 9 datasets from the BEIR benchmark that none of the evaluated models have been trained upon (to our knowledge).
- Arguana
- Dbpedia-entity
- Fiqa
- NFcorpus
- Scidocs
- Scifact
- Trec-covid-v2
- Vihealthqa
- Webis-touche2020
We evaluate on a subset of all queries (the first 250) to save evaluation time.
We find that our model performs similarly or better than many of the state-of-the-art reranker models in our evaluation, without compromising on inference speed.
We make our evaluation code and results available on our Github.
As we can see, this reranker attains greater IR evaluation metrics compared to the two benchmarks we include for all positions apart from @1.
We also show that our model is, on average, faster than the BGE reranker v2.
License
We share this model under an Apache 2.0 license.
Developed by
This model was trained by Peter Devine (ptrdvn) for Lightblue
- Downloads last month
- 305
2-bit
3-bit
4-bit
5-bit
6-bit
8-bit


