Image-Text-to-Text
Transformers
Safetensors
English
lfm2_vl
text-generation-inference
unsloth
conversational
Instructions to use Ba2han/tr_ocr6 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Ba2han/tr_ocr6 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Ba2han/tr_ocr6") 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, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("Ba2han/tr_ocr6") model = AutoModelForImageTextToText.from_pretrained("Ba2han/tr_ocr6") 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 Ba2han/tr_ocr6 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Ba2han/tr_ocr6" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Ba2han/tr_ocr6", "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/Ba2han/tr_ocr6
- SGLang
How to use Ba2han/tr_ocr6 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 "Ba2han/tr_ocr6" \ --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": "Ba2han/tr_ocr6", "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 "Ba2han/tr_ocr6" \ --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": "Ba2han/tr_ocr6", "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" } } ] } ] }' - Unsloth Studio
How to use Ba2han/tr_ocr6 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 Ba2han/tr_ocr6 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 Ba2han/tr_ocr6 to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Ba2han/tr_ocr6 to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="Ba2han/tr_ocr6", max_seq_length=2048, ) - Docker Model Runner
How to use Ba2han/tr_ocr6 with Docker Model Runner:
docker model run hf.co/Ba2han/tr_ocr6
Upload model trained with Unsloth
Browse filesUpload model trained with Unsloth 2x faster
- README.md +2 -0
- config.json +100 -193
- generation_config.json +5 -9
- model.safetensors +2 -2
README.md
CHANGED
|
@@ -5,6 +5,8 @@ tags:
|
|
| 5 |
- transformers
|
| 6 |
- unsloth
|
| 7 |
- gemma4
|
|
|
|
|
|
|
| 8 |
license: apache-2.0
|
| 9 |
language:
|
| 10 |
- en
|
|
|
|
| 5 |
- transformers
|
| 6 |
- unsloth
|
| 7 |
- gemma4
|
| 8 |
+
- trl
|
| 9 |
+
- sft
|
| 10 |
license: apache-2.0
|
| 11 |
language:
|
| 12 |
- en
|
config.json
CHANGED
|
@@ -1,200 +1,107 @@
|
|
| 1 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
"architectures": [
|
| 3 |
-
|
| 4 |
],
|
| 5 |
-
"
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
"is_encoder_decoder": false,
|
| 25 |
-
"label2id": {
|
| 26 |
-
"LABEL_0": 0,
|
| 27 |
-
"LABEL_1": 1
|
| 28 |
-
},
|
| 29 |
-
"model_type": "gemma4_audio",
|
| 30 |
-
"num_attention_heads": 8,
|
| 31 |
-
"num_hidden_layers": 12,
|
| 32 |
-
"output_attentions": false,
|
| 33 |
-
"output_hidden_states": false,
|
| 34 |
-
"output_proj_dims": 1536,
|
| 35 |
-
"problem_type": null,
|
| 36 |
-
"residual_weight": 0.5,
|
| 37 |
-
"return_dict": true,
|
| 38 |
-
"rms_norm_eps": 1e-06,
|
| 39 |
-
"subsampling_conv_channels": [
|
| 40 |
-
128,
|
| 41 |
-
32
|
| 42 |
-
],
|
| 43 |
-
"use_clipped_linears": true
|
| 44 |
-
},
|
| 45 |
-
"audio_token_id": 258881,
|
| 46 |
-
"boa_token_id": 256000,
|
| 47 |
-
"boi_token_id": 255999,
|
| 48 |
-
"bos_token_id": 2,
|
| 49 |
-
"torch_dtype": "bfloat16",
|
| 50 |
-
"eoa_token_id": 258883,
|
| 51 |
-
"eoa_token_index": 258883,
|
| 52 |
-
"eoi_token_id": 258882,
|
| 53 |
-
"eos_token_id": 106,
|
| 54 |
-
"image_token_id": 258880,
|
| 55 |
"initializer_range": 0.02,
|
| 56 |
-
"
|
| 57 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
"pad_token_id": 0,
|
| 59 |
-
"
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
"attention_k_eq_v": false,
|
| 63 |
-
"bos_token_id": 2,
|
| 64 |
-
"torch_dtype": "bfloat16",
|
| 65 |
-
"enable_moe_block": false,
|
| 66 |
-
"eos_token_id": 1,
|
| 67 |
-
"expert_intermediate_size": null,
|
| 68 |
-
"final_logit_softcapping": 30.0,
|
| 69 |
-
"global_head_dim": 512,
|
| 70 |
-
"head_dim": 256,
|
| 71 |
-
"hidden_activation": "gelu_pytorch_tanh",
|
| 72 |
-
"hidden_size": 2560,
|
| 73 |
-
"hidden_size_per_layer_input": 256,
|
| 74 |
-
"initializer_range": 0.02,
|
| 75 |
-
"intermediate_size": 10240,
|
| 76 |
-
"layer_types": [
|
| 77 |
-
"sliding_attention",
|
| 78 |
-
"sliding_attention",
|
| 79 |
-
"sliding_attention",
|
| 80 |
-
"sliding_attention",
|
| 81 |
-
"sliding_attention",
|
| 82 |
-
"full_attention",
|
| 83 |
-
"sliding_attention",
|
| 84 |
-
"sliding_attention",
|
| 85 |
-
"sliding_attention",
|
| 86 |
-
"sliding_attention",
|
| 87 |
-
"sliding_attention",
|
| 88 |
-
"full_attention",
|
| 89 |
-
"sliding_attention",
|
| 90 |
-
"sliding_attention",
|
| 91 |
-
"sliding_attention",
|
| 92 |
-
"sliding_attention",
|
| 93 |
-
"sliding_attention",
|
| 94 |
-
"full_attention",
|
| 95 |
-
"sliding_attention",
|
| 96 |
-
"sliding_attention",
|
| 97 |
-
"sliding_attention",
|
| 98 |
-
"sliding_attention",
|
| 99 |
-
"sliding_attention",
|
| 100 |
-
"full_attention",
|
| 101 |
-
"sliding_attention",
|
| 102 |
-
"sliding_attention",
|
| 103 |
-
"sliding_attention",
|
| 104 |
-
"sliding_attention",
|
| 105 |
-
"sliding_attention",
|
| 106 |
-
"full_attention",
|
| 107 |
-
"sliding_attention",
|
| 108 |
-
"sliding_attention",
|
| 109 |
-
"sliding_attention",
|
| 110 |
-
"sliding_attention",
|
| 111 |
-
"sliding_attention",
|
| 112 |
-
"full_attention",
|
| 113 |
-
"sliding_attention",
|
| 114 |
-
"sliding_attention",
|
| 115 |
-
"sliding_attention",
|
| 116 |
-
"sliding_attention",
|
| 117 |
-
"sliding_attention",
|
| 118 |
-
"full_attention"
|
| 119 |
-
],
|
| 120 |
-
"max_position_embeddings": 131072,
|
| 121 |
-
"model_type": "gemma4_text",
|
| 122 |
-
"moe_intermediate_size": null,
|
| 123 |
-
"num_attention_heads": 8,
|
| 124 |
-
"num_experts": null,
|
| 125 |
-
"num_global_key_value_heads": null,
|
| 126 |
-
"num_hidden_layers": 42,
|
| 127 |
-
"num_key_value_heads": 2,
|
| 128 |
-
"num_kv_shared_layers": 18,
|
| 129 |
-
"pad_token_id": 0,
|
| 130 |
-
"rms_norm_eps": 1e-06,
|
| 131 |
-
"rope_parameters": {
|
| 132 |
-
"full_attention": {
|
| 133 |
-
"partial_rotary_factor": 0.25,
|
| 134 |
-
"rope_theta": 1000000.0,
|
| 135 |
-
"rope_type": "proportional"
|
| 136 |
-
},
|
| 137 |
-
"sliding_attention": {
|
| 138 |
-
"rope_theta": 10000.0,
|
| 139 |
-
"rope_type": "default"
|
| 140 |
-
}
|
| 141 |
-
},
|
| 142 |
-
"sliding_window": 512,
|
| 143 |
-
"tie_word_embeddings": true,
|
| 144 |
-
"top_k_experts": null,
|
| 145 |
-
"use_bidirectional_attention": null,
|
| 146 |
-
"use_cache": true,
|
| 147 |
-
"use_double_wide_mlp": false,
|
| 148 |
-
"vocab_size": 262144,
|
| 149 |
-
"vocab_size_per_layer_input": 262144
|
| 150 |
},
|
| 151 |
"tie_word_embeddings": true,
|
| 152 |
-
"
|
| 153 |
-
"
|
| 154 |
-
"
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
"max_position_embeddings": 131072,
|
| 180 |
-
"model_type": "gemma4_vision",
|
| 181 |
-
"num_attention_heads": 12,
|
| 182 |
-
"num_hidden_layers": 16,
|
| 183 |
-
"num_key_value_heads": 12,
|
| 184 |
-
"output_attentions": false,
|
| 185 |
-
"output_hidden_states": false,
|
| 186 |
-
"patch_size": 16,
|
| 187 |
-
"pooling_kernel_size": 3,
|
| 188 |
-
"position_embedding_size": 10240,
|
| 189 |
-
"problem_type": null,
|
| 190 |
-
"return_dict": true,
|
| 191 |
-
"rms_norm_eps": 1e-06,
|
| 192 |
-
"rope_parameters": {
|
| 193 |
-
"rope_theta": 100.0,
|
| 194 |
-
"rope_type": "default"
|
| 195 |
-
},
|
| 196 |
-
"standardize": false,
|
| 197 |
-
"use_clipped_linears": true
|
| 198 |
-
},
|
| 199 |
-
"vision_soft_tokens_per_image": 280
|
| 200 |
-
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"Lfm2VlForConditionalGeneration"
|
| 4 |
+
],
|
| 5 |
+
"bos_token_id": 1,
|
| 6 |
+
"do_image_splitting": true,
|
| 7 |
+
"downsample_factor": 2,
|
| 8 |
+
"dtype": "bfloat16",
|
| 9 |
+
"encoder_patch_size": 16,
|
| 10 |
+
"eos_token_id": 7,
|
| 11 |
+
"image_token_id": 396,
|
| 12 |
+
"max_image_tokens": 256,
|
| 13 |
+
"max_pixels_tolerance": 2.0,
|
| 14 |
+
"max_tiles": 10,
|
| 15 |
+
"min_image_tokens": 64,
|
| 16 |
+
"min_tiles": 2,
|
| 17 |
+
"model_name": "LiquidAI/LFM2.5-VL-1.6B",
|
| 18 |
+
"model_type": "lfm2_vl",
|
| 19 |
+
"pad_token_id": 0,
|
| 20 |
+
"projector_bias": true,
|
| 21 |
+
"projector_hidden_act": "gelu",
|
| 22 |
+
"projector_hidden_size": 2048,
|
| 23 |
+
"projector_use_layernorm": false,
|
| 24 |
+
"text_config": {
|
| 25 |
+
"_name_or_path": "LiquidAI/LFM2-1.2B",
|
| 26 |
"architectures": [
|
| 27 |
+
"Lfm2ForCausalLM"
|
| 28 |
],
|
| 29 |
+
"block_auto_adjust_ff_dim": true,
|
| 30 |
+
"block_dim": 2048,
|
| 31 |
+
"block_ffn_dim_multiplier": 1.0,
|
| 32 |
+
"block_mlp_init_scale": 1.0,
|
| 33 |
+
"block_multiple_of": 256,
|
| 34 |
+
"block_norm_eps": 1e-05,
|
| 35 |
+
"block_out_init_scale": 1.0,
|
| 36 |
+
"block_use_swiglu": true,
|
| 37 |
+
"block_use_xavier_init": true,
|
| 38 |
+
"bos_token_id": 1,
|
| 39 |
+
"conv_L_cache": 3,
|
| 40 |
+
"conv_bias": false,
|
| 41 |
+
"conv_dim": 2048,
|
| 42 |
+
"conv_dim_out": 2048,
|
| 43 |
+
"conv_use_xavier_init": true,
|
| 44 |
+
"dtype": "bfloat16",
|
| 45 |
+
"eos_token_id": 7,
|
| 46 |
+
"full_attn_idxs": null,
|
| 47 |
+
"hidden_size": 2048,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
"initializer_range": 0.02,
|
| 49 |
+
"intermediate_size": 12288,
|
| 50 |
+
"layer_types": [
|
| 51 |
+
"conv",
|
| 52 |
+
"conv",
|
| 53 |
+
"full_attention",
|
| 54 |
+
"conv",
|
| 55 |
+
"conv",
|
| 56 |
+
"full_attention",
|
| 57 |
+
"conv",
|
| 58 |
+
"conv",
|
| 59 |
+
"full_attention",
|
| 60 |
+
"conv",
|
| 61 |
+
"full_attention",
|
| 62 |
+
"conv",
|
| 63 |
+
"full_attention",
|
| 64 |
+
"conv",
|
| 65 |
+
"full_attention",
|
| 66 |
+
"conv"
|
| 67 |
+
],
|
| 68 |
+
"max_position_embeddings": 128000,
|
| 69 |
+
"model_type": "lfm2",
|
| 70 |
+
"norm_eps": 1e-05,
|
| 71 |
+
"num_attention_heads": 32,
|
| 72 |
+
"num_heads": 32,
|
| 73 |
+
"num_hidden_layers": 16,
|
| 74 |
+
"num_key_value_heads": 8,
|
| 75 |
"pad_token_id": 0,
|
| 76 |
+
"rope_parameters": {
|
| 77 |
+
"rope_theta": 1000000.0,
|
| 78 |
+
"rope_type": "default"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
},
|
| 80 |
"tie_word_embeddings": true,
|
| 81 |
+
"use_cache": true,
|
| 82 |
+
"use_pos_enc": true,
|
| 83 |
+
"vocab_size": 65536
|
| 84 |
+
},
|
| 85 |
+
"tie_word_embeddings": true,
|
| 86 |
+
"tile_size": 512,
|
| 87 |
+
"transformers_version": "5.5.0",
|
| 88 |
+
"unsloth_version": "2026.4.6",
|
| 89 |
+
"use_cache": false,
|
| 90 |
+
"use_image_special_tokens": true,
|
| 91 |
+
"use_thumbnail": true,
|
| 92 |
+
"vision_config": {
|
| 93 |
+
"attention_dropout": 0.0,
|
| 94 |
+
"dtype": "bfloat16",
|
| 95 |
+
"hidden_act": "gelu_pytorch_tanh",
|
| 96 |
+
"hidden_size": 1152,
|
| 97 |
+
"intermediate_size": 4304,
|
| 98 |
+
"layer_norm_eps": 1e-06,
|
| 99 |
+
"model_type": "siglip2_vision_model",
|
| 100 |
+
"num_attention_heads": 16,
|
| 101 |
+
"num_channels": 3,
|
| 102 |
+
"num_hidden_layers": 27,
|
| 103 |
+
"num_patches": 256,
|
| 104 |
+
"patch_size": 16,
|
| 105 |
+
"vision_use_head": false
|
| 106 |
+
}
|
| 107 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
generation_config.json
CHANGED
|
@@ -1,14 +1,10 @@
|
|
| 1 |
{
|
| 2 |
-
"
|
| 3 |
-
"
|
| 4 |
"eos_token_id": [
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
50
|
| 8 |
],
|
| 9 |
"pad_token_id": 0,
|
| 10 |
-
"
|
| 11 |
-
"top_k": 64,
|
| 12 |
-
"top_p": 0.95,
|
| 13 |
-
"transformers_version": "5.5.0.dev0"
|
| 14 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 1,
|
| 4 |
"eos_token_id": [
|
| 5 |
+
7,
|
| 6 |
+
7
|
|
|
|
| 7 |
],
|
| 8 |
"pad_token_id": 0,
|
| 9 |
+
"transformers_version": "5.5.0"
|
|
|
|
|
|
|
|
|
|
| 10 |
}
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7325e63bbd39624816bdb64cc5249bb6e7c1eb35dc17e5ca256d466696e10af9
|
| 3 |
+
size 3193334216
|