Run this model with HF Jobs
Run yasserrmd/smoothie-diffusion-qqp 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/yasserrmd/smoothie-diffusion-qqp. 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/yasserrmd/smoothie-diffusion-qqp 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/yasserrmd/smoothie-diffusion-qqp. 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/yasserrmd/smoothie-diffusion-qqp. 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 yasserrmd/smoothie-diffusion-qqp with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yasserrmd/smoothie-diffusion-qqp with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="yasserrmd/smoothie-diffusion-qqp")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("yasserrmd/smoothie-diffusion-qqp", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use yasserrmd/smoothie-diffusion-qqp with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "yasserrmd/smoothie-diffusion-qqp" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yasserrmd/smoothie-diffusion-qqp", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/yasserrmd/smoothie-diffusion-qqp
- SGLang
How to use yasserrmd/smoothie-diffusion-qqp 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 "yasserrmd/smoothie-diffusion-qqp" \ --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": "yasserrmd/smoothie-diffusion-qqp", "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 "yasserrmd/smoothie-diffusion-qqp" \ --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": "yasserrmd/smoothie-diffusion-qqp", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use yasserrmd/smoothie-diffusion-qqp with Docker Model Runner:
docker model run hf.co/yasserrmd/smoothie-diffusion-qqp
Final successful upload
Browse filesFiles changed (4)
- README.mdAdded+8
- config.json+13-11
- model.safetensorsAdded+3
- modeling_smoothie.py+26-48
12345678
---license: mitlanguage: en---# Smoothie: Diffusion Model for ParaphrasingThis repository contains a diffusion model based on the "Smoothie" paper, trained on QQP.It requires `trust_remote_code=True` to load.123456789101112{"model_type": "smoothie","d_model": 768,"num_layers": 12,"num_heads": 12,"max_seq_len": 50,"vocab_size": 28996,"conditional": true,"architectures": ["SmoothieModel"]}1234567891011121314{"architectures": ["SmoothieModel"],"conditional": true,"d_model": 768,"dtype": "float32","max_seq_len": 50,"model_type": "smoothie","num_heads": 12,"num_layers": 12,"transformers_version": "4.56.1","vocab_size": 28996}
123version https://git-lfs.github.com/spec/v1oid sha256:3a2bf2844b729af090ce025c2ad570cddd3ed54f6d0653c91c6339790ff7e2f2size 62334949612345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758import torchimport torch.nn as nnimport math# We need to include all custom classes the model depends on.class TimeEmbed(nn.Module):def __init__(self, dim):super().__init__()self.dim = dimself.mlp = nn.Sequential(nn.Linear(dim, dim * 4), nn.Mish(), nn.Linear(dim * 4, dim))def forward(self, t):half_dim = self.dim // 2emb = math.log(10000) / (half_dim - 1)emb = torch.exp(torch.arange(half_dim, device=t.device) * -emb)emb = t[:, None] * emb[None, :]emb = torch.cat((emb.sin(), emb.cos()), dim=-1)return self.mlp(emb)class SmoothieModel(nn.Module):def __init__(self, config): # It's best practice to accept a config objectsuper().__init__()self.config = configself.time_embed = TimeEmbed(config.d_model)self.input_proj = nn.Linear(config.d_model, config.d_model)self.pos_embed = nn.Embedding(config.max_seq_len, config.d_model)self.decoder_layers = nn.ModuleList([nn.TransformerDecoderLayer(d_model=config.d_model, nhead=config.num_heads, batch_first=True)for _ in range(config.num_layers)])if config.conditional:self.encoder_embedding = nn.Embedding(config.vocab_size, config.d_model)encoder_layer = nn.TransformerEncoderLayer(d_model=config.d_model, nhead=config.num_heads, batch_first=True)self.encoder = nn.TransformerEncoder(encoder_layer, num_layers=6)self.output_proj = nn.Linear(config.d_model, config.d_model)def forward(self, weighted_avg_emb, t, src_tokens=None, src_mask=None):device = weighted_avg_emb.devicex = self.input_proj(weighted_avg_emb)time_emb = self.time_embed(t).unsqueeze(1)pos = torch.arange(0, weighted_avg_emb.size(1), device=device).unsqueeze(0)pos_emb = self.pos_embed(pos)x = x + time_emb + pos_embencoder_output = Noneif self.config.conditional and src_tokens is not None:src_emb = self.encoder_embedding(src_tokens)encoder_output = self.encoder(src_emb, src_key_padding_mask=src_mask)skip_connections = []num_layers = len(self.decoder_layers)for i in range(num_layers // 2):skip_connections.append(x)x = self.decoder_layers[i](tgt=x, memory=encoder_output, memory_key_padding_mask=src_mask)x = self.decoder_layers[num_layers // 2](tgt=x, memory=encoder_output, memory_key_padding_mask=src_mask)for i in range(num_layers // 2 + 1, num_layers):x = x + skip_connections.pop()x = self.decoder_layers[i](tgt=x, memory=encoder_output, memory_key_padding_mask=src_mask)return self.output_proj(x)print("Created modeling_smoothie.py")123456789101112131415161718192021222324252627282930313233343536import torchimport torch.nn as nnimport mathfrom transformers import PreTrainedModel, PretrainedConfig, AutoConfig, AutoModelclass SmoothieConfig(PretrainedConfig):model_type = "smoothie"def __init__(self, d_model=768, num_layers=12, num_heads=12, max_seq_len=50, vocab_size=28996, conditional=True, **kwargs):self.d_model=d_model; self.num_layers=num_layers; self.num_heads=num_heads; self.max_seq_len=max_seq_len; self.vocab_size=vocab_size; self.conditional=conditional; super().__init__(**kwargs)class TimeEmbed(nn.Module):def __init__(self, dim):super().__init__(); self.dim=dim; self.mlp=nn.Sequential(nn.Linear(dim, dim*4), nn.Mish(), nn.Linear(dim*4, dim))def forward(self, t):half_dim = self.dim // 2; emb = math.log(10000) / (half_dim - 1); emb = torch.exp(torch.arange(half_dim, device=t.device) * -emb); emb = t[:, None] * emb[None, :]; emb = torch.cat((emb.sin(), emb.cos()), dim=-1); return self.mlp(emb)class SmoothieModel(PreTrainedModel):config_class = SmoothieConfigdef __init__(self, config: SmoothieConfig):super().__init__(config); self.config=config; self.time_embed=TimeEmbed(config.d_model); self.input_proj=nn.Linear(config.d_model, config.d_model); self.pos_embed=nn.Embedding(config.max_seq_len, config.d_model)self.decoder_layers=nn.ModuleList([nn.TransformerDecoderLayer(d_model=config.d_model, nhead=config.num_heads, batch_first=True) for _ in range(config.num_layers)])if config.conditional: self.encoder_embedding=nn.Embedding(config.vocab_size, config.d_model); encoder_layer=nn.TransformerEncoderLayer(d_model=config.d_model, nhead=config.num_heads, batch_first=True); self.encoder=nn.TransformerEncoder(encoder_layer, num_layers=6)self.output_proj=nn.Linear(config.d_model, config.d_model)def forward(self, weighted_avg_emb, t, src_tokens=None, src_mask=None, **kwargs):device=weighted_avg_emb.device; x=self.input_proj(weighted_avg_emb); time_emb=self.time_embed(t).unsqueeze(1); pos=torch.arange(0, weighted_avg_emb.size(1), device=device).unsqueeze(0); pos_emb=self.pos_embed(pos); x=x+time_emb+pos_embencoder_output=Noneif self.config.conditional and src_tokens is not None: src_emb=self.encoder_embedding(src_tokens); encoder_output=self.encoder(src_emb, src_key_padding_mask=src_mask)skip_connections=[]; num_layers=len(self.decoder_layers)for i in range(num_layers // 2): skip_connections.append(x); x=self.decoder_layers[i](tgt=x, memory=encoder_output, memory_key_padding_mask=src_mask)x=self.decoder_layers[num_layers // 2](tgt=x, memory=encoder_output, memory_key_padding_mask=src_mask)for i in range(num_layers // 2 + 1, num_layers): x=x+skip_connections.pop(); x=self.decoder_layers[i](tgt=x, memory=encoder_output, memory_key_padding_mask=src_mask)return self.output_proj(x)AutoConfig.register("smoothie", SmoothieConfig)AutoModel.register(SmoothieConfig, SmoothieModel)
README.mdAdded+8
config.json+13-11
model.safetensorsAdded+3
modeling_smoothie.py+26-48