Archive of AI

Source Snapshot / 2024-07-18-mistral-nemo-12b-tekken-3

mistralai/Mistral-Nemo-Instruct-2407

Linked event: 2024-07-18 · Mistral AI and NVIDIA Open-Source 12B Multilingual Model Mistral NeMo and 100+ Language Tokenizer Tekken

Publisher
Hugging Face
Archived
2026-11-23
Capture Method
Direct page capture
HTTP / SHA-256
200 / aec40b8e47ea110b
Original URL
Open source ↗
Wayback Backup
Not archived
This page preserves a plain-text static snapshot against link rot. When citing figures, tables, or full legal terms, verify against the original URL and Wayback Machine archive.

[来源关键摘录] Hugging Face 官方模型仓库,公开 Mistral NeMo 指令微调权重与 Apache 2.0 许可。

[正文前段节选] Hugging Face

Search models, datasets, users... ⌘K

Mistral-Nemo-Instruct-2407

Mistral 21.2k

mistral-common

Eval Results

License: apache-2.0

Model card Files Files and versions

Copy to bucket

Model Card for Mistral-Nemo-Instruct-2407

The Mistral-Nemo-Instruct-2407 Large Language Model (LLM) is an instruct fine-tuned version of the Mistral-Nemo-Base-2407. Trained jointly by Mistral AI and NVIDIA, it significantly outperforms existing models smaller or similar in size.

For more details about this model please refer to our release blog post.

Key features

Released under the Apache 2 License

Pre-trained and instructed versions

Trained with a 128k context window

Trained on a large proportion of multilingual and code data

Drop-in replacement of Mistral 7B

Model Architecture

Mistral Nemo is a transformer model, with the following architecture choices:

Head dim: 128

Hidden dim: 14,336

Activation Function: SwiGLU

Number of heads: 32

Number of kv-heads: 8 (GQA)

Vocabulary size: 2**17 ~= 128k

Rotary embeddings (theta = 1M)

Main Benchmarks

HellaSwag (0-shot)

Winogrande (0-shot)

OpenBookQA (0-shot)

CommonSenseQA (0-shot)

TruthfulQA (0-shot)

MMLU (5-shot)

TriviaQA (5-shot)

NaturalQuestions (5-shot)

Multilingual Benchmarks (MMLU)

The model can be used with three different frameworks

mistral_inference: See here

transformers: See here

NeMo: See nvidia/Mistral-NeMo-12B-Instruct

Mistral Inference

It is recommended to use mistralai/Mistral-Nemo-Instruct-2407 with mistral-inference. For HF transformers code snippets, please keep scrolling.

pip install mistral_inference

from huggingface_hub import snapshot_download

from pathlib import Path

mistral_models_path = Path.home().joinpath('mistral_models', 'Nemo-Instruct')

mistral_models_path.mkdir(parents=True, exist_ok=True)

snapshot_download(repo_id="mistralai/Mistral-Nemo-Instruct-2407", allow_patterns=["params.json", "consolidated.safetensors", "tekken.json"], local_dir=mistral_models_path)

After installing mistral_inference, a mistral-chat CLI command should be available in your environment. You can chat with the model using

mistral-chat $HOME/mistral_models/Nemo-Instruct --instruct --max_tokens 256 --temperature 0.35

E.g. Try out something like:

How expensive would it be to ask a window cleaner to clean all windows in Paris. Make a reasonable guess in US Dollar.

Instruct following

from mistral_inference.transformer import Transformer

from mistral_inference.generate import generate

from mistral_common.tokens.tokenizers.mistral import MistralTokenizer

from mistral_common.protocol.instruct.messages import UserMessage

from mistral_common.protocol.instruct.request import ChatCompletionRequest

tokenizer = MistralTokenizer.from_file(f"{mistral_models_path}/tekken.json")

model = Transformer.from_folder(mistral_models_path)

prompt = "How expensive would it be to ask a window cleaner to clean all windows in Paris. Make a reasonable guess in US Dollar."

completion_request = ChatCompletionRequest(messages=[UserMessage(content=prompt)])

tokens = tokenizer.encode_chat_completion(completion_request).tokens

out_tokens, _ = generate([tokens], model, max_tokens=64, temperature=0.35, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)

result = tokenizer.decode(out_tokens[0])

print(result)

Function calling

from mistral_common.protocol.instruct.tool_calls import Function, Tool

