Instructions to use BAAI/AquilaChat-7B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use BAAI/AquilaChat-7B with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("BAAI/AquilaChat-7B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download chat_test.py from BAAI/AquilaChat-7B: direct link, hf CLI and curl.
- Browser
- Download file 843 Bytes
-
https://huggingface.co/BAAI/AquilaChat-7B/resolve/3d19935326b8420dcddd3796dca53824c55b97f9/chat_test.py
- Command line
-
hf download hf://BAAI/AquilaChat-7B@3d19935326b8420dcddd3796dca53824c55b97f9/chat_test.py
-
curl -L -o chat_test.py https://huggingface.co/BAAI/AquilaChat-7B/resolve/3d19935326b8420dcddd3796dca53824c55b97f9/chat_test.py
843 Bytes
| #If you need to use this code, please install the following transformers | |
| #https://github.com/shunxing1234/transformers | |
| from transformers import AutoTokenizer, AquilaForCausalLM | |
| import torch | |
| from cyg_conversation import default_conversation, covert_prompt_to_input_ids_with_history | |
| tokenizer = AutoTokenizer.from_pretrained("BAAI/AquilaChat-7B") | |
| model = AquilaForCausalLM.from_pretrained("BAAI/AquilaChat-7B") | |
| model.eval() | |
| model.to("cuda:4") | |
| vocab = tokenizer.vocab | |
| print(len(vocab)) | |
| text = "请给出10个要到北京旅游的理由。" | |
| tokens = covert_prompt_to_input_ids_with_history(text, history=[], tokenizer=tokenizer, max_token=512) | |
| tokens = torch.tensor(tokens)[None,].to("cuda:4") | |
| out = model.generate(tokens, do_sample=True, max_length=512, eos_token_id=100007)[0] | |
| out = tokenizer.decode(out.cpu().numpy().tolist()) | |
| print(out) | |