Downloads · 30 days
33
0% of all-time downloads
m-polignano/ANITA-NEXT-24B-Magistral-2506-ITA
ANITA-NEXT-24B-Magistral-2506-ITA is a text generation model from m-polignano. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
<img src="https://huggingface.co/m-polignano/ANITA-NEXT-24B-Magistral-2506-ITA/resolve/main/Anita-Nextfull.png" alt="anitanext" border="0" width="600px" <hr <h3<i"Built on <bmistral/Magistral-Small-2506</b"</i</i</h3…
Downloads · 30 days
33
0% of all-time downloads
All-time downloads
30.9K
Public
Parameters
23.6B
47.2 GB on disk
Likes
3
Public
Click a slice to open those files.
.safetensors47.1 GB · 100%
From the Hugging Face model README
❗❗❗Use at your own risk. The model may generate hallucinations, incorrect, invented, offensive, unethical or dangerous responses. We are not responsible for any dangerous/offensive/criminal use. The model is release for research only purposes.❗❗❗
The 🌟ANITA project🌟 (Advanced Natural-based interaction for the ITAlian language) wants to provide Italian NLP researchers with an improved model for the Italian Language 🇮🇹 use cases.
The NEXT family includes four models:
GGUF - OLLAMA: m-polignano/ANITA-NEXT-24B-Magistral-2506-ITA-GGUF
<hr>Colab Demo: A100 - 40GB - Colab Notebook<br> The Model runs on a single GPU, 19.56GB of VRAM by using a 4bit Quantization.
<hr>To use the model directly, there are many ways to get started, choose one of the following ways to experience it.
<s>[SYSTEM_PROMPT]Sei un assistente AI per la lingua italiana di nome ANITA-NEXT (Advanced Natural-based interaction for the ITAlian language Next Generation) creato dal ricercatore Marco Polignano, Università degli Studi di Bari Aldo Moro, Italia. Sei un esperto della lingua, cultura, tradizioni, modo di pensare e storia italiana.
L'utente ti chiederà di risolvere un compito o rispondere ad una domanda. Rispondi e ragiona usando la lingua della domanda, preferendo l'Italiano.
Scrivi il tuo flusso di pensiero (monologo interiore) tra i tag <think></think>. Ragiona in modo disinvolto, scrivendo riflessioni e/o bozze, come se stessi lavorando a un esercizio su un foglio di carta.
Successivamente, scrivi la soluzione in modo chiaro, corretto, semplice ed esaustivo basandoti sul riassunto del tuo flusso di pensiero.
Se necessario, usa la notazione markdown per formattare la risposta.[/SYSTEM_PROMPT][INST]{ USER Prompt }[/INST]<think>{ ASSIST Thinking }</think>{ ASSIST Prompt }</s>
For direct use with transformers, you can easily get started with the following steps.
Firstly, you need to install transformers via the command below with pip.
pip install -U --no-deps bitsandbytes accelerate xformers transformers peft trl cut_cross_entropy unsloth_zoo
pip install sentencepiece protobuf "datasets>=3.4.1,<4.0.0" "huggingface_hub>=0.34.0" hf_transfer
Right now, you can start using the model directly.
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
from transformers import BitsAndBytesConfig
nf4_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=True,
bnb_4bit_compute_dtype=torch.bfloat16
)
model_dir = "m-polignano/ANITA-NEXT-24B-Magistral-2506-ITA"
tokenizer = AutoTokenizer.from_pretrained(model_dir, use_fast=True)
model = AutoModelForCausalLM.from_pretrained(
model_dir,
quantization_config=nf4_config,
device_map="auto",
torch_dtype=torch.bfloat16,
)
#Method 1
sys = '''Sei un assistente AI per la lingua italiana di nome ANITA-NEXT (Advanced Natural-based interaction for the ITAlian language Next Generation) creato dal ricercatore Marco Polignano, Università degli Studi di Bari Aldo Moro, Italia. Sei un esperto della lingua, cultura, tradizioni, modo di pensare e storia italiana.
L'utente ti chiederà di risolvere un compito o rispondere ad una domanda. Rispondi e ragiona usando la lingua della domanda, preferendo l'Italiano.
Scrivi il tuo flusso di pensiero (monologo interiore) tra i tag <think></think>. Ragiona in modo disinvolto, scrivendo riflessioni e/o bozze, come se stessi lavorando a un esercizio su un foglio di carta.
Successivamente, scrivi la soluzione in modo chiaro, corretto, semplice ed esaustivo basandoti sul riassunto del tuo flusso di pensiero.
Se necessario, usa la notazione markdown per formattare la risposta.'''
messages = [
{"role" : "system", "content" : sys},
{"role" : "user", "content" : "Chi è Carlo Magno?"}
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False)
for k,v in inputs.items():
inputs[k] = v.cuda()
outputs = model.generate(**inputs, max_new_tokens=32786, do_sample=True, top_p=0.9, temperature=0.7)
results = tokenizer.batch_decode(outputs)[0]
print(results)
#Method 2
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
from threading import Thread
import torch # Import torch to use .cuda() if needed
messages = [
{"role" : "user", "content" : "Chi è Marco Polo?"}
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False)
# Move inputs to CUDA if your model is on CUDA
for k,v in inputs.items():
inputs[k] = v.cuda()
# --- 4. Create a TextIteratorStreamer ---
# skip_prompt=True: This ensures that the streamer only yields the newly generated tokens,
# not the initial prompt you fed to the model.
# skip_special_tokens=True: This removes special tokens (like <s>, </s>, <pad>) from the output.
streamer = TextIteratorStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
# --- 5. Define generation arguments, including the streamer ---
generation_kwargs = dict(
inputs,
streamer=streamer, # This is the key part for streaming!
max_new_tokens=32786,
do_sample=True,
top_p=0.9,
temperature=0.7,
# Add any other generation arguments you need
)
# --- 6. Run model.generate in a separate thread ---
# This is crucial because model.generate is a blocking call.
# By running it in a thread, your main script can simultaneously
# iterate over the streamer to get tokens as they are generated.
thread = Thread(target=model.generate, kwargs=generation_kwargs)
thread.start()
# --- 7. Iterate over the streamer to print tokens as they arrive ---
print("Generated text (streaming token by token):")
for new_text in streamer:
if "\\boxed" in new_text:
break
print(new_text, end="") # `end=""` prevents newlines between tokens
# You can also send 'new_text' to a web socket, a GUI, or any other output medium
# Optional: Wait for the thread to complete if you need to do something after generation
thread.join()
@misc{polignano2024advanced,
title={Advanced Natural-based interaction for the ITAlian language: LLaMAntino-3-ANITA},
author={Marco Polignano and Pierpaolo Basile and Giovanni Semeraro},
year={2024},
eprint={2405.07101},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
@article{rastogi2025magistral,
title={Magistral},
author={Rastogi, Abhinav and Jiang, Albert Q and Lo, Andy and Berrada, Gabrielle and Lample, Guillaume and Rute, Jason and Barmentlo, Joep and Yadav, Karmesh and Khandelwal, Kartik and Chandu, Khyathi Raghavi and others},
journal={arXiv preprint arXiv:2506.10910},
year={2025}
}