yujiepan commited on
Commit
6d90fef
1 Parent(s): 69e082e

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/mathstral-7B-v0.1](https://huggingface.co/mistralai/mathstral-7B-v0.1) but with smaller size.
12
+
13
+ Codes:
14
+ ```python
15
+ from huggingface_hub import create_repo, upload_folder
16
+ from transformers import (
17
+ pipeline,
18
+ set_seed,
19
+ AutoConfig,
20
+ AutoModelForCausalLM,
21
+ AutoTokenizer,
22
+ GenerationConfig,
23
+ )
24
+ import torch
25
+ import transformers
26
+ import os
27
+
28
+ model_id = "mistralai/mathstral-7B-v0.1"
29
+ repo_id = "yujiepan/mathstral-v0.1-tiny-random"
30
+ save_path = f"/tmp/{repo_id}"
31
+
32
+ config = AutoConfig.from_pretrained(model_id)
33
+ config.hidden_size = 8
34
+ config.intermediate_size = 32
35
+ config.num_attention_heads = 4
36
+ config.num_hidden_layers = 2
37
+ config.num_key_value_heads = 2
38
+ config.head_dim = 2
39
+ print(config)
40
+
41
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
42
+ tokenizer.save_pretrained(save_path)
43
+
44
+ model = AutoModelForCausalLM.from_config(config, torch_dtype=torch.bfloat16)
45
+ model.generation_config = GenerationConfig.from_pretrained(model_id)
46
+
47
+ set_seed(42)
48
+ with torch.no_grad():
49
+ for _, p in sorted(model.named_parameters()):
50
+ torch.nn.init.uniform_(p, -0.1, 0.1)
51
+
52
+ model.save_pretrained(save_path)
53
+
54
+ pipe = pipeline("text-generation", model=model, tokenizer=tokenizer, do_sample=False, device="cuda")
55
+ print(pipe("Hello World!"))
56
+
57
+ messages = [
58
+ {"role": "system", "content": "You are a robot."},
59
+ {"role": "user", "content": "Hi!"},
60
+ ]
61
+ chatbot = pipeline("text-generation", model=save_path, max_length=1000, max_new_tokens=16)
62
+ print(chatbot(messages))
63
+ ```
config.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "mistralai/mathstral-7B-v0.1",
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": 32768,
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": 32768
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:889ed1d5d4ad3c6a1a204b49dcf13c9980147a1c31fdff08ebd455171e4b41d1
3
+ size 1054672
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.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:59f95e28944c062244741268596badc900df86c7f5ded05088d2da22a7379e06
3
+ size 587583
tokenizer_config.json ADDED
The diff for this file is too large to render. See raw diff