Text Generation
Transformers
Safetensors
llama
custom_generate
sampling
kvcache
text-generation-inference
Instructions to use manueldeprada/sampling_with_kvcache_hf_helpers with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use manueldeprada/sampling_with_kvcache_hf_helpers with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="manueldeprada/sampling_with_kvcache_hf_helpers")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("manueldeprada/sampling_with_kvcache_hf_helpers") model = AutoModelForCausalLM.from_pretrained("manueldeprada/sampling_with_kvcache_hf_helpers", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use manueldeprada/sampling_with_kvcache_hf_helpers with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "manueldeprada/sampling_with_kvcache_hf_helpers" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "manueldeprada/sampling_with_kvcache_hf_helpers", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/manueldeprada/sampling_with_kvcache_hf_helpers
- SGLang
How to use manueldeprada/sampling_with_kvcache_hf_helpers 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 "manueldeprada/sampling_with_kvcache_hf_helpers" \ --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": "manueldeprada/sampling_with_kvcache_hf_helpers", "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 "manueldeprada/sampling_with_kvcache_hf_helpers" \ --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": "manueldeprada/sampling_with_kvcache_hf_helpers", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use manueldeprada/sampling_with_kvcache_hf_helpers with Docker Model Runner:
docker model run hf.co/manueldeprada/sampling_with_kvcache_hf_helpers
Commit ·
97c3e33
1
Parent(s): 47784f5
update
Browse files
README.md
CHANGED
|
@@ -48,19 +48,19 @@ model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-0.5B-Instruct", devic
|
|
| 48 |
inputs = tokenizer(["The quick brown"], return_tensors="pt").to(model.device)
|
| 49 |
|
| 50 |
# Basic sampling
|
| 51 |
-
gen_out = model.generate(**inputs, custom_generate="manueldeprada/
|
| 52 |
|
| 53 |
# With temperature
|
| 54 |
-
gen_out = model.generate(**inputs, custom_generate="manueldeprada/
|
| 55 |
|
| 56 |
# With top-k
|
| 57 |
-
gen_out = model.generate(**inputs, custom_generate="manueldeprada/
|
| 58 |
|
| 59 |
# With top-p (nucleus sampling)
|
| 60 |
-
gen_out = model.generate(**inputs, custom_generate="manueldeprada/
|
| 61 |
|
| 62 |
# Greedy decoding (no sampling)
|
| 63 |
-
gen_out = model.generate(**inputs, custom_generate="manueldeprada/
|
| 64 |
|
| 65 |
# Get detailed output with probabilities
|
| 66 |
gen_out = model.generate(
|
|
|
|
| 48 |
inputs = tokenizer(["The quick brown"], return_tensors="pt").to(model.device)
|
| 49 |
|
| 50 |
# Basic sampling
|
| 51 |
+
gen_out = model.generate(**inputs, custom_generate="manueldeprada/sampling_with_kvcache_hf_helpers", trust_remote_code=True)
|
| 52 |
|
| 53 |
# With temperature
|
| 54 |
+
gen_out = model.generate(**inputs, custom_generate="manueldeprada/sampling_with_kvcache_hf_helpers", temperature=0.8, trust_remote_code=True)
|
| 55 |
|
| 56 |
# With top-k
|
| 57 |
+
gen_out = model.generate(**inputs, custom_generate="manueldeprada/sampling_with_kvcache_hf_helpers", top_k=50, trust_remote_code=True)
|
| 58 |
|
| 59 |
# With top-p (nucleus sampling)
|
| 60 |
+
gen_out = model.generate(**inputs, custom_generate="manueldeprada/sampling_with_kvcache_hf_helpers", top_p=0.9, trust_remote_code=True)
|
| 61 |
|
| 62 |
# Greedy decoding (no sampling)
|
| 63 |
+
gen_out = model.generate(**inputs, custom_generate="manueldeprada/sampling_with_kvcache_hf_helpers", do_sample=False, trust_remote_code=True)
|
| 64 |
|
| 65 |
# Get detailed output with probabilities
|
| 66 |
gen_out = model.generate(
|