yujiepan commited on
Commit
f9f7d37
1 Parent(s): b4cf276

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +51 -0
README.md ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pipeline_tag: text-generation
3
+ inference: true
4
+ widget:
5
+ - text: 'Hello!'
6
+ example_title: Hello world
7
+ group: Python
8
+ library_name: transformers
9
+ ---
10
+
11
+ This model is randomly initialized, using the config from [ai21labs/Jamba-v0.1](https://huggingface.co/ai21labs/Jamba-v0.1/blob/main/config.json) but with smaller size.
12
+ Note the model is in float16.
13
+
14
+ Codes:
15
+ ```python
16
+ import transformers
17
+ import torch
18
+ import os
19
+ from huggingface_hub import create_repo, upload_folder
20
+
21
+ source_model_id = 'ai21labs/Jamba-v0.1'
22
+ save_path = '/tmp/yujiepan/jamba-tiny-random'
23
+ repo_id = 'yujiepan/jamba-tiny-random'
24
+
25
+ config = transformers.AutoConfig.from_pretrained(
26
+ source_model_id, trust_remote_code=True)
27
+ config.hidden_size = 4
28
+ config.intermediate_size = 6
29
+ config.num_attention_heads = 4
30
+ config.num_hidden_layers = 16
31
+ config.num_key_value_heads = 2
32
+ config.use_mamba_kernels = False
33
+
34
+ model = transformers.AutoModelForCausalLM.from_config(
35
+ config, trust_remote_code=True)
36
+ model = model.half()
37
+ model.save_pretrained(save_path)
38
+
39
+ tokenizer = transformers.AutoTokenizer.from_pretrained(
40
+ source_model_id, trust_remote_code=True)
41
+ tokenizer.save_pretrained(save_path)
42
+
43
+ result = transformers.pipelines.pipeline(
44
+ 'text-generation',
45
+ model=model.float(), tokenizer=tokenizer)('Hello World!')
46
+ print(result)
47
+
48
+ os.system(f'ls -alh {save_path}')
49
+ create_repo(repo_id, exist_ok=True)
50
+ upload_folder(repo_id=repo_id, folder_path=save_path)
51
+ ```