Run this model with HF Jobs
Run zyznull/RankingGPT-llama2-7b on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/zyznull/RankingGPT-llama2-7b. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/zyznull/RankingGPT-llama2-7b on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/zyznull/RankingGPT-llama2-7b. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/zyznull/RankingGPT-llama2-7b. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use zyznull/RankingGPT-llama2-7b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zyznull/RankingGPT-llama2-7b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="zyznull/RankingGPT-llama2-7b")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("zyznull/RankingGPT-llama2-7b") model = AutoModelForCausalLM.from_pretrained("zyznull/RankingGPT-llama2-7b", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use zyznull/RankingGPT-llama2-7b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "zyznull/RankingGPT-llama2-7b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "zyznull/RankingGPT-llama2-7b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/zyznull/RankingGPT-llama2-7b
- SGLang
How to use zyznull/RankingGPT-llama2-7b 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 "zyznull/RankingGPT-llama2-7b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "zyznull/RankingGPT-llama2-7b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "zyznull/RankingGPT-llama2-7b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "zyznull/RankingGPT-llama2-7b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use zyznull/RankingGPT-llama2-7b with Docker Model Runner:
docker model run hf.co/zyznull/RankingGPT-llama2-7b
RankingGPT-llama2-7b
RankingGPT is a text ranker based on large language models with significant in-domain and out-domain effectiveness. We provide RankingGPT in different sizes and types, including bloom-560m, bloom-1b1, bloom-3b, bloom-7b, llama2-7b, baichuan2-7b and qwen-7b.
More details please refer to our paper and github.
Usage
Code example
import torch
from transformers import AutoModelForCausalLM, LlamaTokenizer
tokenizer = LlamaTokenizer.from_pretrained('zyznull/RankingGPT-llama2-7b',trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained('zyznull/RankingGPT-llama2-7b',trust_remote_code=True).eval()
query='when should a baby walk'
document='Most babies start to walk around 13 months, but your baby may start walking as early as 9 or 10 months or as late as 15 or 16 months.'
context=f'Document: {document} Query:'
example=context+query
context_enc = tokenizer.encode(context, add_special_tokens=False)
continuation_enc = tokenizer.encode(query, add_special_tokens=False)
model_input = torch.tensor(context_enc+continuation_enc[:-1])
continuation_len = len(continuation_enc)
input_len, = model_input.shape
with torch.no_grad():
logprobs = torch.nn.functional.log_softmax(model(model_input.unsqueeze(dim=0))[0], dim=-1)[0]
logprobs = logprobs[input_len-continuation_len:]
logprobs = torch.gather(logprobs, 1, torch.tensor(continuation_enc).unsqueeze(-1)).squeeze(-1)
score = torch.sum(logprobs)/logprobs.shape[0]
print(f"Document: {document[:20] + '...'} Score: {score}")
Result
| DL19 | DL20 | BEIR | url | |
|---|---|---|---|---|
| MonoBERT-340M | 72.3 | 70.3 | 50.5 | huggingface |
| MonoT5-220M | 71.5 | 69.7 | 49.3 | huggingface |
| MonoT5-770M | 73.2 | 71.2 | 53.1 | huggingface |
| MonoT5-3B | 72.8 | 74.5 | 54.6 | huggingface |
| RankT5-770M | - | - | 53.7 | huggingface |
| RankLLaMA | 74.6 | 76.6 | 52.5 | huggingface |
| RankingGPT-bloom-560m | 75.3 | 73.2 | 53.7 | huggingface modelscope |
| RankingGPT-bloom-1b1 | 75.6 | 73.2 | 54.5 | huggingface modelscope |
| RankingGPT-bloom-3b | 76.8 | 73.6 | 56.2 | huggingface modelscope |
| RankingGPT-bloom-7b | 77.3 | 74.6 | 56.6 | huggingface modelscope |
| RankingGPT-llama2-7b | 76.2 | 76.3 | 57.8 | huggingface modelscope |
| RankingGPT-baichuan2-7b | 75.9 | 74.3 | 57.5 | huggingface modelscope |
| RankingGPT-qwen-7b | 75.8 | 74.3 | 58.3 | huggingface modelscope |
Citation
If you find our paper or models helpful, please consider citing them as follows:
@misc{zhang2023rankinggpt,
title={RankingGPT: Empowering Large Language Models in Text Ranking with Progressive Enhancement},
author={Longhui Zhang and Yanzhao Zhang and Dingkun Long and Pengjun Xie and Meishan Zhang and Min Zhang},
year={2023},
eprint={2311.16720},
archivePrefix={arXiv},
primaryClass={cs.IR}
}
- Downloads last month
- 17