Text Generation
Transformers
Safetensors
Mongolian
rdt
traditional-mongolian
recurrent-depth-transformer
mamba
causal-lm
custom-code
custom_code
Instructions to use Montlok/DoL-1.2-Base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Montlok/DoL-1.2-Base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Montlok/DoL-1.2-Base", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Montlok/DoL-1.2-Base", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Montlok/DoL-1.2-Base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Montlok/DoL-1.2-Base" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Montlok/DoL-1.2-Base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Montlok/DoL-1.2-Base
- SGLang
How to use Montlok/DoL-1.2-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 "Montlok/DoL-1.2-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": "Montlok/DoL-1.2-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 "Montlok/DoL-1.2-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": "Montlok/DoL-1.2-Base", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Montlok/DoL-1.2-Base with Docker Model Runner:
docker model run hf.co/Montlok/DoL-1.2-Base
File size: 2,017 Bytes
431ffa3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | # -*- coding: utf-8 -*-
"""MorphBPE JSON v1 serialization."""
from __future__ import annotations
import json
from typing import Any
SCHEMA_VERSION = 1
def dump(tokenizer: Any, path: str, extra_config: dict[str, Any] | None = None) -> None:
"""Write a MorphBPETokenizer to disk using v1 schema."""
merges_sorted = sorted(tokenizer.merges.items(), key=lambda item: item[1][1])
merges_arr = [
{"pair": [left, right], "merged": merged, "rank": rank}
for (left, right), (merged, rank) in merges_sorted
]
payload = {
"version": SCHEMA_VERSION,
"type": "morphbpe",
"vocab": tokenizer.vocab,
"merges": merges_arr,
"special_tokens": {"unk": "<unk>"},
"config": {
"boundary_constrained": True,
"min_boundary_confidence": getattr(
tokenizer, "min_boundary_confidence", 0.60
),
"seed_alphabet": getattr(tokenizer, "seed_alphabet", False),
**(extra_config or {}),
},
}
with open(path, "w", encoding="utf-8") as f:
json.dump(payload, f, ensure_ascii=False, indent=2)
def load(path: str) -> dict[str, Any]:
with open(path, "r", encoding="utf-8") as f:
payload = json.load(f)
version = payload.get("version")
if version is not None and int(version) != SCHEMA_VERSION:
raise ValueError(
f"unsupported morphbpe schema version: {version}; expected {SCHEMA_VERSION}"
)
return payload
def merges_from_payload(
payload: dict[str, Any],
) -> dict[tuple[str, str], tuple[str, int]]:
merges: dict[tuple[str, str], tuple[str, int]] = {}
for i, item in enumerate(payload.get("merges", [])):
if isinstance(item, dict):
left, right = item["pair"]
merged = item.get("merged", left + right)
rank = int(item.get("rank", i))
else:
left, right, merged, rank = item
merges[(left, right)] = (merged, rank)
return merges
|