Instructions to use Pramodith/topN_sigma_generation with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Pramodith/topN_sigma_generation with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Pramodith/topN_sigma_generation") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Pramodith/topN_sigma_generation") model = AutoModelForCausalLM.from_pretrained("Pramodith/topN_sigma_generation") 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Pramodith/topN_sigma_generation with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Pramodith/topN_sigma_generation" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Pramodith/topN_sigma_generation", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Pramodith/topN_sigma_generation
- SGLang
How to use Pramodith/topN_sigma_generation 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 "Pramodith/topN_sigma_generation" \ --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": "Pramodith/topN_sigma_generation", "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 "Pramodith/topN_sigma_generation" \ --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": "Pramodith/topN_sigma_generation", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Pramodith/topN_sigma_generation with Docker Model Runner:
docker model run hf.co/Pramodith/topN_sigma_generation
Update Readme.md
Browse files
README.md
CHANGED
|
@@ -46,14 +46,24 @@ The authors recommend using `n_sigma=1.0` for most use cases, but you can experi
|
|
| 46 |
|
| 47 |
```py
|
| 48 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
# There is a print message hardcoded in the custom generation method
|
| 55 |
-
gen_out = model.generate(**
|
| 56 |
-
|
|
|
|
| 57 |
```
|
| 58 |
|
| 59 |
### Citation
|
|
|
|
| 46 |
|
| 47 |
```py
|
| 48 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 49 |
+
from transformers import GenerationConfig
|
| 50 |
+
|
| 51 |
+
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-0.6B")
|
| 52 |
+
model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-0.6B", device_map="auto")
|
| 53 |
+
generation_config = GenerationConfig(temperature=1.5, max_length=128)
|
| 54 |
+
|
| 55 |
+
messages = [{"role":"user", "content": "Write a story about a dog and cat becoming friends."}]
|
| 56 |
+
text = tokenizer.apply_chat_template(
|
| 57 |
+
messages,
|
| 58 |
+
tokenize=False,
|
| 59 |
+
add_generation_prompt=True,
|
| 60 |
+
enable_thinking=False # Switches between thinking and non-thinking modes. Default is True.
|
| 61 |
+
)
|
| 62 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
| 63 |
# There is a print message hardcoded in the custom generation method
|
| 64 |
+
gen_out = model.generate(**model_inputs, n_sigma=1.0, generation_config=generation_config, custom_generate="Pramodith/topN_sigma_generation", trust_remote_code=True)
|
| 65 |
+
|
| 66 |
+
print(tokenizer.batch_decode(gen_out, skip_special_tokens=True)[0])
|
| 67 |
```
|
| 68 |
|
| 69 |
### Citation
|