Text Generation
Transformers
Safetensors
ouro
looped-language-model
reasoning
recurrent-depth
conversational
custom_code
Instructions to use ByteDance/Ouro-1.4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ByteDance/Ouro-1.4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ByteDance/Ouro-1.4B", 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", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ByteDance/Ouro-1.4B 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" # 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", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ByteDance/Ouro-1.4B
- SGLang
How to use ByteDance/Ouro-1.4B 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" \ --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", "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" \ --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", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ByteDance/Ouro-1.4B with Docker Model Runner:
docker model run hf.co/ByteDance/Ouro-1.4B
Upload folder using huggingface_hub
Browse files- README.md +31 -0
- config.json +1 -0
- configuration_ouro.py +4 -0
README.md
CHANGED
|
@@ -27,6 +27,37 @@ tags:
|
|
| 27 |
- **Iterative Latent Reasoning**: Performs reasoning through recurrent computation in latent space
|
| 28 |
- **Adaptive Computation**: Supports early exit mechanisms for dynamic compute allocation
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
## Model Architecture
|
| 31 |
|
| 32 |
Ouro-1.4B is based on the decoder-only Transformer architecture with parameter sharing across recurrent steps:
|
|
|
|
| 27 |
- **Iterative Latent Reasoning**: Performs reasoning through recurrent computation in latent space
|
| 28 |
- **Adaptive Computation**: Supports early exit mechanisms for dynamic compute allocation
|
| 29 |
|
| 30 |
+
## Configuration
|
| 31 |
+
|
| 32 |
+
### Recurrent Steps and Adaptive Exit
|
| 33 |
+
|
| 34 |
+
The model's computational behavior can be configured through the `config.json` file:
|
| 35 |
+
|
| 36 |
+
```json
|
| 37 |
+
{
|
| 38 |
+
"total_ut_steps": 4,
|
| 39 |
+
"early_exit_threshold": 1.0
|
| 40 |
+
}
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
- **`total_ut_steps`**: Controls the number of recurrent steps (default: 4). You can adjust this value to trade off between performance and computation time.
|
| 44 |
+
- **`early_exit_threshold`**: Controls the adaptive exit mechanism (default: 1.0). Lower values encourage earlier exit, while 1.0 means always use all steps.
|
| 45 |
+
|
| 46 |
+
**Example: Modify recurrent steps**
|
| 47 |
+
```python
|
| 48 |
+
from transformers import AutoConfig, AutoModelForCausalLM
|
| 49 |
+
|
| 50 |
+
config = AutoConfig.from_pretrained("ByteDance/Ouro-1.4B")
|
| 51 |
+
config.total_ut_steps = 3 # Use 3 recurrent steps instead of 4
|
| 52 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 53 |
+
"ByteDance/Ouro-1.4B",
|
| 54 |
+
config=config,
|
| 55 |
+
device_map="auto"
|
| 56 |
+
)
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
> **Note**: vLLM does not currently support the adaptive exit feature due to its inference optimization characteristics. When using vLLM, the model will always execute the full number of `total_ut_steps`.
|
| 60 |
+
|
| 61 |
## Model Architecture
|
| 62 |
|
| 63 |
Ouro-1.4B is based on the decoder-only Transformer architecture with parameter sharing across recurrent steps:
|
config.json
CHANGED
|
@@ -54,6 +54,7 @@
|
|
| 54 |
"tie_word_embeddings": false,
|
| 55 |
"torch_dtype": "bfloat16",
|
| 56 |
"total_ut_steps": 4,
|
|
|
|
| 57 |
"transformers_version": "4.55.0",
|
| 58 |
"use_cache": true,
|
| 59 |
"use_sliding_window": false,
|
|
|
|
| 54 |
"tie_word_embeddings": false,
|
| 55 |
"torch_dtype": "bfloat16",
|
| 56 |
"total_ut_steps": 4,
|
| 57 |
+
"early_exit_threshold": 1.0,
|
| 58 |
"transformers_version": "4.55.0",
|
| 59 |
"use_cache": true,
|
| 60 |
"use_sliding_window": false,
|
configuration_ouro.py
CHANGED
|
@@ -169,6 +169,8 @@ class OuroConfig(PretrainedConfig):
|
|
| 169 |
max_window_layers=28,
|
| 170 |
layer_types=None,
|
| 171 |
attention_dropout=0.0,
|
|
|
|
|
|
|
| 172 |
**kwargs,
|
| 173 |
):
|
| 174 |
self.vocab_size = vocab_size
|
|
@@ -193,6 +195,8 @@ class OuroConfig(PretrainedConfig):
|
|
| 193 |
self.rope_theta = rope_theta
|
| 194 |
self.rope_scaling = rope_scaling
|
| 195 |
self.attention_dropout = attention_dropout
|
|
|
|
|
|
|
| 196 |
# Validate the correctness of rotary position embeddings parameters
|
| 197 |
# BC: if there is a 'type' field, move it to 'rope_type'.
|
| 198 |
if self.rope_scaling is not None and "type" in self.rope_scaling:
|
|
|
|
| 169 |
max_window_layers=28,
|
| 170 |
layer_types=None,
|
| 171 |
attention_dropout=0.0,
|
| 172 |
+
total_ut_steps=4,
|
| 173 |
+
early_exit_threshold=1.0,
|
| 174 |
**kwargs,
|
| 175 |
):
|
| 176 |
self.vocab_size = vocab_size
|
|
|
|
| 195 |
self.rope_theta = rope_theta
|
| 196 |
self.rope_scaling = rope_scaling
|
| 197 |
self.attention_dropout = attention_dropout
|
| 198 |
+
self.total_ut_steps = total_ut_steps
|
| 199 |
+
self.early_exit_threshold = early_exit_threshold
|
| 200 |
# Validate the correctness of rotary position embeddings parameters
|
| 201 |
# BC: if there is a 'type' field, move it to 'rope_type'.
|
| 202 |
if self.rope_scaling is not None and "type" in self.rope_scaling:
|