Text Generation
Transformers
Safetensors
PyTorch
English
neolm
causal-lm
custom-code
pretrained
foundation
custom_code
Instructions to use MaagDeveloper/NeoLM-Small-Base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MaagDeveloper/NeoLM-Small-Base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="MaagDeveloper/NeoLM-Small-Base", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("MaagDeveloper/NeoLM-Small-Base", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use MaagDeveloper/NeoLM-Small-Base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MaagDeveloper/NeoLM-Small-Base" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MaagDeveloper/NeoLM-Small-Base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/MaagDeveloper/NeoLM-Small-Base
- SGLang
How to use MaagDeveloper/NeoLM-Small-Base 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 "MaagDeveloper/NeoLM-Small-Base" \ --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": "MaagDeveloper/NeoLM-Small-Base", "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 "MaagDeveloper/NeoLM-Small-Base" \ --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": "MaagDeveloper/NeoLM-Small-Base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use MaagDeveloper/NeoLM-Small-Base with Docker Model Runner:
docker model run hf.co/MaagDeveloper/NeoLM-Small-Base
Update README.md
Browse files
README.md
CHANGED
|
@@ -21,7 +21,7 @@ library_name: transformers
|
|
| 21 |
|
| 22 |
**NeoLM-Small-Base** is an English-focused, decoder-only Transformer language model trained from scratch with PyTorch and Hugging Face Transformers. This repository publishes the **Stage 1 Foundation** base-model checkpoint in **bfloat16** format. It is a **base next-token prediction model**, not an instruction-tuned chat assistant.
|
| 23 |
|
| 24 |
-
The fixed Foundation release can be loaded using the `stage1-foundation` revision
|
| 25 |
|
| 26 |
## Architecture
|
| 27 |
|
|
@@ -82,7 +82,6 @@ This is a released training checkpoint rather than a claim of complete convergen
|
|
| 82 |
Install compatible versions of `torch` and `transformers`. The model requires custom Python code, so review the repository code before enabling `trust_remote_code=True`.
|
| 83 |
|
| 84 |
```python
|
| 85 |
-
import torch
|
| 86 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 87 |
|
| 88 |
repo_id = "MaagDeveloper/NeoLM-Small-Base"
|
|
@@ -91,28 +90,79 @@ revision = "stage1-foundation"
|
|
| 91 |
tokenizer = AutoTokenizer.from_pretrained(
|
| 92 |
repo_id, revision=revision, trust_remote_code=True
|
| 93 |
)
|
|
|
|
| 94 |
model = AutoModelForCausalLM.from_pretrained(
|
| 95 |
repo_id, revision=revision, trust_remote_code=True,
|
| 96 |
-
dtype=
|
| 97 |
).eval()
|
| 98 |
|
| 99 |
-
# For a CPU that does not support BF16 well,
|
| 100 |
prompt = "The future of artificial intelligence"
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 114 |
```
|
| 115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
The code above is **text completion**, not role-based chat. NeoLM-Small-Base may not reliably follow instructions, answer factual questions, or perform multi-step reasoning. A separate instruction-tuned model belongs in a distinct repository.
|
| 117 |
|
| 118 |
## Evaluation and limitations
|
|
|
|
| 21 |
|
| 22 |
**NeoLM-Small-Base** is an English-focused, decoder-only Transformer language model trained from scratch with PyTorch and Hugging Face Transformers. This repository publishes the **Stage 1 Foundation** base-model checkpoint in **bfloat16** format. It is a **base next-token prediction model**, not an instruction-tuned chat assistant.
|
| 23 |
|
| 24 |
+
The fixed Foundation release can be loaded using the `stage1-foundation` revision.
|
| 25 |
|
| 26 |
## Architecture
|
| 27 |
|
|
|
|
| 82 |
Install compatible versions of `torch` and `transformers`. The model requires custom Python code, so review the repository code before enabling `trust_remote_code=True`.
|
| 83 |
|
| 84 |
```python
|
|
|
|
| 85 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 86 |
|
| 87 |
repo_id = "MaagDeveloper/NeoLM-Small-Base"
|
|
|
|
| 90 |
tokenizer = AutoTokenizer.from_pretrained(
|
| 91 |
repo_id, revision=revision, trust_remote_code=True
|
| 92 |
)
|
| 93 |
+
|
| 94 |
model = AutoModelForCausalLM.from_pretrained(
|
| 95 |
repo_id, revision=revision, trust_remote_code=True,
|
| 96 |
+
dtype="auto",
|
| 97 |
).eval()
|
| 98 |
|
| 99 |
+
# For a CPU that does not support BF16 well, use dtype=torch.float32 instead.
|
| 100 |
prompt = "The future of artificial intelligence"
|
| 101 |
+
|
| 102 |
+
inputs = tokenizer(
|
| 103 |
+
prompt, return_tensors="pt", truncation=True, max_length=1024
|
| 104 |
+
)
|
| 105 |
+
|
| 106 |
+
outputs = model.generate(
|
| 107 |
+
**inputs,
|
| 108 |
+
max_new_tokens=64,
|
| 109 |
+
do_sample=True,
|
| 110 |
+
temperature=0.8,
|
| 111 |
+
top_p=0.9,
|
| 112 |
+
repetition_penalty=1.15,
|
| 113 |
+
eos_token_id=tokenizer.eos_token_id,
|
| 114 |
+
pad_token_id=tokenizer.pad_token_id,
|
| 115 |
+
)
|
| 116 |
+
|
| 117 |
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 118 |
```
|
| 119 |
|
| 120 |
+
|
| 121 |
+
## Streaming Text Generation
|
| 122 |
+
|
| 123 |
+
You can stream generated text progressively using Hugging Face Transformers' `TextStreamer`.
|
| 124 |
+
|
| 125 |
+
```python
|
| 126 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, TextStreamer
|
| 127 |
+
|
| 128 |
+
repo_id = "MaagDeveloper/NeoLM-Small-Base"
|
| 129 |
+
revision = "stage1-foundation"
|
| 130 |
+
|
| 131 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 132 |
+
repo_id,
|
| 133 |
+
revision=revision,
|
| 134 |
+
trust_remote_code=True,
|
| 135 |
+
)
|
| 136 |
+
|
| 137 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 138 |
+
repo_id,
|
| 139 |
+
revision=revision,
|
| 140 |
+
trust_remote_code=True,
|
| 141 |
+
dtype="auto",
|
| 142 |
+
).eval()
|
| 143 |
+
|
| 144 |
+
streamer = TextStreamer(
|
| 145 |
+
tokenizer,
|
| 146 |
+
skip_prompt=False,
|
| 147 |
+
skip_special_tokens=True,
|
| 148 |
+
)
|
| 149 |
+
|
| 150 |
+
prompt = "Once upon a time"
|
| 151 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 152 |
+
|
| 153 |
+
model.generate(
|
| 154 |
+
**inputs,
|
| 155 |
+
streamer=streamer,
|
| 156 |
+
max_new_tokens=100,
|
| 157 |
+
do_sample=True,
|
| 158 |
+
temperature=0.8,
|
| 159 |
+
top_p=0.9,
|
| 160 |
+
repetition_penalty=1.15,
|
| 161 |
+
eos_token_id=tokenizer.eos_token_id,
|
| 162 |
+
pad_token_id=tokenizer.pad_token_id,
|
| 163 |
+
)
|
| 164 |
+
```
|
| 165 |
+
|
| 166 |
The code above is **text completion**, not role-based chat. NeoLM-Small-Base may not reliably follow instructions, answer factual questions, or perform multi-step reasoning. A separate instruction-tuned model belongs in a distinct repository.
|
| 167 |
|
| 168 |
## Evaluation and limitations
|