Image-Text-to-Text
Transformers
Safetensors
English
Chinese
sensenova_loop
text-generation
nvfp4
modelopt
quantized
multimodal
looped-transformer
mhc
mtp
custom_code
conversational
8-bit precision
Instructions to use gitcommit90/SenseNova-Loop-9B-Preview-NVFP4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use gitcommit90/SenseNova-Loop-9B-Preview-NVFP4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="gitcommit90/SenseNova-Loop-9B-Preview-NVFP4", trust_remote_code=True) messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("gitcommit90/SenseNova-Loop-9B-Preview-NVFP4", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use gitcommit90/SenseNova-Loop-9B-Preview-NVFP4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "gitcommit90/SenseNova-Loop-9B-Preview-NVFP4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "gitcommit90/SenseNova-Loop-9B-Preview-NVFP4", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/gitcommit90/SenseNova-Loop-9B-Preview-NVFP4
- SGLang
How to use gitcommit90/SenseNova-Loop-9B-Preview-NVFP4 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 "gitcommit90/SenseNova-Loop-9B-Preview-NVFP4" \ --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": "gitcommit90/SenseNova-Loop-9B-Preview-NVFP4", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "gitcommit90/SenseNova-Loop-9B-Preview-NVFP4" \ --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": "gitcommit90/SenseNova-Loop-9B-Preview-NVFP4", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use gitcommit90/SenseNova-Loop-9B-Preview-NVFP4 with Docker Model Runner:
docker model run hf.co/gitcommit90/SenseNova-Loop-9B-Preview-NVFP4
Download runtime-v2/tokenmap/build_token_map.py from gitcommit90/SenseNova-Loop-9B-Preview-NVFP4: direct link, hf CLI and curl.
- Browser
- Download file 2.79 kB
-
https://huggingface.co/gitcommit90/SenseNova-Loop-9B-Preview-NVFP4/resolve/8edc128b0e751107315c77a58ed73caad5c41d45/runtime-v2/tokenmap/build_token_map.py
- Command line
-
hf download hf://gitcommit90/SenseNova-Loop-9B-Preview-NVFP4@8edc128b0e751107315c77a58ed73caad5c41d45/runtime-v2/tokenmap/build_token_map.py
-
curl -L -o build_token_map.py https://huggingface.co/gitcommit90/SenseNova-Loop-9B-Preview-NVFP4/resolve/8edc128b0e751107315c77a58ed73caad5c41d45/runtime-v2/tokenmap/build_token_map.py
2.79 kB
| """Build FR-Spec style hot-vocab maps for the MTP draft lm_head from TRAIN-split corpora only (calib/raw): | |
| oasst2 (multilingual chat, all messages), glaive-function-calling-v2 (tool calls), mbpp (code), gsm8k train (math). | |
| The target model always verifies against the FULL vocabulary; this only restricts which tokens the draft can propose. | |
| Output: hot_<K>.pt = sorted int64 tensor of token ids (special/added tokens always included) + stats json.""" | |
| import json, collections, sys, re, argparse | |
| from pathlib import Path | |
| import pyarrow.parquet as pq, torch | |
| from tokenizers import Tokenizer | |
| ap = argparse.ArgumentParser(description=__doc__) | |
| ap.add_argument("--raw-dir", required=True, help="Pinned corpus tree used by quantization/build_calib.py") | |
| ap.add_argument("--tokenizer", required=True) | |
| ap.add_argument("--out", required=True) | |
| a = ap.parse_args() | |
| R = str(Path(a.raw_dir).resolve()) + "/"; OUT = a.out | |
| Path(OUT).mkdir(parents=True, exist_ok=True) | |
| tok = Tokenizer.from_file(a.tokenizer) | |
| texts = {} | |
| texts["oasst2"] = [t for t in pq.read_table(R + "OpenAssistant__oasst2/data/train-00000-of-00001-88ba0162028a73fc.parquet", columns=["text"]).column("text").to_pylist() if t] | |
| mb = pq.read_table(R + "google-research-datasets__mbpp/full/train-00000-of-00001.parquet").to_pylist() | |
| texts["mbpp"] = [r["text"] + "\n" + r["code"] for r in mb] | |
| gs = pq.read_table(R + "openai__gsm8k/main/train-00000-of-00001.parquet").to_pylist() | |
| texts["gsm8k"] = [r["question"] + "\n" + r["answer"] for r in gs] | |
| gl = json.load(open(R + "glaiveai__glaive-function-calling-v2/glaive-function-calling-v2.json")) | |
| texts["glaive"] = [r["system"] + "\n" + r["chat"] for r in gl[:40000]] | |
| cnt = collections.Counter(); per = {} | |
| for k, ts in texts.items(): | |
| c = collections.Counter() | |
| for i in range(0, len(ts), 2000): | |
| for e in tok.encode_batch(ts[i:i + 2000], add_special_tokens=False): c.update(e.ids) | |
| per[k] = sum(c.values()) | |
| # weight sources so the big tool corpus does not swamp chat/code/math: normalize each to equal mass | |
| tot = sum(c.values()) | |
| for t, n in c.items(): cnt[t] += n / tot | |
| special = sorted(tok.get_added_tokens_decoder().keys()) | |
| ranked = [t for t, _ in cnt.most_common()] | |
| stats = {"tokens_per_source": per, "distinct_tokens_seen": len(ranked), "n_special": len(special), "vocab": tok.get_vocab_size()} | |
| for K in (32768, 65536): | |
| ids = set(special) | |
| for t in ranked: | |
| if len(ids) >= K: break | |
| ids.add(t) | |
| ids = torch.tensor(sorted(ids), dtype=torch.int64) | |
| torch.save(ids, f"{OUT}/hot_{K // 1024}k.pt") | |
| cov = sum(cnt[t] for t in ids.tolist()) / sum(cnt.values()) | |
| stats[f"hot_{K // 1024}k"] = {"n": len(ids), "weighted_coverage_of_corpus": round(cov, 5)} | |
| json.dump(stats, open(f"{OUT}/token_map_stats.json", "w"), indent=1); print(stats) | |