Text Generation
Transformers
Safetensors
modilify_mk2
feature-extraction
diffusion
mixture-of-experts
custom-code
modilify-mk2
conversational
custom_code
Instructions to use modilify/Modilify-Mk2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use modilify/Modilify-Mk2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="modilify/Modilify-Mk2", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("modilify/Modilify-Mk2", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use modilify/Modilify-Mk2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "modilify/Modilify-Mk2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "modilify/Modilify-Mk2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/modilify/Modilify-Mk2
- SGLang
How to use modilify/Modilify-Mk2 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 "modilify/Modilify-Mk2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "modilify/Modilify-Mk2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "modilify/Modilify-Mk2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "modilify/Modilify-Mk2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use modilify/Modilify-Mk2 with Docker Model Runner:
docker model run hf.co/modilify/Modilify-Mk2
Download inference.py from modilify/Modilify-Mk2: direct link, hf CLI and curl.
- Browser
- Download file 2.11 kB
-
https://huggingface.co/modilify/Modilify-Mk2/resolve/main/inference.py
- Command line
-
hf download hf://modilify/Modilify-Mk2/inference.py
-
curl -L -o inference.py https://huggingface.co/modilify/Modilify-Mk2/resolve/main/inference.py
2.11 kB
| """Run the published Transformers model locally or from Hugging Face.""" | |
| from __future__ import annotations | |
| import argparse | |
| from pathlib import Path | |
| import torch | |
| from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer | |
| def main() -> None: | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("--model", default=str(Path(__file__).resolve().parent)) | |
| parser.add_argument("--prompt", default="你好,请介绍一下自己。") | |
| parser.add_argument("--device", choices=("auto", "cpu", "cuda", "mps"), default="auto") | |
| parser.add_argument("--max-new-tokens", type=int, default=256) | |
| parser.add_argument("--max-denoising-steps", type=int, default=256) | |
| parser.add_argument("--seed", type=int, default=42) | |
| parser.add_argument("--no-thinking", action="store_true") | |
| parser.add_argument("--stream", action="store_true") | |
| args = parser.parse_args() | |
| device = args.device | |
| if device == "auto": | |
| device = "cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu" | |
| tokenizer = AutoTokenizer.from_pretrained(args.model, trust_remote_code=True) | |
| model = AutoModelForCausalLM.from_pretrained( | |
| args.model, trust_remote_code=True, dtype="auto", device_map=device, | |
| attn_implementation="sdpa", | |
| ).eval() | |
| inputs = tokenizer.apply_chat_template( | |
| [{"role": "user", "content": args.prompt}], | |
| enable_thinking=not args.no_thinking, add_generation_prompt=True, | |
| return_tensors="pt", return_dict=True, | |
| ).to(model.device) | |
| streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True) if args.stream else None | |
| with torch.inference_mode(): | |
| output = model.generate(**inputs, max_new_tokens=args.max_new_tokens, | |
| max_denoising_steps=args.max_denoising_steps, | |
| seed=args.seed, streamer=streamer) | |
| if streamer is None: | |
| print(tokenizer.decode(output.sequences[0, inputs.input_ids.shape[1]:], skip_special_tokens=True)) | |
| if __name__ == "__main__": | |
| main() | |