NeMo
PyTorch
English
nemotron
suhara commited on
Commit
b4d4a52
1 Parent(s): 269ce3f

Initial commit

Browse files
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ nemo/nemotron-mini-4b-instruct.nemo filter=lfs diff=lfs merge=lfs -text
37
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,5 +1,117 @@
1
- ---
2
- license: other
3
- license_name: nvidia-community-model-license
4
- license_link: LICENSE
5
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Nemotron-Mini-4B-Instruct
2
+
3
+ ## Model Overview
4
+
5
+ Nemotron-Mini-4B-Instruct is a model for generating responses for roleplaying, retrieval augmented generation, and function calling. It is a small language model (SLM) optimized through distillation, pruning and quantization for speed and on-device deployment. It is a fine-tuned version of [nvidia/Minitron-4B-Base](https://huggingface.co/nvidia/Minitron-4B-Base), which was pruned and distilled from [Nemotron-4 15B](https://arxiv.org/abs/2402.16819) using [our compression technique](https://arxiv.org/abs/2407.14679). This instruct model is optimized for roleplay, RAG QA, and function calling in English. It supports a context length of 4,096 tokens. This model is ready for commercial use.
6
+
7
+ Try this model on [build.nvidia.com](https://build.nvidia.com/nvidia/nemotron-mini-4b-instruct).
8
+
9
+ For more details about how this model is used for [NVIDIA ACE](https://developer.nvidia.com/ace), please refer to [this blog post](https://developer.nvidia.com/blog/deploy-the-first-on-device-small-language-model-for-improved-game-character-roleplay/) and [this demo video](https://www.youtube.com/watch?v=d5z7oIXhVqg) showcases how the SLM works for gaming use cases. You can also download the model checkpoint for NVIDIA AI Inference Manager (AIM) SDK from [NGC](https://catalog.ngc.nvidia.com/orgs/nvidia/teams/ucs-ms/resources/nemotron-mini-4b-instruct).
10
+
11
+ **Model Developer:** NVIDIA
12
+
13
+ **Model Dates:** Nemotron-Mini-4B-Instruct was trained between February 2024 and Aug 2024.
14
+
15
+ ## License
16
+
17
+ [NVIDIA Community Model License](https://huggingface.co/nvidia/Nemotron-Mini-4B-Instruct/blob/main/nvidia-community-model-license-aug2024.pdf)
18
+
19
+ ## Model Architecture
20
+
21
+ Nemotron-Mini-4B-Instruct uses a model embedding size of 3072, 32 attention heads, and an MLP intermediate dimension of 9216. It also uses Grouped-Query Attention (GQA) and Rotary Position Embeddings (RoPE).
22
+
23
+ **Architecture Type:** Transformer Decoder (auto-regressive language model)
24
+
25
+ **Network Architecture:** Nemotron-4
26
+
27
+
28
+ ## Prompt Format:
29
+
30
+ We recommend using the following prompt template, which was used to fine-tune the model. The model may not perform optimally without it.
31
+
32
+ **Single Turn**
33
+
34
+ ```
35
+ <extra_id_0>System
36
+ {system prompt}
37
+
38
+ <extra_id_1>User
39
+ {prompt}
40
+ <extra_id_1>Assistant\n
41
+ ```
42
+
43
+ **Tool use**
44
+
45
+ ```
46
+ <extra_id_0>System
47
+ {system prompt}
48
+
49
+ <tool> ... </tool>
50
+ <context> ... </context>
51
+
52
+ <extra_id_1>User
53
+ {prompt}
54
+ <extra_id_1>Assistant
55
+ <toolcall> ... </toolcall>
56
+ <extra_id_1>Tool
57
+ {tool response}
58
+ <extra_id_1>Assistant\n
59
+ ```
60
+
61
+
62
+ ## Usage
63
+
64
+ ```
65
+ from transformers import AutoTokenizer, AutoModelForCausalLM
66
+
67
+ # Load the tokenizer and model
68
+ tokenizer = AutoTokenizer.from_pretrained("nvidia/Nemotron-Mini-4B-Instruct")
69
+ model = AutoModelForCausalLM.from_pretrained("nvidia/Nemotron-Mini-4B-Instruct")
70
+
71
+ # Use the prompt template
72
+ messages = [
73
+ {
74
+ "role": "system",
75
+ "content": "You are a friendly chatbot who always responds in the style of a pirate",
76
+ },
77
+ {"role": "user", "content": "How many helicopters can a human eat in one sitting?"},
78
+ ]
79
+ tokenized_chat = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt")
80
+
81
+ outputs = model.generate(tokenized_chat, max_new_tokens=128)
82
+ print(tokenizer.decode(outputs[0]))
83
+ ```
84
+
85
+ You can also use `pipeline` but you need to create a tokenizer object and assign it to the pipeline manually.
86
+
87
+ ```
88
+ from transformers import AutoTokenizer
89
+ from transformers import pipeline
90
+
91
+ tokenizer = AutoTokenizer.from_pretrained("nvidia/Nemotron-Mini-4B-Instruct")
92
+
93
+ messages = [
94
+ {"role": "user", "content": "Who are you?"},
95
+ ]
96
+ pipe = pipeline("text-generation", model="nvidia/Nemotron-Mini-4B-Instruct")
97
+ pipe.tokenizer = tokenizer # You need to assign tokenizer manually
98
+ pipe(messages)
99
+ ```
100
+
101
+ ## AI Safety Efforts
102
+
103
+ The Nemotron-Mini-4B-Instruct model underwent AI safety evaluation including adversarial testing via three distinct methods:
104
+ - [Garak](https://github.com/leondz/garak), is an automated LLM vulnerability scanner that probes for common weaknesses, including prompt injection and data leakage.
105
+ - [AEGIS](https://huggingface.co/datasets/nvidia/Aegis-AI-Content-Safety-Dataset-1.0), is a content safety evaluation dataset and LLM based content safety classifier model, that adheres to a broad taxonomy of 13 categories of critical risks in human-LLM interactions.
106
+ - Human Content Red Teaming leveraging human interaction and evaluation of the models' responses.
107
+
108
+
109
+ ## Limitations
110
+
111
+ The model was trained on data that contains toxic language and societal biases originally crawled from the internet. Therefore, the model may amplify those biases and return toxic responses especially when prompted with toxic prompts. The model may generate answers that may be inaccurate, omit key information, or include irrelevant or redundant text producing socially unacceptable or undesirable text, even if the prompt itself does not include anything explicitly offensive. This issue could be exacerbated without the use of the recommended prompt template. This issue could be exacerbated without the use of the recommended prompt template.
112
+
113
+
114
+ ## Ethical Considerations
115
+
116
+ NVIDIA believes Trustworthy AI is a shared responsibility and we have established policies and practices to enable development for a wide array of AI applications. When downloaded or used in accordance with our terms of service, developers should work with their internal model team to ensure this model meets requirements for the relevant industry and use case and addresses unforeseen product misuse. For more detailed information on ethical considerations for this model, please see the [Model Card++](https://build.nvidia.com/nvidia/nemotron-mini-4b-instruct/modelcard). Please report security vulnerabilities or NVIDIA AI Concerns [here](https://www.nvidia.com/en-us/support/submit-security-vulnerability/).
117
+
config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "nvidia/Minitron-4B-Instruct",
3
+ "architectures": [
4
+ "NemotronForCausalLM"
5
+ ],
6
+ "bos_token_id": 2,
7
+ "eos_token_id": 3,
8
+ "hidden_act": "relu2",
9
+ "hidden_size": 3072,
10
+ "initializer_range": 0.0134,
11
+ "intermediate_size": 9216,
12
+ "max_position_embeddings": 4096,
13
+ "model_type": "nemotron",
14
+ "num_attention_heads": 24,
15
+ "num_hidden_layers": 32,
16
+ "num_key_value_heads": 8,
17
+ "norm_eps": 1e-05,
18
+ "rope_theta": 10000,
19
+ "partial_rotary_factor": 0.5,
20
+ "tie_word_embeddings": false,
21
+ "torch_dtype": "bfloat16",
22
+ "transformers_version": "4.32.0.dev0",
23
+ "use_cache": true,
24
+ "vocab_size": 256000,
25
+ "kv_channels": 128
26
+ }
nemo/nemotron-mini-4b-instruct.nemo ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:70be3d47b3c1eb1a239c077367a7c5088f165311b0fdbc9732ebff08ccfe2b65
3
+ size 8386488320
nvidia-community-model-license-aug2024.pdf ADDED
Binary file (146 kB). View file
 
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e851a12d65d56e90ed99659e7439f2b5fc080db478500ee3390f809131426854
3
+ size 8381129342
special_tokens_map.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "bos_token": "<s>",
3
+ "eos_token": "</s>"
4
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:83d0648daa0467fb02ddef7ff25460321dab2fbb20c280ae0bc1ea8052f7df90
3
+ size 18143149
tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6dfd8b970f437002fc445214304969fe59e64d4f48500bd0b77ba55340f2d811
3
+ size 4545602
tokenizer_config.json ADDED
The diff for this file is too large to render. See raw diff