Xiaowen-dg's picture
Upload README.md with huggingface_hub
930d2e8 verified
metadata
base_model: mistralai/Mistral-Nemo-Base-2407
language:
  - en
  - fr
  - de
  - es
  - it
  - pt
  - ru
  - zh
  - ja
license: apache-2.0
extra_gated_description: >-
  If you want to learn more about how we process your personal data, please read
  our <a href="https://mistral.ai/terms/">Privacy Policy</a>.
model-index:
  - name: Mistral-Nemo-Instruct-2407
    results:
      - task:
          type: squad_answerable-judge
        dataset:
          name: squad_answerable
          type: multi-choices
        metrics:
          - type: judge_match
            value: '0.685'
            args:
              results:
                squad_answerable-judge:
                  exact_match,strict_match: 0.6852522530110334
                  exact_match_stderr,strict_match: 0.004262305820311226
                  alias: squad_answerable-judge
                context_has_answer-judge:
                  exact_match,strict_match: 0.7906976744186046
                  exact_match_stderr,strict_match: 0.04412480456048906
                  alias: context_has_answer-judge
              group_subtasks:
                context_has_answer-judge: []
                squad_answerable-judge: []
              configs:
                context_has_answer-judge:
                  task: context_has_answer-judge
                  group: dg
                  dataset_path: DataGuard/eval-multi-choices
                  dataset_name: context_has_answer_judge
                  test_split: test
                  doc_to_text: >-
                    <s>[INST]You are asked to determine if a question has the
                    answer in the context, and answer with a simple Yes or No.


                    Example:

                    Question: How is the weather today? Context: How is the
                    traffic today? It is horrible. Does the question have the
                    answer in the Context?

                    Answer: No

                    Question: How is the weather today? Context: Is the weather
                    good today? Yes, it is sunny. Does the question have the
                    answer in the Context?

                    Answer: Yes


                    Question: {{question}}

                    Context: {{similar_question}} {{similar_answer}}

                    Does the question have the answer in the Context?

                    [/INST]
                  doc_to_target: '{{''Yes'' if is_relevant in [''Yes'', 1] else ''No''}}'
                  description: ''
                  target_delimiter: ' '
                  fewshot_delimiter: |+


                  metric_list:
                    - metric: exact_match
                  output_type: generate_until
                  generation_kwargs:
                    until:
                      - <|im_end|>
                    do_sample: false
                    temperature: 0.3
                  repeats: 1
                  filter_list:
                    - name: strict_match
                      filter:
                        - function: regex
                          regex_pattern: Yes|No
                          group_select: -1
                        - function: take_first
                  should_decontaminate: false
                squad_answerable-judge:
                  task: squad_answerable-judge
                  group: dg
                  dataset_path: DataGuard/eval-multi-choices
                  dataset_name: squad_answerable_judge
                  test_split: test
                  doc_to_text: >-
                    <s>[INST]You are asked to determine if a question has the
                    answer in the context, and answer with a simple Yes or No.


                    Example:

                    Question: How is the weather today? Context: The traffic is
                    horrible. Does the question have the answer in the Context?

                    Answer: No

                    Question: How is the weather today? Context: The weather is
                    good. Does the question have the answer in the Context?

                    Answer: Yes


                    Question: {{question}}

                    Context: {{context}}

                    Does the question have the answer in the Context?

                    [/INST]
                  doc_to_target: '{{''Yes'' if is_relevant in [''Yes'', 1] else ''No''}}'
                  description: ''
                  target_delimiter: ' '
                  fewshot_delimiter: |+


                  metric_list:
                    - metric: exact_match
                  output_type: generate_until
                  generation_kwargs:
                    until:
                      - <|im_end|>
                    do_sample: false
                    temperature: 0.3
                  repeats: 1
                  filter_list:
                    - name: strict_match
                      filter:
                        - function: regex
                          regex_pattern: Yes|No
                          group_select: -1
                        - function: take_first
                  should_decontaminate: false
              versions:
                context_has_answer-judge: Yaml
                squad_answerable-judge: Yaml
              n-shot: {}
              config:
                model: vllm
                model_args: >-
                  pretrained=mistralai/Mistral-Nemo-Instruct-2407,tensor_parallel_size=1,dtype=auto,gpu_memory_utilization=0.8,max_model_len=2048,trust_remote_code=True
                batch_size: auto
                batch_sizes: []
                bootstrap_iters: 100000
              git_hash: cddf85d
              pretty_env_info: >-
                PyTorch version: 2.4.0+cu121

                Is debug build: False

                CUDA used to build PyTorch: 12.1

                ROCM used to build PyTorch: N/A


                OS: Ubuntu 22.04.3 LTS (x86_64)

                GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

                Clang version: Could not collect

                CMake version: version 3.25.0

                Libc version: glibc-2.35


                Python version: 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC
                11.4.0] (64-bit runtime)

                Python platform: Linux-5.4.0-149-generic-x86_64-with-glibc2.35

                Is CUDA available: True

                CUDA runtime version: 11.8.89

                CUDA_MODULE_LOADING set to: LAZY

                GPU models and configuration: GPU 0: NVIDIA L40

                Nvidia driver version: 535.54.03

                cuDNN version: Could not collect

                HIP runtime version: N/A

                MIOpen runtime version: N/A

                Is XNNPACK available: True


                CPU:

                Architecture:                    x86_64

                CPU op-mode(s):                  32-bit, 64-bit

                Address sizes:                   48 bits physical, 48 bits
                virtual

                Byte Order:                      Little Endian

                CPU(s):                          256

                On-line CPU(s) list:             0-254

                Off-line CPU(s) list:            255

                Vendor ID:                       AuthenticAMD

                Model name:                      AMD EPYC 7773X 64-Core
                Processor

                CPU family:                      25

                Model:                           1

                Thread(s) per core:              2

                Core(s) per socket:              64

                Socket(s):                       2

                Stepping:                        2

                Frequency boost:                 enabled

                CPU max MHz:                     2200.0000

                CPU min MHz:                     0.0000

                BogoMIPS:                        4400.14

                Flags:                           fpu vme de pse tsc msr pae mce
                cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse
                sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm
                constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid
                aperfmperf pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1
                sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm
                cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse
                3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core
                perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3
                invpcid_single hw_pstate ssbd mba ibrs ibpb stibp vmmcall
                fsgsbase bmi1 avx2 smep bmi2 invpcid cqm rdt_a rdseed adx smap
                clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_llc
                cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf
                xsaveerptr wbnoinvd arat npt lbrv svm_lock nrip_save tsc_scale
                vmcb_clean flushbyasid decodeassists pausefilter pfthreshold
                v_vmsave_vmload vgif umip pku ospke vaes vpclmulqdq rdpid
                overflow_recov succor smca

                Virtualization:                  AMD-V

                L1d cache:                       4 MiB (128 instances)

                L1i cache:                       4 MiB (128 instances)

                L2 cache:                        64 MiB (128 instances)

                L3 cache:                        1.5 GiB (16 instances)

                NUMA node(s):                    16

                NUMA node0 CPU(s):               0-7,128-135

                NUMA node1 CPU(s):               8-15,136-143

                NUMA node2 CPU(s):               16-23,144-151

                NUMA node3 CPU(s):               24-31,152-159

                NUMA node4 CPU(s):               32-39,160-167

                NUMA node5 CPU(s):               40-47,168-175

                NUMA node6 CPU(s):               48-55,176-183

                NUMA node7 CPU(s):               56-63,184-191

                NUMA node8 CPU(s):               64-71,192-199

                NUMA node9 CPU(s):               72-79,200-207

                NUMA node10 CPU(s):              80-87,208-215

                NUMA node11 CPU(s):              88-95,216-223

                NUMA node12 CPU(s):              96-103,224-231

                NUMA node13 CPU(s):              104-111,232-239

                NUMA node14 CPU(s):              112-119,240-247

                NUMA node15 CPU(s):              120-127,248-254

                Vulnerability Itlb multihit:     Not affected

                Vulnerability L1tf:              Not affected

                Vulnerability Mds:               Not affected

                Vulnerability Meltdown:          Not affected

                Vulnerability Mmio stale data:   Not affected

                Vulnerability Retbleed:          Not affected

                Vulnerability Spec store bypass: Mitigation; Speculative Store
                Bypass disabled via prctl and seccomp

                Vulnerability Spectre v1:        Mitigation; usercopy/swapgs
                barriers and __user pointer sanitization

                Vulnerability Spectre v2:        Mitigation; Retpolines, IBPB
                conditional, IBRS_FW, STIBP always-on, RSB filling, PBRSB-eIBRS
                Not affected

                Vulnerability Srbds:             Not affected

                Vulnerability Tsx async abort:   Not affected


                Versions of relevant libraries:

                [pip3] numpy==1.24.1

                [pip3] torch==2.4.0

                [pip3] torchaudio==2.0.2+cu118

                [pip3] torchvision==0.19.0

                [pip3] triton==3.0.0

                [conda] Could not collect
              transformers_version: 4.44.1
      - task:
          type: context_has_answer-judge
        dataset:
          name: context_has_answer
          type: multi-choices
        metrics:
          - type: judge_match
            value: '0.791'
            args:
              results:
                squad_answerable-judge:
                  exact_match,strict_match: 0.6852522530110334
                  exact_match_stderr,strict_match: 0.004262305820311226
                  alias: squad_answerable-judge
                context_has_answer-judge:
                  exact_match,strict_match: 0.7906976744186046
                  exact_match_stderr,strict_match: 0.04412480456048906
                  alias: context_has_answer-judge
              group_subtasks:
                context_has_answer-judge: []
                squad_answerable-judge: []
              configs:
                context_has_answer-judge:
                  task: context_has_answer-judge
                  group: dg
                  dataset_path: DataGuard/eval-multi-choices
                  dataset_name: context_has_answer_judge
                  test_split: test
                  doc_to_text: >-
                    <s>[INST]You are asked to determine if a question has the
                    answer in the context, and answer with a simple Yes or No.


                    Example:

                    Question: How is the weather today? Context: How is the
                    traffic today? It is horrible. Does the question have the
                    answer in the Context?

                    Answer: No

                    Question: How is the weather today? Context: Is the weather
                    good today? Yes, it is sunny. Does the question have the
                    answer in the Context?

                    Answer: Yes


                    Question: {{question}}

                    Context: {{similar_question}} {{similar_answer}}

                    Does the question have the answer in the Context?

                    [/INST]
                  doc_to_target: '{{''Yes'' if is_relevant in [''Yes'', 1] else ''No''}}'
                  description: ''
                  target_delimiter: ' '
                  fewshot_delimiter: |+


                  metric_list:
                    - metric: exact_match
                  output_type: generate_until
                  generation_kwargs:
                    until:
                      - <|im_end|>
                    do_sample: false
                    temperature: 0.3
                  repeats: 1
                  filter_list:
                    - name: strict_match
                      filter:
                        - function: regex
                          regex_pattern: Yes|No
                          group_select: -1
                        - function: take_first
                  should_decontaminate: false
                squad_answerable-judge:
                  task: squad_answerable-judge
                  group: dg
                  dataset_path: DataGuard/eval-multi-choices
                  dataset_name: squad_answerable_judge
                  test_split: test
                  doc_to_text: >-
                    <s>[INST]You are asked to determine if a question has the
                    answer in the context, and answer with a simple Yes or No.


                    Example:

                    Question: How is the weather today? Context: The traffic is
                    horrible. Does the question have the answer in the Context?

                    Answer: No

                    Question: How is the weather today? Context: The weather is
                    good. Does the question have the answer in the Context?

                    Answer: Yes


                    Question: {{question}}

                    Context: {{context}}

                    Does the question have the answer in the Context?

                    [/INST]
                  doc_to_target: '{{''Yes'' if is_relevant in [''Yes'', 1] else ''No''}}'
                  description: ''
                  target_delimiter: ' '
                  fewshot_delimiter: |+


                  metric_list:
                    - metric: exact_match
                  output_type: generate_until
                  generation_kwargs:
                    until:
                      - <|im_end|>
                    do_sample: false
                    temperature: 0.3
                  repeats: 1
                  filter_list:
                    - name: strict_match
                      filter:
                        - function: regex
                          regex_pattern: Yes|No
                          group_select: -1
                        - function: take_first
                  should_decontaminate: false
              versions:
                context_has_answer-judge: Yaml
                squad_answerable-judge: Yaml
              n-shot: {}
              config:
                model: vllm
                model_args: >-
                  pretrained=mistralai/Mistral-Nemo-Instruct-2407,tensor_parallel_size=1,dtype=auto,gpu_memory_utilization=0.8,max_model_len=2048,trust_remote_code=True
                batch_size: auto
                batch_sizes: []
                bootstrap_iters: 100000
              git_hash: cddf85d
              pretty_env_info: >-
                PyTorch version: 2.4.0+cu121

                Is debug build: False

                CUDA used to build PyTorch: 12.1

                ROCM used to build PyTorch: N/A


                OS: Ubuntu 22.04.3 LTS (x86_64)

                GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

                Clang version: Could not collect

                CMake version: version 3.25.0

                Libc version: glibc-2.35


                Python version: 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC
                11.4.0] (64-bit runtime)

                Python platform: Linux-5.4.0-149-generic-x86_64-with-glibc2.35

                Is CUDA available: True

                CUDA runtime version: 11.8.89

                CUDA_MODULE_LOADING set to: LAZY

                GPU models and configuration: GPU 0: NVIDIA L40

                Nvidia driver version: 535.54.03

                cuDNN version: Could not collect

                HIP runtime version: N/A

                MIOpen runtime version: N/A

                Is XNNPACK available: True


                CPU:

                Architecture:                    x86_64

                CPU op-mode(s):                  32-bit, 64-bit

                Address sizes:                   48 bits physical, 48 bits
                virtual

                Byte Order:                      Little Endian

                CPU(s):                          256

                On-line CPU(s) list:             0-254

                Off-line CPU(s) list:            255

                Vendor ID:                       AuthenticAMD

                Model name:                      AMD EPYC 7773X 64-Core
                Processor

                CPU family:                      25

                Model:                           1

                Thread(s) per core:              2

                Core(s) per socket:              64

                Socket(s):                       2

                Stepping:                        2

                Frequency boost:                 enabled

                CPU max MHz:                     2200.0000

                CPU min MHz:                     0.0000

                BogoMIPS:                        4400.14

                Flags:                           fpu vme de pse tsc msr pae mce
                cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse
                sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm
                constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid
                aperfmperf pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1
                sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm
                cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse
                3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core
                perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3
                invpcid_single hw_pstate ssbd mba ibrs ibpb stibp vmmcall
                fsgsbase bmi1 avx2 smep bmi2 invpcid cqm rdt_a rdseed adx smap
                clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_llc
                cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf
                xsaveerptr wbnoinvd arat npt lbrv svm_lock nrip_save tsc_scale
                vmcb_clean flushbyasid decodeassists pausefilter pfthreshold
                v_vmsave_vmload vgif umip pku ospke vaes vpclmulqdq rdpid
                overflow_recov succor smca

                Virtualization:                  AMD-V

                L1d cache:                       4 MiB (128 instances)

                L1i cache:                       4 MiB (128 instances)

                L2 cache:                        64 MiB (128 instances)

                L3 cache:                        1.5 GiB (16 instances)

                NUMA node(s):                    16

                NUMA node0 CPU(s):               0-7,128-135

                NUMA node1 CPU(s):               8-15,136-143

                NUMA node2 CPU(s):               16-23,144-151

                NUMA node3 CPU(s):               24-31,152-159

                NUMA node4 CPU(s):               32-39,160-167

                NUMA node5 CPU(s):               40-47,168-175

                NUMA node6 CPU(s):               48-55,176-183

                NUMA node7 CPU(s):               56-63,184-191

                NUMA node8 CPU(s):               64-71,192-199

                NUMA node9 CPU(s):               72-79,200-207

                NUMA node10 CPU(s):              80-87,208-215

                NUMA node11 CPU(s):              88-95,216-223

                NUMA node12 CPU(s):              96-103,224-231

                NUMA node13 CPU(s):              104-111,232-239

                NUMA node14 CPU(s):              112-119,240-247

                NUMA node15 CPU(s):              120-127,248-254

                Vulnerability Itlb multihit:     Not affected

                Vulnerability L1tf:              Not affected

                Vulnerability Mds:               Not affected

                Vulnerability Meltdown:          Not affected

                Vulnerability Mmio stale data:   Not affected

                Vulnerability Retbleed:          Not affected

                Vulnerability Spec store bypass: Mitigation; Speculative Store
                Bypass disabled via prctl and seccomp

                Vulnerability Spectre v1:        Mitigation; usercopy/swapgs
                barriers and __user pointer sanitization

                Vulnerability Spectre v2:        Mitigation; Retpolines, IBPB
                conditional, IBRS_FW, STIBP always-on, RSB filling, PBRSB-eIBRS
                Not affected

                Vulnerability Srbds:             Not affected

                Vulnerability Tsx async abort:   Not affected


                Versions of relevant libraries:

                [pip3] numpy==1.24.1

                [pip3] torch==2.4.0

                [pip3] torchaudio==2.0.2+cu118

                [pip3] torchvision==0.19.0

                [pip3] triton==3.0.0

                [conda] Could not collect
              transformers_version: 4.44.1

