yujiepan commited on
Commit
11801d1
·
verified ·
1 Parent(s): 209f8df

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ pipeline_tag: text-generation
4
+ inference: true
5
+ widget:
6
+ - text: Hello!
7
+ example_title: Hello world
8
+ group: Python
9
+ ---
10
+
11
+ This model is for debugging. It is randomly initialized using the config from [mistralai/Mistral-Nemo-Instruct-2407](https://huggingface.co/mistralai/Mistral-Nemo-Instruct-2407) but with smaller size.
12
+
13
+ Codes:
14
+ ```python
15
+ from transformers import pipeline
16
+ from huggingface_hub import create_repo, upload_folder
17
+ import torch
18
+ import transformers
19
+ import os
20
+
21
+ model_id = 'mistralai/Mistral-Nemo-Instruct-2407'
22
+ repo_id = 'yujiepan/mistral-nemo-2407-tiny-random'
23
+ save_path = f'/tmp/{repo_id}'
24
+
25
+ config = transformers.AutoConfig.from_pretrained(model_id)
26
+ config.hidden_size = 8
27
+ config.intermediate_size = 32
28
+ config.num_attention_heads = 4
29
+ config.num_hidden_layers = 2
30
+ config.num_key_value_heads = 2
31
+ config.head_dim = 2
32
+ print(config)
33
+
34
+ tokenizer = transformers.AutoTokenizer.from_pretrained(model_id)
35
+ tokenizer.save_pretrained(save_path)
36
+
37
+ model = transformers.AutoModelForCausalLM.from_config(config, torch_dtype=torch.bfloat16)
38
+ model.generation_config = transformers.GenerationConfig.from_pretrained(model_id)
39
+
40
+ transformers.set_seed(42)
41
+ with torch.no_grad():
42
+ for _, p in sorted(model.named_parameters()):
43
+ torch.nn.init.uniform_(p, -0.1, 0.1)
44
+
45
+ pipe = pipeline('text-generation', model=model, tokenizer=tokenizer, do_sample=False, device='cuda')
46
+ print(pipe('Hello World!'))
47
+
48
+ messages = [
49
+ {"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
50
+ {"role": "user", "content": "Who are you?"},
51
+ ]
52
+ chatbot = pipeline("text-generation", model=save_path, max_length=1000, max_new_tokens=16)
53
+ print(chatbot(messages))
54
+
55
+ model.save_pretrained(save_path)
56
+ ```
config.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "mistralai/Mistral-Nemo-Instruct-2407",
3
+ "architectures": [
4
+ "MistralForCausalLM"
5
+ ],
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 1,
8
+ "eos_token_id": 2,
9
+ "head_dim": 2,
10
+ "hidden_act": "silu",
11
+ "hidden_size": 8,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 32,
14
+ "max_position_embeddings": 1024000,
15
+ "model_type": "mistral",
16
+ "num_attention_heads": 4,
17
+ "num_hidden_layers": 2,
18
+ "num_key_value_heads": 2,
19
+ "rms_norm_eps": 1e-05,
20
+ "rope_theta": 1000000.0,
21
+ "sliding_window": null,
22
+ "tie_word_embeddings": false,
23
+ "torch_dtype": "bfloat16",
24
+ "transformers_version": "4.43.0.dev0",
25
+ "use_cache": true,
26
+ "vocab_size": 131072
27
+ }
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 2,
5
+ "transformers_version": "4.43.0.dev0"
6
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f62ca92cd05e9be1e4622b8a686c078cdb83e213eb164f95509fa528ca8aa637
3
+ size 4200408
special_tokens_map.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "</s>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "unk_token": {
17
+ "content": "<unk>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ }
23
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
The diff for this file is too large to render. See raw diff