Text Generation
Transformers
Safetensors
gpt2
latent-reasoning
codi
slpo
reinforcement-learning
text-generation-inference
Run this model with HF Jobs
Run ModalityDance/slpo-codi-gpt2 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/ModalityDance/slpo-codi-gpt2. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/ModalityDance/slpo-codi-gpt2 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/ModalityDance/slpo-codi-gpt2. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/ModalityDance/slpo-codi-gpt2. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use ModalityDance/slpo-codi-gpt2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ModalityDance/slpo-codi-gpt2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ModalityDance/slpo-codi-gpt2")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, LatentCODIGPT2 tokenizer = AutoTokenizer.from_pretrained("ModalityDance/slpo-codi-gpt2") model = LatentCODIGPT2.from_pretrained("ModalityDance/slpo-codi-gpt2", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ModalityDance/slpo-codi-gpt2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ModalityDance/slpo-codi-gpt2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ModalityDance/slpo-codi-gpt2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ModalityDance/slpo-codi-gpt2
- SGLang
How to use ModalityDance/slpo-codi-gpt2 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 "ModalityDance/slpo-codi-gpt2" \ --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": "ModalityDance/slpo-codi-gpt2", "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 "ModalityDance/slpo-codi-gpt2" \ --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": "ModalityDance/slpo-codi-gpt2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use ModalityDance/slpo-codi-gpt2 with Docker Model Runner:
docker model run hf.co/ModalityDance/slpo-codi-gpt2
Add runnable load-and-generate usage snippet
Browse files36 unmodified lines3738394041424344454647484950515253545556575859606162636436 unmodified lines## Related- Code: [ModalityDance/SLPO](https://github.com/ModalityDance/SLPO)- Base model: [ModalityDance/latent-tts-codi](https://huggingface.co/ModalityDance/latent-tts-codi)- Sibling: [ModalityDance/slpo-coconut-gpt2](https://huggingface.co/ModalityDance/slpo-coconut-gpt2)- Latent TTS collection: [Latent TTS](https://huggingface.co/collections/ModalityDance/latent-tts-69635ae5a732662b4d41225f)## Installation```bashhuggingface-cli download ModalityDance/slpo-codi-gpt2 --local-dir checkpoints/slpo-codi-gpt2```## Quick StartInference uses the custom latent generation stack from the [SLPO](https://github.com/ModalityDance/SLPO) repository:```bashCKPT=checkpoints/slpo-codi-gpt2 \MODEL_TYPE=codi STOP_POLICY=gate \MAX_LATENT_LENGTH=12 \bash scripts/eval.sh```Set `stop_gate_threshold=0.7` to match the paper evaluation.## Citation36 unmodified lines37383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311436 unmodified lines## Related- Code: [ModalityDance/SLPO](https://github.com/ModalityDance/SLPO)- Project page: [modalitydance.github.io/SLPO](https://modalitydance.github.io/SLPO/)- Base model: [ModalityDance/latent-tts-codi](https://huggingface.co/ModalityDance/latent-tts-codi)- Sibling: [ModalityDance/slpo-coconut-gpt2](https://huggingface.co/ModalityDance/slpo-coconut-gpt2)- Collection: [ModalityDance/SLPO](https://huggingface.co/collections/ModalityDance/slpo)## Installation```bashgit clone https://github.com/ModalityDance/SLPO.gitcd SLPOpip install -r requirements.txt # plus a CUDA PyTorch buildhf download ModalityDance/slpo-codi-gpt2 --local-dir checkpoints/slpo-codi-gpt2```## Quick StartBatched eval (paper Acc settings):```bashCKPT=checkpoints/slpo-codi-gpt2 \MODEL_TYPE=codi STOP_POLICY=gate \STOP_GATE_THRESHOLD=0.7 MAX_LATENT_LENGTH=12 \DATA=data/gsm_test.json \bash scripts/eval.sh```Minimal Python (from the repo root; needs the SLPO latent generation stack):```pythonimport torchfrom transformers import AutoTokenizerfrom src.models.generation import LatentGenerationMixin, LatentGenerationConfigfrom src.paths import get_model_classmodel_id = "ModalityDance/slpo-codi-gpt2"backbone_cls = get_model_class("codi")class LatentModel(backbone_cls, LatentGenerationMixin):passtokenizer = AutoTokenizer.from_pretrained(model_id)if tokenizer.pad_token is None:tokenizer.pad_token = tokenizer.eos_tokenmodel = LatentModel.from_pretrained(model_id)model.eval()question = ("Janet's ducks lay 16 eggs per day. She eats three for breakfast every morning ""and bakes muffins for her friends every day with four. She sells the remainder ""at the farmers' market daily for $2 per fresh duck egg. ""How much in dollars does she make every day at the farmers' market?")prompt = question + "<|start-latent|>"inputs = tokenizer(prompt, return_tensors="pt")gen_cfg = LatentGenerationConfig(stop_policy="gate",max_latent_length=12,stop_gate_threshold=0.7,max_new_tokens=128,pad_token_id=tokenizer.pad_token_id,eos_token_id=tokenizer.eos_token_id,bos_token_id=tokenizer.bos_token_id,)with torch.no_grad():output = model.generate(**inputs, generation_config=gen_cfg)sequences = output.sequences if hasattr(output, "sequences") else outputprint(tokenizer.decode(sequences[0], skip_special_tokens=True))```## Citation
README.md+55-5