Open Machine commited on
Update README.md
Browse files
README.md
CHANGED
|
@@ -5,62 +5,278 @@ library_name: pytorch
|
|
| 5 |
pipeline_tag: text-generation
|
| 6 |
tags:
|
| 7 |
- text-generation
|
|
|
|
|
|
|
| 8 |
- bfloat16
|
|
|
|
| 9 |
- inference-only
|
| 10 |
- local-inference
|
|
|
|
|
|
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
-
#
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
|
|
|
| 17 |
|
| 18 |
-
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
- `luluv2_live_inference.py` β streaming inference engine.
|
| 22 |
-
- `luluv2_optimized_engine.py` β optimized local inference engine with cache paths.
|
| 23 |
-
- `app.py` β local Gradio chat UI.
|
| 24 |
-
- `run_inference.py` β minimal command-line runner.
|
| 25 |
-
- `tokenizer/` β local tokenizer files and chat template.
|
| 26 |
|
| 27 |
-
|
| 28 |
|
| 29 |
-
|
| 30 |
|
| 31 |
-
|
| 32 |
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
```text
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
```
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
-
|
| 43 |
|
| 44 |
```bash
|
|
|
|
|
|
|
| 45 |
pip install -r requirements.txt
|
|
|
|
|
|
|
|
|
|
|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55 |
|
| 56 |
```bash
|
| 57 |
-
python
|
| 58 |
```
|
| 59 |
|
| 60 |
-
##
|
| 61 |
|
| 62 |
-
|
| 63 |
|
| 64 |
-
##
|
| 65 |
|
| 66 |
-
Before
|
|
|
|
| 5 |
pipeline_tag: text-generation
|
| 6 |
tags:
|
| 7 |
- text-generation
|
| 8 |
+
- pytorch
|
| 9 |
+
- custom-architecture
|
| 10 |
- bfloat16
|
| 11 |
+
- native-bf16
|
| 12 |
- inference-only
|
| 13 |
- local-inference
|
| 14 |
+
- no-quantization
|
| 15 |
+
- gradio
|
| 16 |
+
license: apache-2.0
|
| 17 |
---
|
| 18 |
|
| 19 |
+
## OpenMachine Lulu INFORMATION
|
| 20 |
|
| 21 |
+
Important this is native RPT/VWM arhitecture, not Transformers in whole. The model speaks English and several other languages, and it was only tested with few milion examples of UltraChat for chatting.
|
| 22 |
+
You do not need ##quantization.
|
| 23 |
+
Performance on consumer grade
|
| 24 |
|
| 25 |
+
MacBook M3 Pro Max is enough you can run it even on CPU just slower. For MacBook MPS makes a lot of issues with logits,so run it on CPU it will not make issues.
|
| 26 |
+
PC/Windows: On our 32 RTX 5090 works under with 1.3GB of RAM. CTX for 4K is ok even theoretically it can do 32k but its not optimized.
|
| 27 |
|
| 28 |
+
##NOTE: WE DIDN'T MADE QUANTIZATION OF THE MODEL AND WE STRONGLY ENCURAGE YOU NOT TO DO IT AS WELL. IT CAN RUN LOCALLY WITHOUT THAT EVEN ON OLDER DEVICES.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
+
The Fine-Tuning script along with paper comes out very soon. Stay updated.
|
| 31 |
|
| 32 |
+
TIer it appart, play with it let us know what is missing.
|
| 33 |
|
| 34 |
+
Currently we are working on mobile version without quantization as well for the native APP.
|
| 35 |
|
| 36 |
+
Next model will be likley 7-9B parameters also runable on MAC/PC without quantization.
|
| 37 |
+
|
| 38 |
+
The goal of this arhitecture is Reconstruction like brain entity.
|
| 39 |
+
|
| 40 |
+
It has different layout, than standard Transformers.
|
| 41 |
+
|
| 42 |
+
The parts of Inference are still un-optimized as heavly python loops.
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
# LuluV2 Native-bf16
|
| 46 |
+
|
| 47 |
+
LuluV2 is released here as a **custom PyTorch architecture with its own inference runtime**. It is not a standard `transformers.AutoModelForCausalLM` repository and it is not intended to be loaded with `pipeline(...)` or `AutoModelForCausalLM.from_pretrained(...)`.
|
| 48 |
+
|
| 49 |
+
The package is designed for people who want to clone the repository and run the model locally in **native bfloat16**. No quantization, GGUF conversion, GPTQ, AWQ, or other conversion step is required.
|
| 50 |
+
|
| 51 |
+
## What makes this package different
|
| 52 |
+
|
| 53 |
+
Most Hugging Face text-generation repositories expose a standard Transformers model class. LuluV2 does not. The model is packaged as:
|
| 54 |
+
|
| 55 |
+
- a native PyTorch checkpoint: `LULUV2-bf16.pt`
|
| 56 |
+
- a local tokenizer folder: `tokenizer/`
|
| 57 |
+
- a stripped inference-only runtime: `luluv2_inference_runtime.py`
|
| 58 |
+
- a streaming local engine: `luluv2_live_inference.py`
|
| 59 |
+
- a Gradio chat UI: `app.py`
|
| 60 |
+
- a small command-line runner: `run_inference.py`
|
| 61 |
+
|
| 62 |
+
The runtime directly constructs the LuluV2 architecture, loads the checkpoint tensors, and runs local generation. The guard messages printed at startup are intentional: they confirm that the runtime is not pulling external model weights and is not using `AutoModelForCausalLM`.
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
## Files in this repository
|
| 66 |
|
| 67 |
```text
|
| 68 |
+
.
|
| 69 |
+
βββ LULUV2-bf16.pt # native bf16 checkpoint, required
|
| 70 |
+
βββ README.md # this model card
|
| 71 |
+
βββ app.py # local chat UI
|
| 72 |
+
βββ run_inference.py # minimal CLI runner
|
| 73 |
+
βββ luluv2_inference_runtime.py # custom architecture + checkpoint loader
|
| 74 |
+
βββ luluv2_live_inference.py # streaming generation engine
|
| 75 |
+
βββ luluv2_optimized_engine.py # optimized local engine variant
|
| 76 |
+
βββ config.json # HF metadata only; not an AutoModel config
|
| 77 |
+
βββ generation_config.json # default generation settings
|
| 78 |
+
βββ requirements.txt
|
| 79 |
+
βββ tokenizer/ # local tokenizer files
|
| 80 |
```
|
| 81 |
|
| 82 |
+
## Requirements
|
| 83 |
+
|
| 84 |
+
Recommended:
|
| 85 |
+
|
| 86 |
+
- Python 3.10+
|
| 87 |
+
- PyTorch 2.1+
|
| 88 |
+
- CUDA GPU with bfloat16 support for best performance
|
| 89 |
+
- enough VRAM for the native checkpoint size
|
| 90 |
+
|
| 91 |
+
Install the runtime dependencies:
|
| 92 |
+
|
| 93 |
+
```bash
|
| 94 |
+
pip install -r requirements.txt
|
| 95 |
+
```
|
| 96 |
+
|
| 97 |
+
The package is local-first. It uses the tokenizer files included in `tokenizer/` and does not need to download another model at runtime.
|
| 98 |
+
|
| 99 |
+
## Quick start: local chat UI
|
| 100 |
|
| 101 |
+
Clone the model repository, enter the folder, install requirements, and run the UI:
|
| 102 |
|
| 103 |
```bash
|
| 104 |
+
git clone https://huggingface.co/YOUR_USERNAME/YOUR_REPO_NAME
|
| 105 |
+
cd YOUR_REPO_NAME
|
| 106 |
pip install -r requirements.txt
|
| 107 |
+
python app.py --ckpt ./LULUV2-bf16.pt --tokenizer-dir ./tokenizer --dtype bf16 --inbrowser
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
The UI starts a local Gradio chat app. By default it binds to `127.0.0.1` on port `7862`.
|
| 111 |
+
|
| 112 |
+
Useful UI options:
|
| 113 |
+
|
| 114 |
+
```bash
|
| 115 |
+
python app.py \
|
| 116 |
+
--ckpt ./LULUV2-bf16.pt \
|
| 117 |
+
--tokenizer-dir ./tokenizer \
|
| 118 |
+
--device cuda \
|
| 119 |
+
--dtype bf16 \
|
| 120 |
+
--max-context 32768 \
|
| 121 |
+
--inbrowser
|
| 122 |
+
```
|
| 123 |
+
|
| 124 |
+
For CPU testing only:
|
| 125 |
+
|
| 126 |
+
```bash
|
| 127 |
+
python app.py --ckpt ./LULUV2-bf16.pt --device cpu --dtype fp32 --inbrowser
|
| 128 |
+
```
|
| 129 |
+
|
| 130 |
+
CPU mode is mainly for compatibility checks. Real generation is expected to be much slower than GPU inference.
|
| 131 |
+
|
| 132 |
+
## Quick start: command line
|
| 133 |
+
|
| 134 |
+
```bash
|
| 135 |
+
python run_inference.py \
|
| 136 |
+
--ckpt ./LULUV2-bf16.pt \
|
| 137 |
+
--tokenizer-dir ./tokenizer \
|
| 138 |
+
--dtype bf16 \
|
| 139 |
+
--prompt "Write a short introduction to LuluV2."
|
| 140 |
+
```
|
| 141 |
+
|
| 142 |
+
Generation controls:
|
| 143 |
+
|
| 144 |
+
```bash
|
| 145 |
+
python run_inference.py \
|
| 146 |
+
--ckpt ./LULUV2-bf16.pt \
|
| 147 |
+
--prompt "Explain why native bf16 inference matters." \
|
| 148 |
+
--max-new-tokens 700 \
|
| 149 |
+
--temperature 0.65 \
|
| 150 |
+
--top-p 0.90 \
|
| 151 |
+
--top-k 40
|
| 152 |
+
```
|
| 153 |
+
|
| 154 |
+
## Python usage
|
| 155 |
+
|
| 156 |
+
```python
|
| 157 |
+
import torch
|
| 158 |
+
from luluv2_live_inference import LULUV2LiveEngine, GenerationConfig
|
| 159 |
+
|
| 160 |
+
engine = LULUV2LiveEngine(
|
| 161 |
+
ckpt_path="./LULUV2-bf16.pt",
|
| 162 |
+
model_py="luluv2_inference_runtime.py",
|
| 163 |
+
tokenizer_dir="./tokenizer",
|
| 164 |
+
device="cuda",
|
| 165 |
+
dtype="bf16",
|
| 166 |
+
local_files_only=True,
|
| 167 |
+
no_config_download=True,
|
| 168 |
+
)
|
| 169 |
+
|
| 170 |
+
cfg = GenerationConfig(
|
| 171 |
+
max_new_tokens=512,
|
| 172 |
+
temperature=0.65,
|
| 173 |
+
top_p=0.90,
|
| 174 |
+
top_k=40,
|
| 175 |
+
)
|
| 176 |
+
|
| 177 |
+
history = []
|
| 178 |
+
system_prompt = "You are LuluV2, a helpful local AI assistant."
|
| 179 |
+
|
| 180 |
+
for partial_text in engine.generate_stream(
|
| 181 |
+
"What are you?",
|
| 182 |
+
history,
|
| 183 |
+
system_prompt,
|
| 184 |
+
cfg,
|
| 185 |
+
):
|
| 186 |
+
print(partial_text, end="", flush=True)
|
| 187 |
+
|
| 188 |
+
print()
|
| 189 |
+
torch.cuda.empty_cache()
|
| 190 |
+
```
|
| 191 |
+
|
| 192 |
+
## Native bf16: no quantization step
|
| 193 |
+
|
| 194 |
+
This release is meant to be run from the native bf16 checkpoint directly:
|
| 195 |
+
|
| 196 |
+
```text
|
| 197 |
+
LULUV2-bf16.pt
|
| 198 |
```
|
| 199 |
|
| 200 |
+
Do not quantize the model before using this package. Start with:
|
| 201 |
+
|
| 202 |
+
```bash
|
| 203 |
+
--dtype bf16
|
| 204 |
+
```
|
| 205 |
+
|
| 206 |
+
Fallback options are available for hardware that does not support bfloat16:
|
| 207 |
+
|
| 208 |
+
```bash
|
| 209 |
+
--dtype fp16
|
| 210 |
+
--dtype fp32
|
| 211 |
+
```
|
| 212 |
+
|
| 213 |
+
These fallbacks are compatibility modes, not separate releases.
|
| 214 |
+
|
| 215 |
+
## Checkpoint format
|
| 216 |
+
|
| 217 |
+
The runtime expects a PyTorch checkpoint file that contains a model state dictionary under the `model` key. Optional checkpoint fields can include runtime metadata and second-pass refinement weights.
|
| 218 |
+
|
| 219 |
+
At minimum, the repository root should contain:
|
| 220 |
+
|
| 221 |
+
```text
|
| 222 |
+
LULUV2-bf16.pt
|
| 223 |
+
```
|
| 224 |
+
|
| 225 |
+
If the checkpoint is missing or renamed, pass the correct path with `--ckpt`.
|
| 226 |
+
|
| 227 |
+
## What this is not
|
| 228 |
+
|
| 229 |
+
This repository is not:
|
| 230 |
+
|
| 231 |
+
- a training repository
|
| 232 |
+
- a dataset release
|
| 233 |
+
- a quantized model release
|
| 234 |
+
- a GGUF/llama.cpp release
|
| 235 |
+
- a standard Transformers `AutoModelForCausalLM` package
|
| 236 |
+
- a hosted inference-widget-first package
|
| 237 |
+
|
| 238 |
+
Run it locally with the included runtime scripts.
|
| 239 |
+
|
| 240 |
+
## Troubleshooting
|
| 241 |
+
|
| 242 |
+
### `FileNotFoundError: LULUV2-bf16.pt`
|
| 243 |
+
|
| 244 |
+
The checkpoint file is not present or has a different name. Put the checkpoint in the repository root or pass the full path:
|
| 245 |
+
|
| 246 |
+
```bash
|
| 247 |
+
python app.py --ckpt /path/to/LULUV2-bf16.pt --inbrowser
|
| 248 |
+
```
|
| 249 |
+
|
| 250 |
+
### `Checkpoint missing model state dict`
|
| 251 |
+
|
| 252 |
+
The file passed to `--ckpt` is not the expected LuluV2 PyTorch checkpoint. Make sure you are using the native bf16 `.pt` checkpoint, not a config file, tokenizer file, or unrelated export.
|
| 253 |
+
|
| 254 |
+
### CUDA out of memory
|
| 255 |
+
|
| 256 |
+
Try a smaller context window or fewer generated tokens:
|
| 257 |
+
|
| 258 |
+
```bash
|
| 259 |
+
python app.py --ckpt ./LULUV2-bf16.pt --max-context 8192 --inbrowser
|
| 260 |
+
```
|
| 261 |
+
|
| 262 |
+
### Older GPU does not support bf16
|
| 263 |
+
|
| 264 |
+
Try fp16:
|
| 265 |
|
| 266 |
```bash
|
| 267 |
+
python app.py --ckpt ./LULUV2-bf16.pt --dtype fp16 --inbrowser
|
| 268 |
```
|
| 269 |
|
| 270 |
+
For CPU-only compatibility testing:
|
| 271 |
|
| 272 |
```bash
|
| 273 |
+
python app.py --ckpt ./LULUV2-bf16.pt --device cpu --dtype fp32 --inbrowser
|
| 274 |
```
|
| 275 |
|
| 276 |
+
## Safety and intended use
|
| 277 |
|
| 278 |
+
LuluV2 is a local text-generation model. It can produce incorrect or unsafe outputs and should not be treated as a source of truth for medical, legal, financial, security, or other high-stakes decisions. Use human review where accuracy matters.
|
| 279 |
|
| 280 |
+
## License and notices
|
| 281 |
|
| 282 |
+
Before publishing the weights publicly, confirm that you have the right to distribute the final checkpoint and that the repository includes any license text, notices, or attribution that your training sources, base weights, or dependencies require.
|