Text Generation
Transformers
Safetensors
ouro
looped-language-model
reasoning
recurrent-depth
thinking
chain-of-thought
conversational
custom_code
Instructions to use ByteDance/Ouro-1.4B-Thinking with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ByteDance/Ouro-1.4B-Thinking with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ByteDance/Ouro-1.4B-Thinking", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("ByteDance/Ouro-1.4B-Thinking", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ByteDance/Ouro-1.4B-Thinking with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ByteDance/Ouro-1.4B-Thinking" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ByteDance/Ouro-1.4B-Thinking", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ByteDance/Ouro-1.4B-Thinking
- SGLang
How to use ByteDance/Ouro-1.4B-Thinking 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 "ByteDance/Ouro-1.4B-Thinking" \ --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": "ByteDance/Ouro-1.4B-Thinking", "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 "ByteDance/Ouro-1.4B-Thinking" \ --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": "ByteDance/Ouro-1.4B-Thinking", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ByteDance/Ouro-1.4B-Thinking with Docker Model Runner:
docker model run hf.co/ByteDance/Ouro-1.4B-Thinking
Fix cache in UniversalTransformerCache
#7
by Thisusernamealreadyexists00 - opened
- modeling_ouro.py +9 -8
modeling_ouro.py
CHANGED
|
@@ -146,21 +146,22 @@ class UniversalTransformerCache(Cache):
|
|
| 146 |
) -> tuple[torch.Tensor, torch.Tensor]:
|
| 147 |
if layer_idx < 0:
|
| 148 |
raise ValueError(f"layer_idx must be non-negative, got {layer_idx}")
|
| 149 |
-
|
| 150 |
if self.max_cache_size is not None and layer_idx >= self.max_cache_size:
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
)
|
| 155 |
-
|
|
|
|
| 156 |
# Expand cache storage so the requested index is available.
|
| 157 |
while len(self.key_cache) <= layer_idx:
|
| 158 |
self.key_cache.append(None)
|
| 159 |
self.value_cache.append(None)
|
| 160 |
-
|
| 161 |
cached_key = self.key_cache[layer_idx]
|
| 162 |
cached_value = self.value_cache[layer_idx]
|
| 163 |
-
|
| 164 |
if cached_key is None:
|
| 165 |
self.key_cache[layer_idx] = key_states
|
| 166 |
self.value_cache[layer_idx] = value_states
|
|
|
|
| 146 |
) -> tuple[torch.Tensor, torch.Tensor]:
|
| 147 |
if layer_idx < 0:
|
| 148 |
raise ValueError(f"layer_idx must be non-negative, got {layer_idx}")
|
| 149 |
+
|
| 150 |
if self.max_cache_size is not None and layer_idx >= self.max_cache_size:
|
| 151 |
+
self.max_cache_size = layer_idx + 1
|
| 152 |
+
|
| 153 |
+
while len(self.key_cache) <= layer_idx:
|
| 154 |
+
self.key_cache.append(None)
|
| 155 |
+
self.value_cache.append(None)
|
| 156 |
+
|
| 157 |
# Expand cache storage so the requested index is available.
|
| 158 |
while len(self.key_cache) <= layer_idx:
|
| 159 |
self.key_cache.append(None)
|
| 160 |
self.value_cache.append(None)
|
| 161 |
+
|
| 162 |
cached_key = self.key_cache[layer_idx]
|
| 163 |
cached_value = self.value_cache[layer_idx]
|
| 164 |
+
|
| 165 |
if cached_key is None:
|
| 166 |
self.key_cache[layer_idx] = key_states
|
| 167 |
self.value_cache[layer_idx] = value_states
|