Text Generation
Transformers
Safetensors
Russian
English
qwen2
MANTA
autocomplete
word-completion
text-generation-inference
Instructions to use average23/MANTA-20M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use average23/MANTA-20M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="average23/MANTA-20M")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("average23/MANTA-20M") model = AutoModelForCausalLM.from_pretrained("average23/MANTA-20M", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use average23/MANTA-20M with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "average23/MANTA-20M" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "average23/MANTA-20M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/average23/MANTA-20M
- SGLang
How to use average23/MANTA-20M 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 "average23/MANTA-20M" \ --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": "average23/MANTA-20M", "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 "average23/MANTA-20M" \ --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": "average23/MANTA-20M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use average23/MANTA-20M with Docker Model Runner:
docker model run hf.co/average23/MANTA-20M
Download manta/__init__.py from average23/MANTA-20M: direct link, hf CLI and curl.
- Browser
- Download file 1.71 kB
-
https://huggingface.co/average23/MANTA-20M/resolve/main/manta/__init__.py
- Command line
-
hf download hf://average23/MANTA-20M/manta/__init__.py
-
curl -L -o __init__.py https://huggingface.co/average23/MANTA-20M/resolve/main/manta/__init__.py
1.71 kB
| """MANTA 20M whole-word inference.""" | |
| from pathlib import Path | |
| import torch | |
| from huggingface_hub import snapshot_download | |
| from tokenizers import Tokenizer | |
| from transformers import AutoModelForCausalLM | |
| from .decoder import GenerativeKeyboard | |
| __version__ = '0.1.0' | |
| __all__ = ['MantaKeyboard'] | |
| class MantaKeyboard(GenerativeKeyboard): | |
| """Whole-word next-word prediction and prefix-constrained completion.""" | |
| def from_pretrained(cls, model_id, *, revision='v0.1.0', device='cpu', | |
| local_files_only=False, beam_size=10, max_steps=64, | |
| max_chars=48, context_tokens=128, max_seconds=float('inf')): | |
| """Load a local directory or a Hub release using standard Transformers. | |
| Search is deterministic in FP32 with fixed token and beam budgets. | |
| A finite max_seconds adds a wall-clock deadline to the search. | |
| """ | |
| folder = Path(model_id) | |
| if not folder.is_dir(): | |
| folder = Path(snapshot_download( | |
| str(model_id), revision=revision, local_files_only=local_files_only, | |
| allow_patterns=['config.json', 'model.safetensors', 'tokenizer.json', | |
| 'tokenizer_config.json', 'generation_config.json'])) | |
| model = AutoModelForCausalLM.from_pretrained( | |
| folder, local_files_only=True, trust_remote_code=False, | |
| attn_implementation='eager', torch_dtype=torch.float32).to(device) | |
| return cls(model, Tokenizer.from_file(str(folder / 'tokenizer.json')), | |
| beam_size=beam_size, max_steps=max_steps, max_chars=max_chars, | |
| context_tokens=context_tokens, max_seconds=max_seconds) | |