Run this model with HF Jobs
Run codefuse-ai/CodeFuse-VLM-14B 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/codefuse-ai/CodeFuse-VLM-14B. 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/codefuse-ai/CodeFuse-VLM-14B 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/codefuse-ai/CodeFuse-VLM-14B. 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/codefuse-ai/CodeFuse-VLM-14B. 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 codefuse-ai/CodeFuse-VLM-14B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use codefuse-ai/CodeFuse-VLM-14B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="codefuse-ai/CodeFuse-VLM-14B", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("codefuse-ai/CodeFuse-VLM-14B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use codefuse-ai/CodeFuse-VLM-14B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "codefuse-ai/CodeFuse-VLM-14B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "codefuse-ai/CodeFuse-VLM-14B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/codefuse-ai/CodeFuse-VLM-14B
- SGLang
How to use codefuse-ai/CodeFuse-VLM-14B 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 "codefuse-ai/CodeFuse-VLM-14B" \ --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": "codefuse-ai/CodeFuse-VLM-14B", "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 "codefuse-ai/CodeFuse-VLM-14B" \ --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": "codefuse-ai/CodeFuse-VLM-14B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use codefuse-ai/CodeFuse-VLM-14B with Docker Model Runner:
docker model run hf.co/codefuse-ai/CodeFuse-VLM-14B
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
CodeFuse-VLM
CodeFuse-VLM is a Multimodal LLM(MLLM) framework that provides users with multiple vision encoders, multimodal alignment adapters, and LLMs. Through CodeFuse-VLM framework, users are able to customize their own MLLM model to adapt their own tasks. As more and more models are published on Huggingface community, there will be more open-source vision encoders and LLMs. Each of these models has their own specialties, e.g. Code-LLama is good at code-related tasks but has poor performance for Chinese tasks. Therefore, we built CodeFuse-VLM framework to support multiple vision encoders, multimodal alignment adapters, and LLMs to adapt different types of tasks.
Under CodeFuse-VLM framework, we use cross attention multimodal adapter, Qwen-14B LLM, and Qwen-VL's vision encoder to train CodeFuse-VLM-14B model. On multiple benchmarks, our CodeFuse-VLM-14B shows superior performances over Qwen-VL and LLAVA-1.5.
Here is the table for different MLLM model's performance on benchmarks
| Model | MMBench | MMBench-CN | VqaV2 | GQA | TextVQA | Vizwiz |
|---|---|---|---|---|---|---|
| LLAVA-1.5 | 67.7 | 63.6 | 80.0 | 63.3 | 61.3 | 53.6 |
| Qwen-VL | 60.6 | 56.7 | 78.2 | 57.5 | 63.8 | 38.9 |
| CodeFuse-VLM-14B | 75.7 | 69.8 | 79.3 | 59.4 | 63.9 | 45.3 |
Contents
Install
Please run sh init_env.sh
Datasets
Here's the table of datasets we used to train CodeFuse-VLM-14B:
| Dataset | Task Type | Number of Samples |
|---|---|---|
| synthdog-en | OCR | 800,000 |
| synthdog-zh | OCR | 800,000 |
| cc3m(downsampled) | Image Caption | 600,000 |
| cc3m(downsampled) | Image Caption | 600,000 |
| SBU | Image Caption | 850,000 |
| Visual Genome VQA (Downsampled) | Visual Question Answer(VQA) | 500,000 |
| Visual Genome Region descriptions (Downsampled) | Reference Grouding | 500,000 |
| Visual Genome objects (Downsampled) | Grounded Caption | 500,000 |
| OCR VQA (Downsampled) | OCR and VQA | 500,000 |
Please download these datasets on their own official websites.
Multimodal Alignment
Please run sh scripts/pretrain.sh or sh scripts/pretrain_multinode.sh
Visual Instruction Tuning
Please run sh scripts/finetune.sh or sh scripts/finetune_multinode.sh
Evaluation
Please run python scripts in directory llava/eval/. Our pre-trained CodeFuse-VLM-14B can be loaded with the following code:
import os
from llava.model.builder import load_mixed_pretrained_model
model_path = '/pretrained/model/path'
tokenizer, model, image_processor, context_len = load_mixed_pretrained_model(model_path, None, 'qwen-vl-14b', os.path.join(model_path, 'Qwen-VL-visual'), 'cross_attn', os.path.join(model_path, 'mm_projector/mm_projector.bin'))
- Downloads last month
- 35