completion_request = ChatCompletionRequest(

function=Function(

name="get_current_weather",

description="Get the current weather",

parameters={

"type": "object",

"properties": {

"location": {

"type": "string",

"description": "The city and state, e.g. San Francisco, CA",

"enum": ["celsius", "fahrenheit"],

"description": "The temperature unit to use. Infer this from the users location.",

"required": ["location", "format"],

UserMessage(content="What's the weather like today in Paris?"),

out_tokens, _ = generate([tokens], model, max_tokens=256, temperature=0.35, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)

Transformers

NOTE: Until a new release has been made, you need to install transformers from source:

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

If you want to use Hugging Face transformers to generate text, you can do something like this.

from transformers import pipeline

messages = [

{"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},

{"role": "user", "content": "Who are you?"},

chatbot = pipeline("text-generation", model="mistralai/Mistral-Nemo-Instruct-2407",max_new_tokens=128)

chatbot(messages)

Function calling with transformers

To use this example, you'll need transformers version 4.42.0 or higher. Please see the

function calling guide

in the transformers docs for more information.

from transformers import AutoModelForCausalLM, AutoTokenizer

import torch

model_id = "mistralai/Mistral-Nemo-Instruct-2407"

tokenizer = AutoTokenizer.from_pretrained(model_id)

def get_current_weather(location: str, format: str):

Get the current weather

location: The city and state, e.g. San Francisco, CA

format: The temperature unit to use. Infer this from the users location. (choices: ["celsius", "fahrenheit"])

conversation = [{"role": "user", "content": "What's the weather like in Paris?"}]

tools = [get_current_weather]

# format and tokenize the tool use prompt

inputs = tokenizer.apply_chat_template(

conversation,

tools=tools,

add_generation_prompt=True,

return_dict=True,

return_tensors="pt",

model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto")

inputs.to(model.device)

outputs = model.generate(**inputs, max_new_tokens=1000)

print(tokenizer.decode(outputs[0], skip_special_tokens=True))

Note that, for reasons of space, this example does not show a complete cycle of calling a tool and adding the tool call and tool

results to the chat history so that the model can use them in its next generation. For a full tool calling example, please

see the function calling guide,

and note that Mistral does use tool call IDs, so these must be included in your tool calls and tool results. They should be

exactly 9 alphanumeric characters.

Unlike previous Mistral models, Mistral Nemo requires smaller temperatures. We recommend to use a temperature of 0.3.

The Mistral Nemo Instruct model is a quick demonstration that the base model can be easily fine-tuned to achieve compelling performance.

It does not have any moderation mechanisms. We're looking forward to engaging with the community on ways to

make the model finely respect guardrails, allowing for deployment in environments requiring moderated outputs.

The Mistral AI Team

Albert Jiang, Alexandre Sablayrolles, Alexis Tacnet, Alok Kothari, Antoine Roux, Arthur Mensch, Audrey Herblin-Stoop, Augustin Garreau, Austin Birky, Bam4d, Baptiste Bout, Baudouin de Monicault, Blanche Savary, Carole Rambaud, Caroline Feldman, Devendra Singh Chaplot, Diego de las Casas, Eleonore Arcelin, Emma Bou Hanna, Etienne Metzger, Gaspard Blanchet, Gianna Lengyel, Guillaume Bour, Guillaume Lample, Harizo Rajaona, Henri Roussez, Hichem Sattouf, Ian Mack, Jean-Malo Delignon, Jessica Chudnovsky, Justus Murke, Kartik Khandelwal, Lawrence Stewart, Louis Martin, Louis Ternon, Lucile Saulnier, Lélio Renard Lavaud, Margaret Jennings, Marie Pellat, Marie Torelli, Marie-Anne Lachaux, Marjorie Janiewicz, Mickaël Seznec, Nicolas Schuhl, Niklas Muhs, Olivier de Garrigues, Patrick von Platen, Paul Jacob, Pauline Buche, Pavan Kumar Reddy, Perry Savas, Pierre Stock, Romain Sauvestre, Sagar Vaze, Sandeep Subramanian, Saurabh Garg, Sophia Yang, Szymon Antoniak, Teven Le Scao, Thibault Schueller, Thibaut Lavril, Thomas Wang, Théophile Gervet, Timothée Lacroix, Valera Nemychnikova, Wendy Shang, William El Sayed, William Marshall

Downloads last month 88,390

Chat template

Inference Providers NEW

[...内容已截断,完整版请查看原文或 Wayback 快照]