Text Generation
Transformers
Safetensors
gemma4
image-text-to-text
context-management
tool-use
agent
conversational
Instructions to use tencent/ContextPilot-E4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tencent/ContextPilot-E4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="tencent/ContextPilot-E4B") 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)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("tencent/ContextPilot-E4B") model = AutoModelForMultimodalLM.from_pretrained("tencent/ContextPilot-E4B", device_map="auto") 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?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use tencent/ContextPilot-E4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tencent/ContextPilot-E4B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tencent/ContextPilot-E4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/tencent/ContextPilot-E4B
- SGLang
How to use tencent/ContextPilot-E4B 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 "tencent/ContextPilot-E4B" \ --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": "tencent/ContextPilot-E4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "tencent/ContextPilot-E4B" \ --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": "tencent/ContextPilot-E4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use tencent/ContextPilot-E4B with Docker Model Runner:
docker model run hf.co/tencent/ContextPilot-E4B
File size: 1,287 Bytes
bc64885 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | {
"base": "/workspace/zhuoshipan/research/ACM/agentic_verl_latest_gemma4_20260814/checkpoints/statelm-gemma4-e4b/gemma4-e4b-v38-infnovel-focus100-from-v37s100-seed20261012/global_step_100/huggingface",
"base_extra_alias_tensors": 0,
"expert_delta_l2": {
"browse_local_endpoint": 2.3097255502527276,
"inf_local": 1.6287057477298472
},
"experts": [
{
"name": "inf_local",
"path": "/workspace/zhuoshipan/research/ACM/agentic_verl_latest_gemma4_20260814/checkpoints/statelm-gemma4-e4b/gemma4-e4b-v44-strong-inf-closedloop-fit-step52-lr1e5-seed20261017/global_step_52/huggingface",
"weight": -0.013
},
{
"name": "browse_local_endpoint",
"path": "/workspace/zhuoshipan/research/ACM/agentic_verl_latest_gemma4_20260814/checkpoints/statelm-gemma4-e4b/gemma4-e4b-v50-browse-fullactions-strong-from-v49s52-step52-lr1e5-seed20261024/global_step_52/huggingface",
"weight": 0.82
}
],
"formula": "base + sum(weight_i * (expert_i - base))",
"merged_delta_l2": 1.8919191800841255,
"non_floating_tensors": 0,
"output": "/workspace/zhuoshipan/research/ACM/agentic_verl_latest_gemma4_20260814/merges/gemma4-e4b-v54-v38-infa011-v50browse-local-a082-compact",
"schema": "gemma4-task-vector-merge-v1",
"tensor_count": 2076
}
|