Image-Text-to-Text
Transformers
Safetensors
English
llava_next
text-generation-inference
unsloth
conversational
4-bit precision
bitsandbytes
Instructions to use Prince12f/Llava_spatial_reasoning with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Prince12f/Llava_spatial_reasoning with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Prince12f/Llava_spatial_reasoning") 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("Prince12f/Llava_spatial_reasoning") model = AutoModelForMultimodalLM.from_pretrained("Prince12f/Llava_spatial_reasoning", 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 Prince12f/Llava_spatial_reasoning with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Prince12f/Llava_spatial_reasoning" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Prince12f/Llava_spatial_reasoning", "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/Prince12f/Llava_spatial_reasoning
- SGLang
How to use Prince12f/Llava_spatial_reasoning 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 "Prince12f/Llava_spatial_reasoning" \ --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": "Prince12f/Llava_spatial_reasoning", "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 "Prince12f/Llava_spatial_reasoning" \ --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": "Prince12f/Llava_spatial_reasoning", "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 Desktop
- Docker Model Runner
How to use Prince12f/Llava_spatial_reasoning with Docker Model Runner:
docker model run hf.co/Prince12f/Llava_spatial_reasoning
(Trained with Unsloth)
Browse files- config.json +81 -0
- generation_config.json +7 -0
config.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_name_or_path": "unsloth/llava-v1.6-mistral-7b-hf-bnb-4bit",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"LlavaNextForConditionalGeneration"
|
| 5 |
+
],
|
| 6 |
+
"ignore_index": -100,
|
| 7 |
+
"image_grid_pinpoints": [
|
| 8 |
+
[
|
| 9 |
+
336,
|
| 10 |
+
672
|
| 11 |
+
],
|
| 12 |
+
[
|
| 13 |
+
672,
|
| 14 |
+
336
|
| 15 |
+
],
|
| 16 |
+
[
|
| 17 |
+
672,
|
| 18 |
+
672
|
| 19 |
+
],
|
| 20 |
+
[
|
| 21 |
+
1008,
|
| 22 |
+
336
|
| 23 |
+
],
|
| 24 |
+
[
|
| 25 |
+
336,
|
| 26 |
+
1008
|
| 27 |
+
]
|
| 28 |
+
],
|
| 29 |
+
"image_seq_length": 576,
|
| 30 |
+
"image_token_index": 32000,
|
| 31 |
+
"model_type": "llava_next",
|
| 32 |
+
"pad_token_id": 32001,
|
| 33 |
+
"projector_hidden_act": "gelu",
|
| 34 |
+
"quantization_config": {
|
| 35 |
+
"bnb_4bit_compute_dtype": "bfloat16",
|
| 36 |
+
"bnb_4bit_quant_type": "nf4",
|
| 37 |
+
"bnb_4bit_use_double_quant": true,
|
| 38 |
+
"llm_int8_enable_fp32_cpu_offload": false,
|
| 39 |
+
"llm_int8_has_fp16_weight": false,
|
| 40 |
+
"llm_int8_skip_modules": null,
|
| 41 |
+
"llm_int8_threshold": 6.0,
|
| 42 |
+
"load_in_4bit": true,
|
| 43 |
+
"load_in_8bit": false,
|
| 44 |
+
"quant_method": "bitsandbytes"
|
| 45 |
+
},
|
| 46 |
+
"text_config": {
|
| 47 |
+
"_name_or_path": "mistralai/Mistral-7B-Instruct-v0.2",
|
| 48 |
+
"architectures": [
|
| 49 |
+
"MistralForCausalLM"
|
| 50 |
+
],
|
| 51 |
+
"intermediate_size": 14336,
|
| 52 |
+
"max_position_embeddings": 32768,
|
| 53 |
+
"model_type": "mistral",
|
| 54 |
+
"num_key_value_heads": 8,
|
| 55 |
+
"rms_norm_eps": 1e-05,
|
| 56 |
+
"rope_theta": 1000000.0,
|
| 57 |
+
"sliding_window": null,
|
| 58 |
+
"torch_dtype": "bfloat16",
|
| 59 |
+
"vocab_size": 32064
|
| 60 |
+
},
|
| 61 |
+
"tie_word_embeddings": false,
|
| 62 |
+
"torch_dtype": "bfloat16",
|
| 63 |
+
"transformers_version": "4.46.2",
|
| 64 |
+
"unsloth_fixed": true,
|
| 65 |
+
"unsloth_version": "2025.1.5",
|
| 66 |
+
"use_image_newline_parameter": true,
|
| 67 |
+
"vision_config": {
|
| 68 |
+
"hidden_size": 1024,
|
| 69 |
+
"image_size": 336,
|
| 70 |
+
"intermediate_size": 4096,
|
| 71 |
+
"model_type": "clip_vision_model",
|
| 72 |
+
"num_attention_heads": 16,
|
| 73 |
+
"num_hidden_layers": 24,
|
| 74 |
+
"patch_size": 14,
|
| 75 |
+
"projection_dim": 768,
|
| 76 |
+
"vocab_size": 32000
|
| 77 |
+
},
|
| 78 |
+
"vision_feature_layer": -2,
|
| 79 |
+
"vision_feature_select_strategy": "default",
|
| 80 |
+
"vocab_size": 32064
|
| 81 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 1,
|
| 4 |
+
"eos_token_id": 2,
|
| 5 |
+
"pad_token_id": 32001,
|
| 6 |
+
"transformers_version": "4.46.2"
|
| 7 |
+
}
|