Instructions to use zstanjj/SlimPLM-Query-Rewriting with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zstanjj/SlimPLM-Query-Rewriting with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="zstanjj/SlimPLM-Query-Rewriting")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("zstanjj/SlimPLM-Query-Rewriting") model = AutoModelForCausalLM.from_pretrained("zstanjj/SlimPLM-Query-Rewriting", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use zstanjj/SlimPLM-Query-Rewriting with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "zstanjj/SlimPLM-Query-Rewriting" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "zstanjj/SlimPLM-Query-Rewriting", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/zstanjj/SlimPLM-Query-Rewriting
- SGLang
How to use zstanjj/SlimPLM-Query-Rewriting 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 "zstanjj/SlimPLM-Query-Rewriting" \ --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": "zstanjj/SlimPLM-Query-Rewriting", "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 "zstanjj/SlimPLM-Query-Rewriting" \ --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": "zstanjj/SlimPLM-Query-Rewriting", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use zstanjj/SlimPLM-Query-Rewriting with Docker Model Runner:
docker model run hf.co/zstanjj/SlimPLM-Query-Rewriting
Update README.md
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465---license: llama2---<!-- markdownlint-disable first-line-h1 --><!-- markdownlint-disable html -->
<div align="center"><h1> CheXagent</h1></div>
<p align="center">📝 <a href="https://arxiv.org/abs/2402.12052" target="_blank">Paper</a> • 🤗 <a href="https://huggingface.co/zstanjj/SlimPLM-Query-Rewriting/" target="_blank">Hugging Face</a> • 🧩 <a href="https://github.com/plageon/SlimPLM" target="_blank">Github</a></p>
<div align="center"></div>
## ✨ Latest News
- [1/25/2024]: Search Necessity Judgment Model released in [Hugging Face](https://huggingface.co/zstanjj/SlimPLM-Search-Necessity-Judgment/).- [2/20/2024]: Query Rewriting Model released in [Hugging Face](https://huggingface.co/zstanjj/SlimPLM-Query-Rewriting/).
## 🎬 Get Started
```pythonfrom transformers import AutoModelForCausalLM, AutoTokenizerimport torch
# construct promptquestion = "Who voices Darth Vader in Star Wars Episodes III-VI, IX Rogue One, and Rebels?"heuristic_answer = "The voice of Darth Vader in Star Wars is provided by British actor James Earl Jones. He first voiced the character in the 1977 film \"Star Wars: Episode IV - A New Hope\", and his performance has been used in all subsequent Star Wars films, including the prequels and sequels."prompt = (f"<s>[INST] <<SYS>>\nYou are a helpful assistant. Your task is to parse user input into" f" structured formats according to the coarse answer. Current datatime is 2023-12-20 9:47:28" f" <</SYS>>\n Course answer: (({heuristic_answer}))\nQuestion: (({question})) [/INST]")params_query_rewrite = {"repetition_penalty": 1.05, "temperature": 0.01, "top_k": 1, "top_p": 0.85, "max_new_tokens": 512, "do_sample": False, "seed": 2023}
# deploy modelmodel = AutoModelForCausalLM.from_pretrained("zstanjj/SlimPLM-Query-Rewriting").eval()if torch.cuda.is_available(): model.cuda()tokenizer = AutoTokenizer.from_pretrained("zstanjj/SlimPLM-Query-Rewriting")
# run inference input_ids = tokenizer.encode(question, return_tensors="pt")len_input_ids = len(input_ids[0])if torch.cuda.is_available(): input_ids = input_ids.cuda()outputs = model.generate(input_ids)res = tokenizer.decode(outputs[0][len_input_ids:], skip_special_tokens=True)print(res)```
## ✏️ Citation
```@inproceedings{Tan2024SmallMB, title={Small Models, Big Insights: Leveraging Slim Proxy Models To Decide When and What to Retrieve for LLMs}, author={Jiejun Tan and Zhicheng Dou and Yutao Zhu and Peidong Guo and Kun Fang and Jinhui Wen}, year={2024}, url={https://api.semanticscholar.org/CorpusID:267750726}}```README.md+62