Text Generation
Transformers
Safetensors
qwen3
custom_generate
conversational
text-generation-inference
Instructions to use transformers-community/contrastive-search with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use transformers-community/contrastive-search with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="transformers-community/contrastive-search") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("transformers-community/contrastive-search") model = AutoModelForCausalLM.from_pretrained("transformers-community/contrastive-search", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use transformers-community/contrastive-search with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "transformers-community/contrastive-search" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "transformers-community/contrastive-search", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/transformers-community/contrastive-search
- SGLang
How to use transformers-community/contrastive-search 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 "transformers-community/contrastive-search" \ --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": "transformers-community/contrastive-search", "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 "transformers-community/contrastive-search" \ --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": "transformers-community/contrastive-search", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use transformers-community/contrastive-search with Docker Model Runner:
docker model run hf.co/transformers-community/contrastive-search
Commit History
-
Fix mask None-ness (#5)
- Fix mask None-ness (63af1209f3d821955856aedc24087e6bc03a5914)c8e1d06
-
Update custom_generate/generate.py
Verified signature89ece6d
-
Fix typo
Verified signature00ab760 -
Fix for new versions
Verified signaturecd66a74
-
now fixed
Verified signature2ffb799 -
update for v5
Verified signature818d17e
-
Update cache format (#3)
Verified signature- Update custom_generate/generate.py (18740b73b7543c98b8961bc5489661f181889a2f) - Update custom_generate/generate.py (9b4bf516f80bb86996ecf6c8e8c99ed1a1afdead) - Update custom_generate/generate.py (def1b87d83f9a9d7a52c517e21e517946ffcf67b) - Update custom_generate/generate.py (525fd175fe5561603d20af6cd032c33f5f91b52c) Co-authored-by: Cyril Vallez <cyrilvallez@users.noreply.huggingface.co>bbf36bb
-
Fix a bug (#1)
Verified signature- Fix a bug (8f1c855ae874bdc25b5bd121cdf592b3280ffd26) Co-authored-by: Raushan Turganbay <RaushanTurganbay@users.noreply.huggingface.co>245ec5a
-
Upload folder using huggingface_hub
Verified signature1e37df0 -
Upload folder using huggingface_hub
Verified signature45cf90c -
Delete .ruff_cache
Verified signaturefd71e60 -
Upload folder using huggingface_hub
Verified signature6891872 -
Upload folder using huggingface_hub
Verified signature9da4cff -
Delete .ruff_cache
Verified signature2ae24ea -
Upload folder using huggingface_hub
Verified signature8a86b09 -
Upload folder using huggingface_hub
Verified signature7d89f91 -
initial commit
Verified signaturef466cfe