Text Generation
Transformers
Safetensors
English
quartz_moe
Mixture of Experts
mixture-of-experts
from-scratch
instruction-tuned
custom_code
Instructions to use VertexAGI/quartz-micro-preview with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use VertexAGI/quartz-micro-preview with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="VertexAGI/quartz-micro-preview", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("VertexAGI/quartz-micro-preview", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use VertexAGI/quartz-micro-preview with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "VertexAGI/quartz-micro-preview" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "VertexAGI/quartz-micro-preview", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/VertexAGI/quartz-micro-preview
- SGLang
How to use VertexAGI/quartz-micro-preview 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 "VertexAGI/quartz-micro-preview" \ --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": "VertexAGI/quartz-micro-preview", "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 "VertexAGI/quartz-micro-preview" \ --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": "VertexAGI/quartz-micro-preview", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use VertexAGI/quartz-micro-preview with Docker Model Runner:
docker model run hf.co/VertexAGI/quartz-micro-preview
Download load_model.py from VertexAGI/quartz-micro-preview: direct link, hf CLI and curl.
- Browser
- Download file 1.91 kB
-
https://huggingface.co/VertexAGI/quartz-micro-preview/resolve/main/load_model.py
- Command line
-
hf download hf://VertexAGI/quartz-micro-preview/load_model.py
-
curl -L -o load_model.py https://huggingface.co/VertexAGI/quartz-micro-preview/resolve/main/load_model.py
1.91 kB
| """ | |
| Minimal example: load Quartz Micro Preview Base's weights and generate text. | |
| This is a custom PyTorch architecture (DeepSeek-style fine-grained MoE, see | |
| model.py / config.py in this repo) -- not a registered transformers | |
| architecture, so there's no AutoModel support. Load it directly: | |
| pip install torch safetensors tokenizers | |
| python load_model.py | |
| The tokenizer is a from-scratch 32K-vocab byte-level BPE (tokenizer/ | |
| vocab.json + merges.txt) trained on this model's own pretraining corpus -- | |
| it is NOT compatible with any other model's tokenizer, and no other | |
| tokenizer is compatible with these weights. | |
| """ | |
| import os | |
| import torch | |
| from safetensors.torch import load_file | |
| from tokenizers import ByteLevelBPETokenizer | |
| from config import MoEConfig | |
| from model import MoELanguageModel | |
| HERE = os.path.dirname(__file__) | |
| def load(): | |
| tok = ByteLevelBPETokenizer( | |
| os.path.join(HERE, "tokenizer", "vocab.json"), | |
| os.path.join(HERE, "tokenizer", "merges.txt"), | |
| ) | |
| cfg = MoEConfig() | |
| model = MoELanguageModel(cfg) | |
| state_dict = load_file(os.path.join(HERE, "model.safetensors")) | |
| model.load_state_dict(state_dict) | |
| model.eval() | |
| return model, tok | |
| def generate(model, tok, prompt: str, max_new_tokens: int = 80, temperature: float = 0.8): | |
| BOS_ID, EOS_ID = 1, 2 | |
| ids = [BOS_ID] + tok.encode(prompt).ids | |
| x = torch.tensor([ids], dtype=torch.long) | |
| for _ in range(max_new_tokens): | |
| logits, _ = model(x) | |
| next_logits = logits[0, -1] / temperature | |
| probs = torch.softmax(next_logits, dim=-1) | |
| next_id = torch.multinomial(probs, 1).item() | |
| if next_id == EOS_ID: | |
| break | |
| x = torch.cat([x, torch.tensor([[next_id]])], dim=1) | |
| return tok.decode(x[0, 1:].tolist()) | |
| if __name__ == "__main__": | |
| model, tok = load() | |
| print(generate(model, tok, "The history of the Roman Empire")) | |