Image-Text-to-Text
Transformers
Safetensors
multilingual
qianfan_ocr
vision-language
ocr
document-intelligence
qianfan
conversational
Eval Results (legacy)
Eval Results
Instructions to use rootlocalghost/Qianfan-OCR with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use rootlocalghost/Qianfan-OCR with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="rootlocalghost/Qianfan-OCR") 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("rootlocalghost/Qianfan-OCR") model = AutoModelForMultimodalLM.from_pretrained("rootlocalghost/Qianfan-OCR") 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 rootlocalghost/Qianfan-OCR with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "rootlocalghost/Qianfan-OCR" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rootlocalghost/Qianfan-OCR", "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/rootlocalghost/Qianfan-OCR
- SGLang
How to use rootlocalghost/Qianfan-OCR 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 "rootlocalghost/Qianfan-OCR" \ --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": "rootlocalghost/Qianfan-OCR", "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 "rootlocalghost/Qianfan-OCR" \ --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": "rootlocalghost/Qianfan-OCR", "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 rootlocalghost/Qianfan-OCR with Docker Model Runner:
docker model run hf.co/rootlocalghost/Qianfan-OCR
clone config.json
Browse files- config.json +77 -0
config.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"QianfanOCRForConditionalGeneration"
|
| 4 |
+
],
|
| 5 |
+
"downsample_ratio": 0.5,
|
| 6 |
+
"dynamic_image_size": true,
|
| 7 |
+
"eos_token_id": 151645,
|
| 8 |
+
"force_image_size": 448,
|
| 9 |
+
"image_token_id": 151671,
|
| 10 |
+
"text_config": {
|
| 11 |
+
"_name_or_path": "/root/codespace/checkpoints/Qwen3-4B",
|
| 12 |
+
"architectures": [
|
| 13 |
+
"Qwen3ForCausalLM"
|
| 14 |
+
],
|
| 15 |
+
"attention_bias": false,
|
| 16 |
+
"attention_dropout": 0.0,
|
| 17 |
+
"bos_token_id": 151643,
|
| 18 |
+
"debug": false,
|
| 19 |
+
"eos_token_id": 151645,
|
| 20 |
+
"ep_size": 1,
|
| 21 |
+
"head_dim": 128,
|
| 22 |
+
"hidden_act": "silu",
|
| 23 |
+
"hidden_size": 2560,
|
| 24 |
+
"initializer_range": 0.02,
|
| 25 |
+
"intermediate_size": 9728,
|
| 26 |
+
"max_position_embeddings": 32768,
|
| 27 |
+
"max_window_layers": 36,
|
| 28 |
+
"micro_forward": false,
|
| 29 |
+
"model_type": "qwen3",
|
| 30 |
+
"num_attention_heads": 32,
|
| 31 |
+
"num_hidden_layers": 36,
|
| 32 |
+
"num_key_value_heads": 8,
|
| 33 |
+
"rms_norm_eps": 1e-06,
|
| 34 |
+
"rope_scaling": null,
|
| 35 |
+
"rope_theta": 5000000,
|
| 36 |
+
"skip_checkpoint": false,
|
| 37 |
+
"sliding_window": null,
|
| 38 |
+
"torch_dtype": "bfloat16",
|
| 39 |
+
"use_cache": false,
|
| 40 |
+
"use_deepep": false,
|
| 41 |
+
"use_sliding_window": false,
|
| 42 |
+
"vocab_size": 153678
|
| 43 |
+
},
|
| 44 |
+
"max_dynamic_patch": 12,
|
| 45 |
+
"min_dynamic_patch": 1,
|
| 46 |
+
"model_type": "qianfan_ocr",
|
| 47 |
+
"pad2square": false,
|
| 48 |
+
"pad_token_id": 151643,
|
| 49 |
+
"ps_version": "v2",
|
| 50 |
+
"select_layer": -1,
|
| 51 |
+
"template": "internvl2_5",
|
| 52 |
+
"tie_word_embeddings": false,
|
| 53 |
+
"torch_dtype": "bfloat16",
|
| 54 |
+
"transformers_version": null,
|
| 55 |
+
"use_thumbnail": true,
|
| 56 |
+
"vision_config": {
|
| 57 |
+
"architectures": [
|
| 58 |
+
"QianfanOCRVisionModel"
|
| 59 |
+
],
|
| 60 |
+
"attention_dropout": 0.0,
|
| 61 |
+
"drop_path_rate": 0.1,
|
| 62 |
+
"hidden_act": "gelu",
|
| 63 |
+
"hidden_size": 1024,
|
| 64 |
+
"image_size": 448,
|
| 65 |
+
"initializer_range": 0.02,
|
| 66 |
+
"intermediate_size": 4096,
|
| 67 |
+
"layer_norm_eps": 1e-06,
|
| 68 |
+
"model_type": "qianfan_ocr_vision",
|
| 69 |
+
"norm_type": "layer_norm",
|
| 70 |
+
"num_attention_heads": 16,
|
| 71 |
+
"num_channels": 3,
|
| 72 |
+
"num_hidden_layers": 24,
|
| 73 |
+
"patch_size": 14,
|
| 74 |
+
"qkv_bias": true,
|
| 75 |
+
"torch_dtype": "bfloat16"
|
| 76 |
+
}
|
| 77 |
+
}
|