zRzRzRzRzRzRzR
commited on
Commit
·
e48a104
1
Parent(s):
542476c
z1-9b
Browse files- .gitattributes +1 -0
- LICENSE +21 -0
- README.md +44 -1
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ 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 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
MIT License
|
2 |
+
|
3 |
+
Copyright (c) 2025 zAI
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
+
of this software and associated documentation files (the "Software"), to deal
|
7 |
+
in the Software without restriction, including without limitation the rights
|
8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
+
copies of the Software, and to permit persons to whom the Software is
|
10 |
+
furnished to do so, subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in all
|
13 |
+
copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 |
+
SOFTWARE.
|
README.md
CHANGED
@@ -5,4 +5,47 @@ language:
|
|
5 |
- en
|
6 |
pipeline_tag: text-generation
|
7 |
library_name: transformers
|
8 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
- en
|
6 |
pipeline_tag: text-generation
|
7 |
library_name: transformers
|
8 |
+
---
|
9 |
+
|
10 |
+
# GLM-4-Z1-9B-0414
|
11 |
+
|
12 |
+
## Introduction
|
13 |
+
|
14 |
+
Based on our latest technological advancements, we have trained a `GLM-4-0414` series model. During pretraining, we incorporated more code-related and reasoning-related data. In the alignment phase, we optimized the model specifically for agent capabilities. As a result, the model's performance in agent tasks such as tool use, web search, and coding has been significantly improved.
|
15 |
+
|
16 |
+
## Installation
|
17 |
+
|
18 |
+
Install the transformers library from the source code:
|
19 |
+
|
20 |
+
```shell
|
21 |
+
pip install git+https://github.com/huggingface/transformers.git
|
22 |
+
```
|
23 |
+
|
24 |
+
## Inference Code
|
25 |
+
|
26 |
+
```python
|
27 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
28 |
+
|
29 |
+
MODEL_PATH = "THUDM/GLM-4-Z1-9B-0414"
|
30 |
+
|
31 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
|
32 |
+
model = AutoModelForCausalLM.from_pretrained(MODEL_PATH, device_map="auto")
|
33 |
+
|
34 |
+
message = [{"role": "user", "content": "Let a, b be positive real numbers such that ab = a + b + 3. Determine the range of possible values for a + b."}]
|
35 |
+
|
36 |
+
inputs = tokenizer.apply_chat_template(
|
37 |
+
message,
|
38 |
+
return_tensors="pt",
|
39 |
+
add_generation_prompt=True,
|
40 |
+
return_dict=True,
|
41 |
+
).to(model.device)
|
42 |
+
|
43 |
+
generate_kwargs = {
|
44 |
+
"input_ids": inputs["input_ids"],
|
45 |
+
"attention_mask": inputs["attention_mask"],
|
46 |
+
"max_new_tokens": 4096,
|
47 |
+
"do_sample": False,
|
48 |
+
}
|
49 |
+
out = model.generate(**generate_kwargs)
|
50 |
+
print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
|
51 |
+
```
|