Instructions to use trl-internal-testing/tiny-MistralLarge4ForConditionalGeneration with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use trl-internal-testing/tiny-MistralLarge4ForConditionalGeneration with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="trl-internal-testing/tiny-MistralLarge4ForConditionalGeneration") 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)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("trl-internal-testing/tiny-MistralLarge4ForConditionalGeneration") model = AutoModelForMultimodalLM.from_pretrained("trl-internal-testing/tiny-MistralLarge4ForConditionalGeneration", 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=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use trl-internal-testing/tiny-MistralLarge4ForConditionalGeneration with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "trl-internal-testing/tiny-MistralLarge4ForConditionalGeneration" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "trl-internal-testing/tiny-MistralLarge4ForConditionalGeneration", "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/trl-internal-testing/tiny-MistralLarge4ForConditionalGeneration
- SGLang
How to use trl-internal-testing/tiny-MistralLarge4ForConditionalGeneration 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 "trl-internal-testing/tiny-MistralLarge4ForConditionalGeneration" \ --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": "trl-internal-testing/tiny-MistralLarge4ForConditionalGeneration", "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 "trl-internal-testing/tiny-MistralLarge4ForConditionalGeneration" \ --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": "trl-internal-testing/tiny-MistralLarge4ForConditionalGeneration", "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 trl-internal-testing/tiny-MistralLarge4ForConditionalGeneration with Docker Model Runner:
docker model run hf.co/trl-internal-testing/tiny-MistralLarge4ForConditionalGeneration
FP8 weights, like the reference checkpoint
Browse files- config.json +24 -1
- model.safetensors +2 -2
- tokenizer_config.json +2 -2
config.json
CHANGED
|
@@ -7,11 +7,33 @@
|
|
| 7 |
"model_type": "mistral_large4",
|
| 8 |
"multimodal_projector_bias": false,
|
| 9 |
"projector_hidden_act": "gelu",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
"spatial_merge_size": 2,
|
| 11 |
"text_config": {
|
| 12 |
"attention_bias": false,
|
| 13 |
"attention_dropout": 0.0,
|
| 14 |
"bos_token_id": 1,
|
|
|
|
| 15 |
"eos_token_id": 2,
|
| 16 |
"final_logit_softcapping": 30.0,
|
| 17 |
"first_k_dense_replace": 1,
|
|
@@ -66,7 +88,7 @@
|
|
| 66 |
"sparse"
|
| 67 |
],
|
| 68 |
"model_type": "mistral_large4_text",
|
| 69 |
-
"moe_intermediate_size":
|
| 70 |
"n_group": 1,
|
| 71 |
"n_routed_experts": 8,
|
| 72 |
"n_shared_experts": 1,
|
|
@@ -111,6 +133,7 @@
|
|
| 111 |
"transformers_version": "5.21.0.dev0",
|
| 112 |
"vision_config": {
|
| 113 |
"attention_dropout": 0.0,
|
|
|
|
| 114 |
"head_dim": 4,
|
| 115 |
"hidden_act": "silu",
|
| 116 |
"hidden_size": 16,
|
|
|
|
| 7 |
"model_type": "mistral_large4",
|
| 8 |
"multimodal_projector_bias": false,
|
| 9 |
"projector_hidden_act": "gelu",
|
| 10 |
+
"quantization_config": {
|
| 11 |
+
"activation_scheme": "dynamic",
|
| 12 |
+
"dequantize": false,
|
| 13 |
+
"expert_dtype": "fp8",
|
| 14 |
+
"modules_to_convert": null,
|
| 15 |
+
"modules_to_not_convert": [
|
| 16 |
+
"model.vision_tower",
|
| 17 |
+
"model.multi_modal_projector",
|
| 18 |
+
"lm_head",
|
| 19 |
+
"kv_b_proj",
|
| 20 |
+
"indexer.wk",
|
| 21 |
+
"indexer.weights_proj",
|
| 22 |
+
"kv_a_proj_with_mqa"
|
| 23 |
+
],
|
| 24 |
+
"quant_method": "fp8",
|
| 25 |
+
"scale_fmt": "float",
|
| 26 |
+
"weight_block_size": [
|
| 27 |
+
32,
|
| 28 |
+
32
|
| 29 |
+
]
|
| 30 |
+
},
|
| 31 |
"spatial_merge_size": 2,
|
| 32 |
"text_config": {
|
| 33 |
"attention_bias": false,
|
| 34 |
"attention_dropout": 0.0,
|
| 35 |
"bos_token_id": 1,
|
| 36 |
+
"dtype": "bfloat16",
|
| 37 |
"eos_token_id": 2,
|
| 38 |
"final_logit_softcapping": 30.0,
|
| 39 |
"first_k_dense_replace": 1,
|
|
|
|
| 88 |
"sparse"
|
| 89 |
],
|
| 90 |
"model_type": "mistral_large4_text",
|
| 91 |
+
"moe_intermediate_size": 64,
|
| 92 |
"n_group": 1,
|
| 93 |
"n_routed_experts": 8,
|
| 94 |
"n_shared_experts": 1,
|
|
|
|
| 133 |
"transformers_version": "5.21.0.dev0",
|
| 134 |
"vision_config": {
|
| 135 |
"attention_dropout": 0.0,
|
| 136 |
+
"dtype": "bfloat16",
|
| 137 |
"head_dim": 4,
|
| 138 |
"hidden_act": "silu",
|
| 139 |
"hidden_size": 16,
|
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:30e7f2faab9479609a7075553e61bcd2239513e0a6fb7b6b506549154217adbb
|
| 3 |
+
size 26755208
|
tokenizer_config.json
CHANGED
|
@@ -2,8 +2,8 @@
|
|
| 2 |
"backend": "tokenizers",
|
| 3 |
"bos_token": "<s>",
|
| 4 |
"eos_token": "</s>",
|
| 5 |
-
"is_local":
|
| 6 |
-
"local_files_only":
|
| 7 |
"model_max_length": 1000000000000000019884624838656,
|
| 8 |
"pad_token": "<pad>",
|
| 9 |
"processor_class": "PixtralProcessor",
|
|
|
|
| 2 |
"backend": "tokenizers",
|
| 3 |
"bos_token": "<s>",
|
| 4 |
"eos_token": "</s>",
|
| 5 |
+
"is_local": true,
|
| 6 |
+
"local_files_only": false,
|
| 7 |
"model_max_length": 1000000000000000019884624838656,
|
| 8 |
"pad_token": "<pad>",
|
| 9 |
"processor_class": "PixtralProcessor",
|