Model Details

This model is an int4 model with group_size 128 and symmetric quantization of mistralai/Mistral-Small-3.1-24B-Instruct-2503 generated by intel/auto-round algorithm.

Please follow the license of the original model.

INT4 Inference

Requirements

pip install git+https://github.com/huggingface/transformers.git

Note: There is no official HuggingFace sample code of the original model. The following code may have issues.

from transformers import AutoProcessor, Mistral3ForConditionalGeneration, AutoTokenizer
from huggingface_hub import hf_hub_download
import torch
from datetime import datetime, timedelta

model_id = "OPEA/Mistral-Small-3.1-24B-Instruct-2503-int4-AutoRound-gptq-sym"

def load_system_prompt(repo_id: str, filename: str) -> str:
    file_path = hf_hub_download(repo_id=repo_id, filename=filename)
    with open(file_path, "r") as file:
        system_prompt = file.read()
    today = datetime.today().strftime("%Y-%m-%d")
    yesterday = (datetime.today() - timedelta(days=1)).strftime("%Y-%m-%d")
    model_name = repo_id.split("/")[-1]
    return system_prompt.format(name=model_name, today=today, yesterday=yesterday)


SYSTEM_PROMPT = load_system_prompt(model_id, "SYSTEM_PROMPT.txt")

model = Mistral3ForConditionalGeneration.from_pretrained(
    model_id, torch_dtype=torch.float16, device_map="auto"
).eval()

processor = AutoProcessor.from_pretrained(model_id)
tokenizer = AutoTokenizer.from_pretrained(model_id)
url = "https://huggingface.co/datasets/patrickvonplaten/random_img/resolve/main/europe.png"

prompt = "Which of the depicted countries has the best food? Which the second and third and fourth? Name the country, its color on the map and one its city that is visible on the map, but is not the capital. Make absolutely sure to only name a city that can be seen on the map."

messages = [
    {"role": "system", "content": SYSTEM_PROMPT},
    {
        "role": "user",
        "content": [
            {
                "type": "text",
                "text": prompt,
            },
            {"type": "image"}
        ],
    },
]
inputs = processor.apply_chat_template(
    messages, add_generation_prompt=True, tokenize=False,
    return_dict=True
)
inputs =processor(images=url,
    text=inputs,
    add_special_tokens=False,
    return_tensors="pt").to(model.device).to(torch.float16)

input_len = inputs["input_ids"].shape[-1]

with torch.inference_mode():
    generation = model.generate(**inputs, max_new_tokens=512, do_sample=True)
    generation = generation[0][input_len:]

decoded = processor.decode(generation, skip_special_tokens=True)
print(decoded)
## Output:
## The map shows many countries, but here are some general notes for countries often recognized for their culinary traditions:
## 
## 1. **Italy (Green)**: Known for its rich and diverse cuisine, including pasta, pizza, and gelato and many more.
##    - City: Torino
##
## 2. **France (Yellow-brown)**: Renowned for its refined techniques, high-quality ingredients, and iconic dishes.
##    - City: Marseille
##
## 3. **Spain (Light Brown-Yellow)**: Famous for tapas, paella, and jamón ibérico and many more.
##    - City: Barcelona
## 
## 4. **Germany (Orange)**: Celebrated for its hearty dishes like sausages, pretzels, and beer. Also has a high quality of bread.
##    - City: Munich
## 
## 5. **Greece (Red-Brown)**: Known for Mediterranean flavors in dishes like moussaka, souvlaki, and tzatziki and many more.
##    - City: Thessaloniki
## 
## 6. **Turkey (Yellow-Green)**: Offers a blend of European and Middle Eastern flavors, known for kebabs, baklava and many more.
##    - City: Antalya
## 
## There are many more countries in Europe with great food. The culinary preferences can vary widely depending on personal tastes and cultural backgrounds.

Generate the model

Here is the sample command to reproduce the model.

pip install git+https://github.com/intel/auto-round.git@main
auto-round-mllm \
--model mistralai/Mistral-Small-3.1-24B-Instruct-2503 \
--device 0 \
--bits 4 \
--format 'auto_awq,auto_gptq' \
--output_dir "./tmp_autoround"

Ethical Considerations and Limitations

The model can produce factually incorrect output, and should not be relied on to produce factually accurate information. Because of the limitations of the pretrained model and the finetuning datasets, it is possible that this model could generate lewd, biased or otherwise offensive outputs.

Therefore, before deploying any applications of the model, developers should perform safety testing.

Caveats and Recommendations

Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.

Here are a couple of useful links to learn more about Intel's AI software:

  • Intel Neural Compressor link

Disclaimer

The license on this model does not constitute legal advice. We are not responsible for the actions of third parties who use this model. Please consult an attorney before using this model for commercial purposes.

Cite

@article{cheng2023optimize, title={Optimize weight rounding via signed gradient descent for the quantization of llms}, author={Cheng, Wenhua and Zhang, Weiwei and Shen, Haihao and Cai, Yiyang and He, Xin and Lv, Kaokao and Liu, Yi}, journal={arXiv preprint arXiv:2309.05516}, year={2023} }

arxiv github

Downloads last month
122
Safetensors
Model size
4.76B params
Tensor type
BF16
·
I32
·
FP16
·
Inference Providers NEW
This model is not currently available via any of the supported Inference Providers.
The model cannot be deployed to the HF Inference API: The model has no library tag.

Model tree for OPEA/Mistral-Small-3.1-24B-Instruct-2503-int4-AutoRound-gptq-sym

Dataset used to train OPEA/Mistral-Small-3.1-24B-Instruct-2503-int4-AutoRound-gptq-sym

Collection including OPEA/Mistral-Small-3.1-24B-Instruct-2503-int4-AutoRound-gptq-sym