Text Generation
Transformers
Safetensors
English
cloverlm
causal-lm
quartet-ii
nvfp4
low-precision-training
pretrained
custom_code
Run this model with HF Jobs
Run daslab-testing/CloverLM 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/daslab-testing/CloverLM. 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/daslab-testing/CloverLM 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/daslab-testing/CloverLM. 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/daslab-testing/CloverLM. 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 daslab-testing/CloverLM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use daslab-testing/CloverLM with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="daslab-testing/CloverLM", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("daslab-testing/CloverLM", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use daslab-testing/CloverLM with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "daslab-testing/CloverLM" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "daslab-testing/CloverLM", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/daslab-testing/CloverLM
- SGLang
How to use daslab-testing/CloverLM 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 "daslab-testing/CloverLM" \ --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": "daslab-testing/CloverLM", "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 "daslab-testing/CloverLM" \ --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": "daslab-testing/CloverLM", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use daslab-testing/CloverLM with Docker Model Runner:
docker model run hf.co/daslab-testing/CloverLM
Upload folder using huggingface_hub
Browse filesFiles changed (4)
- config.json+1
- hf_quant_config.jsonAdded+15
- model.safetensors+2-2
- modeling_cloverlm.py+83
11 unmodified lines12131415161711 unmodified lines]},"d_head": 128,"head_dim": 128,"heads": 28,"hidden_size": 3584,11 unmodified lines1213141516171811 unmodified lines]},"d_head": 128,"dtype": "bfloat16","head_dim": 128,"heads": 28,"hidden_size": 3584,
123456789101112131415{ "producer": { "name": "cloverlm_converter", "version": "1.0" }, "quantization": { "quant_algo": "NVFP4", "kv_cache_quant_algo": null, "group_size": 16, "exclude_modules": [ "emb", "linear" ] }}123version https://git-lfs.github.com/spec/v1oid sha256:5802c11b6b024033386dba4cdff8665d48de19850e0e63c31686f44430ca870fsize 16563661264123version https://git-lfs.github.com/spec/v1oid sha256:e0bbc8b129f5affb348c8526847bcba635c16d9e65700d775a0a941bd2e73533size 2659361496
10 unmodified lines111213141516213 unmodified lines23023123223323423510 unmodified linesfrom .fake_quartet import FakeQuartetLineardef _sphere_norm(X, dim=-1):return F.normalize(X, dim=dim)213 unmodified lines)self.post_init()def forward(self, input_ids, attention_mask=None, labels=None, **kwargs):logits = self.transformer(input_ids)10 unmodified lines11121314151617181920212223242526272829303132333435363738394041213 unmodified lines25525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731810 unmodified linesfrom .fake_quartet import FakeQuartetLinear# ββ NVFP4 dequantization for checkpoint loading βββββββββββββββββββββββββββββdef _dequant_nvfp4_state_dict(raw_sd, dtype=torch.bfloat16):"""Dequantize NVFP4-packed tensors using quartet2's _dq_fp4 on GPU.The micro-scales are stored in cuBLAS blocked layout; quartet2's _dq_fp4handles the unblocking correctly."""from quartet2.linear import _dq_fp4scale2_bases = {k.removesuffix("_scale_2") for k in raw_sd if k.endswith("_scale_2")}result = {}for key, tensor in raw_sd.items():if key.endswith(("_scale", "_scale_2")):continueif key in scale2_bases:fp4 = tensor.cuda()scales = raw_sd[f"{key}_scale"].cuda()ts = raw_sd[f"{key}_scale_2"].float().item()result[key] = _dq_fp4(fp4, scales, ts).to(dtype).cpu()else:result[key] = tensor.to(dtype) if tensor.is_floating_point() else tensorreturn resultdef _sphere_norm(X, dim=-1):return F.normalize(X, dim=dim)213 unmodified lines)self.post_init()@classmethoddef from_pretrained(cls, pretrained_model_name_or_path, *args, **kwargs):import osfrom safetensors import safe_openst_path = os.path.join(str(pretrained_model_name_or_path), "model.safetensors")if not os.path.exists(st_path):return super().from_pretrained(pretrained_model_name_or_path, *args, **kwargs)with safe_open(st_path, framework="pt") as f:if not any(k.endswith("_scale_2") for k in f.keys()):return super().from_pretrained(pretrained_model_name_or_path, *args, **kwargs,)from safetensors.torch import load_fileconfig = kwargs.pop("config", None)if config is None:config = cls.config_class.from_pretrained(pretrained_model_name_or_path, trust_remote_code=True,)# Apply config overrides from kwargs (e.g. attn_backend, quartet_2_impl)for key in list(kwargs.keys()):if hasattr(config, key):setattr(config, key, kwargs.pop(key))kwargs.pop("trust_remote_code", None)target_dtype = kwargs.pop("torch_dtype", None)if target_dtype is None:target_dtype = torch.bfloat16if isinstance(target_dtype, str):target_dtype = getattr(torch, target_dtype)device_map = kwargs.pop("device_map", None)raw = load_file(st_path)state_dict = _dequant_nvfp4_state_dict(raw, target_dtype)model = cls(config)model.load_state_dict(state_dict, strict=False)model = model.to(target_dtype)if device_map is not None:if isinstance(device_map, str) and device_map != "auto":model = model.to(device_map)elif isinstance(device_map, dict):device = next(iter(device_map.values()))model = model.to(device)elif device_map == "auto":from accelerate import dispatch_model, infer_auto_device_mapdevice_map_computed = infer_auto_device_map(model)model = dispatch_model(model, device_map=device_map_computed)model.eval()return modeldef forward(self, input_ids, attention_mask=None, labels=None, **kwargs):logits = self.transformer(input_ids)
config.json+1
hf_quant_config.jsonAdded+15
model.safetensors+2-2
modeling_cloverlm.py+83