Instructions to use hanzceo/Jasper-Token-Compression-600M-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Adapters
How to use hanzceo/Jasper-Token-Compression-600M-GGUF with Adapters:
from adapters import AutoAdapterModel model = AutoAdapterModel.from_pretrained("undefined") model.load_adapter("hanzceo/Jasper-Token-Compression-600M-GGUF", set_active=True) - sentence-transformers
How to use hanzceo/Jasper-Token-Compression-600M-GGUF with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("hanzceo/Jasper-Token-Compression-600M-GGUF") sentences = [ "That is a happy person", "That is a happy dog", "That is a very happy person", "Today is a sunny day" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - llama-cpp-python
How to use hanzceo/Jasper-Token-Compression-600M-GGUF with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="hanzceo/Jasper-Token-Compression-600M-GGUF", filename="Jasper-Token-Compression-600M_F16.gguf", )
llm.create_chat_completion( messages = "{\n \"source_sentence\": \"That is a happy person\",\n \"sentences\": [\n \"That is a happy dog\",\n \"That is a very happy person\",\n \"Today is a sunny day\"\n ]\n}" ) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use hanzceo/Jasper-Token-Compression-600M-GGUF with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf hanzceo/Jasper-Token-Compression-600M-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf hanzceo/Jasper-Token-Compression-600M-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf hanzceo/Jasper-Token-Compression-600M-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf hanzceo/Jasper-Token-Compression-600M-GGUF:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf hanzceo/Jasper-Token-Compression-600M-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf hanzceo/Jasper-Token-Compression-600M-GGUF:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf hanzceo/Jasper-Token-Compression-600M-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf hanzceo/Jasper-Token-Compression-600M-GGUF:Q4_K_M
Use Docker
docker model run hf.co/hanzceo/Jasper-Token-Compression-600M-GGUF:Q4_K_M
- LM Studio
- Jan
- Ollama
How to use hanzceo/Jasper-Token-Compression-600M-GGUF with Ollama:
ollama run hf.co/hanzceo/Jasper-Token-Compression-600M-GGUF:Q4_K_M
- Unsloth Studio
How to use hanzceo/Jasper-Token-Compression-600M-GGUF with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for hanzceo/Jasper-Token-Compression-600M-GGUF to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for hanzceo/Jasper-Token-Compression-600M-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for hanzceo/Jasper-Token-Compression-600M-GGUF to start chatting
- Pi
How to use hanzceo/Jasper-Token-Compression-600M-GGUF with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf hanzceo/Jasper-Token-Compression-600M-GGUF:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "hanzceo/Jasper-Token-Compression-600M-GGUF:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use hanzceo/Jasper-Token-Compression-600M-GGUF with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf hanzceo/Jasper-Token-Compression-600M-GGUF:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default hanzceo/Jasper-Token-Compression-600M-GGUF:Q4_K_M
Run Hermes
hermes
- Atomic Chat new
- Docker Model Runner
How to use hanzceo/Jasper-Token-Compression-600M-GGUF with Docker Model Runner:
docker model run hf.co/hanzceo/Jasper-Token-Compression-600M-GGUF:Q4_K_M
- Lemonade
How to use hanzceo/Jasper-Token-Compression-600M-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull hanzceo/Jasper-Token-Compression-600M-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.Jasper-Token-Compression-600M-GGUF-Q4_K_M
List all available models
lemonade list
Jasper-Token-Compression-600M GGUF
To run this model, please use my fork at https://github.com/HanzCEO/llama.cpp/tree/impl/Jasper-Token-Compression-600M.
Benchmark MTEB English
| Quantization | Accuracy | Precision | Recall | F1 Score | Spearman | Mean Sim |
|---|---|---|---|---|---|---|
| Q8_0 | 0.8448 | 0.8763 | 0.9556 | 0.9143 | 0.3062 | 0.6997 |
| Q4_K_M | 0.8477 | 0.8739 | 0.9631 | 0.9163 | 0.3080 | 0.7095 |
| Q1_0 | 0.8484 | 0.8645 | 0.9782 | 0.9179 | 0.1435 | 0.8002 |
Running the Model
$ ./llama-embedding -m Jasper-Token-Compression-600M_Q4_K_M.gguf -p "An apple a day keeps the doctors away"
embedding 0: -0.018346 -0.009776 -0.053883 ... -0.006476 0.008699 0.009683
embedding 1: -0.027236 -0.004766 -0.063195 ... -0.002329 0.007740 0.009831
embedding 2: -0.039688 0.005092 -0.046118 ... -0.010706 0.001788 0.003643
embedding 3: -0.031832 0.002946 -0.062942 ... -0.008288 0.002735 0.000762
embedding 4: -0.048793 -0.006710 -0.065345 ... -0.010053 0.000352 0.007763
embedding 5: -0.039835 0.009338 -0.063589 ... -0.010378 -0.001117 -0.000184
embedding 6: -0.041486 0.012871 -0.071283 ... -0.006661 0.003343 -0.004718
embedding 7: -0.012782 -0.002994 -0.052196 ... -0.011036 0.005822 0.009337
embedding 8: -0.009351 -0.000308 -0.041070 ... -0.005398 0.001508 0.010260
Original model card below.
Jasper-Token-Compression-600M
Introduction
Inspired by Deepseek-OCR, this is the first vector model in the Jasper and Stella series to use dynamic text token compression. Through the combination of vector distillation and contrastive learning, our model can compress text by 10x while still achieving excellent performance!
Original training codes: https://github.com/DunZhang/Jasper-Token-Compression-Training
Report: https://arxiv.org/abs/2511.14405
Wechat: zhdunt
Features
- ⭐⭐⭐ Supports bilingual (Chinese and English)
- ⭐⭐⭐⭐⭐⭐ Dynamic token compression - tested to achieve excellent results even when compressing text to 0.33x of original length
- ⭐⭐⭐ Combines vector distillation with contrastive learning to further improve performance on retrieval tasks
- ⭐⭐ 12 million unsupervised data distillation
- ⭐⭐ 0.6B parameter size
Technical Details
Dynamic Text Token Compression
My implementation is very simple: After text passes through the word_embedding layer, it immediately goes through a
Qwen3MLP (approximately 3 fully connected layers), then I calculate the compressed length, and finally use
adaptive_avg_pool1d to compress tokens to that length.
The compression length calculation logic is as follows:
real_length = 1000 # Actual token count of the text
length_threshold = 80 # Compress only if exceeding this threshold
compression_ratio = 0.333
if real_length <= length_threshold:
# No compression
pass
else:
target_length = int(length_threshold + (real_length - length_threshold) * compression_ratio)
For implementation details, please refer to the modeling_qwen3_jasper.py file in this directory.
Vector Distillation + Contrastive Learning
First, we compute teacher vectors for texts in the contrastive learning training set, then use the following three losses during training:
- Cosine loss: Standard vector distillation loss
- InfoNCE (hard loss): Standard contrastive learning loss function
- KL divergence (soft loss): KL divergence between student score matrix and teacher score matrix. The score matrix is the scores between query and all documents(i.e. positive doc, hard negative docs, other in-batch docs).
Evaluation
My prompt strategy and specific content are consistent with the QZhou model. Please refer to their evaluation script: https://github.com/Kingsoft-LLM/QZhou-Embedding
Usage
import torch
from sentence_transformers import SentenceTransformer
if __name__ == "__main__":
model_name_or_path = "infgrad/Jasper-Token-Compression-600M"
model = SentenceTransformer(
model_name_or_path,
model_kwargs={
"torch_dtype": torch.bfloat16,
"attn_implementation": "sdpa", # We support flash_attention_2; sdpa; eager
"trust_remote_code": True
},
trust_remote_code=True,
tokenizer_kwargs={"padding_side": "left"},
device="cpu",
)
queries = [
"What is photosynthesis?",
"Who invented the telephone?",
]
documents = [
"Photosynthesis is the process by which green plants use sunlight, carbon dioxide, and water to produce glucose and oxygen",
"Alexander Graham Bell is credited with inventing the first practical telephone in 1876, receiving US patent number 174,465 for his device."
]
# The smaller the compression_ratio parameter, the faster the speed, but the quality will correspondingly decrease.
# Based on our parameter settings during training and test results, we recommend a range between 0.3-0.8.
query_embeddings = model.encode(queries, prompt_name="query", normalize_embeddings=True, compression_ratio=0.3333)
document_embeddings = model.encode(documents, normalize_embeddings=True, compression_ratio=0.3333)
similarity = model.similarity(query_embeddings, document_embeddings)
print(similarity)
Limitations and TODO
Retrieval performance
I found that distilled models struggle to approach the retrieval performance of teacher models, which is why I specifically used contrastive learning + distillation learning to enhance the student model. However, I found that while the enhanced model showed improvement on retrieval test sets, there is still a significant gap compared to mainstream models. Therefore, I believe that how to improve the retrieval performance of distilled models is a very necessary and valuable research direction.
More reasonable text token compression modules
There is limited research on text token compression currently, and I have only tried the simplest approach. I believe more reasonable text compression modules can definitely be found.
Text length
I only distilled texts up to 1024 tokens in length, so there should be performance degradation when text length exceeds 1024.
Citation
If you find our work worth citing, please use the following citation.
@misc{zhang2025jasperstelladistillationsota,
title={Jasper and Stella: distillation of SOTA embedding models},
author={Dun Zhang and Jiacheng Li and Ziyang Zeng and Fulong Wang},
year={2025},
eprint={2412.19048},
archivePrefix={arXiv},
primaryClass={cs.IR},
url={https://arxiv.org/abs/2412.19048},
}
@misc{zhang2025jaspertokencompression600mtechnicalreport,
title={Jasper-Token-Compression-600M Technical Report},
author={Dun Zhang and Ziyang Zeng and Yudong Zhou and Shuyang Lu},
year={2025},
eprint={2511.14405},
archivePrefix={arXiv},
primaryClass={cs.IR},
url={https://arxiv.org/abs/2511.14405},
}
- Downloads last month
- 2,778
1-bit
2-bit
3-bit
4-bit
5-bit
6-bit
8-bit
16-bit
Model tree for hanzceo/Jasper-Token-Compression-600M-GGUF
Base model
Qwen/Qwen3-0.6B-Base