Text Generation
Transformers
PyTorch
zhinao
mteb
qihoo360
奇虎360
RAG-reranking
custom_code
Eval Results (legacy)
Instructions to use qihoo360/360Zhinao-1.8B-Reranking with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use qihoo360/360Zhinao-1.8B-Reranking with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="qihoo360/360Zhinao-1.8B-Reranking", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("qihoo360/360Zhinao-1.8B-Reranking", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use qihoo360/360Zhinao-1.8B-Reranking with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "qihoo360/360Zhinao-1.8B-Reranking" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "qihoo360/360Zhinao-1.8B-Reranking", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/qihoo360/360Zhinao-1.8B-Reranking
- SGLang
How to use qihoo360/360Zhinao-1.8B-Reranking 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 "qihoo360/360Zhinao-1.8B-Reranking" \ --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": "qihoo360/360Zhinao-1.8B-Reranking", "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 "qihoo360/360Zhinao-1.8B-Reranking" \ --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": "qihoo360/360Zhinao-1.8B-Reranking", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use qihoo360/360Zhinao-1.8B-Reranking with Docker Model Runner:
docker model run hf.co/qihoo360/360Zhinao-1.8B-Reranking
Update modeling_zhinao.py
#2
by neofung - opened
- modeling_zhinao.py +12 -13
modeling_zhinao.py
CHANGED
|
@@ -748,6 +748,17 @@ class ZhinaoForCausalLM(ZhinaoPreTrainedModel):
|
|
| 748 |
|
| 749 |
def __init__(self, config):
|
| 750 |
super().__init__(config)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 751 |
self.model = ZhinaoModel(config)
|
| 752 |
self.vocab_size = config.vocab_size
|
| 753 |
self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
|
|
@@ -761,19 +772,7 @@ class ZhinaoForCausalLM(ZhinaoPreTrainedModel):
|
|
| 761 |
if config.fp16:
|
| 762 |
self.model.half()
|
| 763 |
self.lm_head.half()
|
| 764 |
-
self.linear.half()
|
| 765 |
-
|
| 766 |
-
if config.use_flash_attn == "auto":
|
| 767 |
-
if flash_attn_varlen_func:
|
| 768 |
-
if config.bf16 or config.fp16:
|
| 769 |
-
logger.warn("Try importing flash-attention.")
|
| 770 |
-
config.use_flash_attn = True
|
| 771 |
-
else:
|
| 772 |
-
config.use_flash_attn = False
|
| 773 |
-
logger.warn("Flash attention will be disabled because it does NOT support fp32.")
|
| 774 |
-
else:
|
| 775 |
-
config.use_flash_attn = False
|
| 776 |
-
logger.warn("Please install FlashAttention first, " "e.g., with pip install flash-attn")
|
| 777 |
|
| 778 |
self.post_init()
|
| 779 |
|
|
|
|
| 748 |
|
| 749 |
def __init__(self, config):
|
| 750 |
super().__init__(config)
|
| 751 |
+
if config.use_flash_attn == "auto":
|
| 752 |
+
if flash_attn_varlen_func:
|
| 753 |
+
if config.bf16 or config.fp16:
|
| 754 |
+
logger.warn("Try importing flash-attention.")
|
| 755 |
+
config.use_flash_attn = True
|
| 756 |
+
else:
|
| 757 |
+
config.use_flash_attn = False
|
| 758 |
+
logger.warn("Flash attention will be disabled because it does NOT support fp32.")
|
| 759 |
+
else:
|
| 760 |
+
config.use_flash_attn = False
|
| 761 |
+
logger.warn("Please install FlashAttention first, " "e.g., with pip install flash-attn")
|
| 762 |
self.model = ZhinaoModel(config)
|
| 763 |
self.vocab_size = config.vocab_size
|
| 764 |
self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
|
|
|
|
| 772 |
if config.fp16:
|
| 773 |
self.model.half()
|
| 774 |
self.lm_head.half()
|
| 775 |
+
self.linear.half()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 776 |
|
| 777 |
self.post_init()
|
| 778 |
|