Download app.py from long1111/chatglm: direct link, hf CLI and curl.
- Browser
- Download file 428 Bytes
-
https://huggingface.co/spaces/long1111/chatglm/resolve/main/app.py
- Command line
-
hf download hf://spaces/long1111/chatglm/app.py
-
curl -L -o app.py https://huggingface.co/spaces/long1111/chatglm/resolve/main/app.py
428 Bytes
| from transformers import AutoTokenizer, AutoModel | |
| tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True) | |
| model = AutoModel.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True).half().quantize(4).cuda() | |
| response, history = model.chat(tokenizer, "你好", history=[]) | |
| print(response) | |
| response, history = model.chat(tokenizer, "晚上睡不着应该怎么办", history=history) | |
| print(response) |