Modify to original glm-4-9b code
Browse files
README.md
CHANGED
@@ -28,20 +28,10 @@ tokenizer = AutoTokenizer.from_pretrained("THUDM/LongWriter-glm4-9b", trust_remo
|
|
28 |
model = AutoModelForCausalLM.from_pretrained("THUDM/LongWriter-glm4-9b", torch_dtype=torch.bfloat16, trust_remote_code=True, device_map="auto")
|
29 |
model = model.eval()
|
30 |
query = "Write a 10000-word China travel guide"
|
31 |
-
|
32 |
-
input = tokenizer(prompt, truncation=False, return_tensors="pt").to(device)
|
33 |
-
context_length = input.input_ids.shape[-1]
|
34 |
-
output = model.generate(
|
35 |
-
**input,
|
36 |
-
max_new_tokens=32768,
|
37 |
-
num_beams=1,
|
38 |
-
do_sample=True,
|
39 |
-
temperature=0.5,
|
40 |
-
)[0]
|
41 |
-
response = tokenizer.decode(output[context_length:], skip_special_tokens=True)
|
42 |
print(response)
|
43 |
```
|
44 |
-
Environment: `
|
45 |
|
46 |
License: [glm-4-9b License](https://huggingface.co/THUDM/glm-4-9b-chat/blob/main/LICENSE)
|
47 |
|
|
|
28 |
model = AutoModelForCausalLM.from_pretrained("THUDM/LongWriter-glm4-9b", torch_dtype=torch.bfloat16, trust_remote_code=True, device_map="auto")
|
29 |
model = model.eval()
|
30 |
query = "Write a 10000-word China travel guide"
|
31 |
+
response, history = model.chat(tokenizer, query, history=[], max_new_tokens=32768, temperature=0.5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
print(response)
|
33 |
```
|
34 |
+
Environment: Same environment requirement as [glm-4-9b-chat](https://huggingface.co/THUDM/glm-4-9b-chat) (`transforemrs>=4.44.0`).
|
35 |
|
36 |
License: [glm-4-9b License](https://huggingface.co/THUDM/glm-4-9b-chat/blob/main/LICENSE)
|
37 |
|