Needle in a Haystack Evaluation Heatmap

Needle in a Haystack Evaluation Heatmap EN

Needle in a Haystack Evaluation Heatmap DE

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:

  • Layers: 40
  • Dim: 5,120
  • 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)

Metrics

Main Benchmarks

Benchmark Score
HellaSwag (0-shot) 83.5%
Winogrande (0-shot) 76.8%
OpenBookQA (0-shot) 60.6%
CommonSenseQA (0-shot) 70.4%
TruthfulQA (0-shot) 50.3%
MMLU (5-shot) 68.0%
TriviaQA (5-shot) 73.8%
NaturalQuestions (5-shot) 31.2%

Multilingual Benchmarks (MMLU)

Language Score
French 62.3%
German 62.7%
Spanish 64.6%
Italian 61.3%
Portuguese 63.3%
Russian 59.2%
Chinese 59.0%
Japanese 59.0%

Usage

The model can be used with three different frameworks

Mistral Inference

Install

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

Download

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)

Chat

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
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)

completion_request = ChatCompletionRequest(
    tools=[
        Tool(
            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",
                        },
                        "format": {
                            "type": "string",
                            "enum": ["celsius", "fahrenheit"],
                            "description": "The temperature unit to use. Infer this from the users location.",
                        },
                    },
                    "required": ["location", "format"],
                },
            )
        )
    ],
    messages=[
        UserMessage(content="What's the weather like today in Paris?"),
        ],
)

tokens = tokenizer.encode_chat_completion(completion_request).tokens

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

print(result)

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

    Args:
        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"])
    """
    pass

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.

Limitations

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