Instructions to use osunlp/ARLoop-1.2B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use osunlp/ARLoop-1.2B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="osunlp/ARLoop-1.2B", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("osunlp/ARLoop-1.2B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use osunlp/ARLoop-1.2B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "osunlp/ARLoop-1.2B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "osunlp/ARLoop-1.2B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/osunlp/ARLoop-1.2B
- SGLang
How to use osunlp/ARLoop-1.2B 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 "osunlp/ARLoop-1.2B" \ --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": "osunlp/ARLoop-1.2B", "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 "osunlp/ARLoop-1.2B" \ --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": "osunlp/ARLoop-1.2B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use osunlp/ARLoop-1.2B with Docker Model Runner:
docker model run hf.co/osunlp/ARLoop-1.2B
Default to BF16 weights for inference
Browse files- README.md +3 -1
- config.json +3 -2
- modeling_arloop.py +1 -1
README.md
CHANGED
|
@@ -33,7 +33,7 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
| 33 |
model_id = "osunlp/ARLoop-1.3B" # Or the local ARLOOP_hf directory.
|
| 34 |
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
| 35 |
model = AutoModelForCausalLM.from_pretrained(
|
| 36 |
-
model_id, trust_remote_code=True, dtype=torch.
|
| 37 |
).to("cuda").eval()
|
| 38 |
inputs = tokenizer("The capital of France is", return_tensors="pt").to("cuda")
|
| 39 |
with torch.inference_mode():
|
|
@@ -41,6 +41,8 @@ with torch.inference_mode():
|
|
| 41 |
print(tokenizer.decode(output[0], skip_special_tokens=True))
|
| 42 |
```
|
| 43 |
|
|
|
|
|
|
|
| 44 |
## Architecture
|
| 45 |
|
| 46 |
| Property | Value |
|
|
|
|
| 33 |
model_id = "osunlp/ARLoop-1.3B" # Or the local ARLOOP_hf directory.
|
| 34 |
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
| 35 |
model = AutoModelForCausalLM.from_pretrained(
|
| 36 |
+
model_id, trust_remote_code=True, dtype=torch.bfloat16,
|
| 37 |
).to("cuda").eval()
|
| 38 |
inputs = tokenizer("The capital of France is", return_tensors="pt").to("cuda")
|
| 39 |
with torch.inference_mode():
|
|
|
|
| 41 |
print(tokenizer.decode(output[0], skip_special_tokens=True))
|
| 42 |
```
|
| 43 |
|
| 44 |
+
Weights load in BF16 for inference. The stored checkpoint retains the original FP32 weights; routing and normalization statistics use FP32 internally.
|
| 45 |
+
|
| 46 |
## Architecture
|
| 47 |
|
| 48 |
| Property | Value |
|
config.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
| 8 |
"AutoModelForCausalLM": "modeling_arloop.ARLoopForCausalLM"
|
| 9 |
},
|
| 10 |
"bos_token_id": 0,
|
| 11 |
-
"dtype": "
|
| 12 |
"embedding_scale": 1.0,
|
| 13 |
"eos_token_id": 0,
|
| 14 |
"head_dim": 128,
|
|
@@ -31,5 +31,6 @@
|
|
| 31 |
"tie_word_embeddings": true,
|
| 32 |
"transformers_version": "5.12.1",
|
| 33 |
"use_cache": true,
|
| 34 |
-
"vocab_size": 49152
|
|
|
|
| 35 |
}
|
|
|
|
| 8 |
"AutoModelForCausalLM": "modeling_arloop.ARLoopForCausalLM"
|
| 9 |
},
|
| 10 |
"bos_token_id": 0,
|
| 11 |
+
"dtype": "bfloat16",
|
| 12 |
"embedding_scale": 1.0,
|
| 13 |
"eos_token_id": 0,
|
| 14 |
"head_dim": 128,
|
|
|
|
| 31 |
"tie_word_embeddings": true,
|
| 32 |
"transformers_version": "5.12.1",
|
| 33 |
"use_cache": true,
|
| 34 |
+
"vocab_size": 49152,
|
| 35 |
+
"torch_dtype": "bfloat16"
|
| 36 |
}
|
modeling_arloop.py
CHANGED
|
@@ -182,7 +182,7 @@ class ARLoopForCausalLM(PreTrainedModel, GenerationMixin):
|
|
| 182 |
if not bool(attention_mask.all()):
|
| 183 |
mask = (key_indices[None, :] <= query_indices[:, None])[None, None, :, :]
|
| 184 |
mask = mask & attention_mask[:, None, None, :].bool()
|
| 185 |
-
#
|
| 186 |
with torch.autocast(device_type=input_ids.device.type, dtype=torch.bfloat16):
|
| 187 |
embedded = (self.transformer.wte(input_ids) * self.config.embedding_scale).to(torch.bfloat16)
|
| 188 |
ve = self.shared_value_embedding(input_ids)
|
|
|
|
| 182 |
if not bool(attention_mask.all()):
|
| 183 |
mask = (key_indices[None, :] <= query_indices[:, None])[None, None, :, :]
|
| 184 |
mask = mask & attention_mask[:, None, None, :].bool()
|
| 185 |
+
# Use BF16 activations; parameters follow the requested loading dtype.
|
| 186 |
with torch.autocast(device_type=input_ids.device.type, dtype=torch.bfloat16):
|
| 187 |
embedded = (self.transformer.wte(input_ids) * self.config.embedding_scale).to(torch.bfloat16)
|
| 188 |
ve = self.shared_value_embedding(input_ids)
|