Instructions to use INX-TEXT/Bailong-instruct-7B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use INX-TEXT/Bailong-instruct-7B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="INX-TEXT/Bailong-instruct-7B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("INX-TEXT/Bailong-instruct-7B") model = AutoModelForCausalLM.from_pretrained("INX-TEXT/Bailong-instruct-7B", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use INX-TEXT/Bailong-instruct-7B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "INX-TEXT/Bailong-instruct-7B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "INX-TEXT/Bailong-instruct-7B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/INX-TEXT/Bailong-instruct-7B
- SGLang
How to use INX-TEXT/Bailong-instruct-7B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "INX-TEXT/Bailong-instruct-7B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "INX-TEXT/Bailong-instruct-7B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "INX-TEXT/Bailong-instruct-7B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "INX-TEXT/Bailong-instruct-7B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use INX-TEXT/Bailong-instruct-7B with Docker Model Runner:
docker model run hf.co/INX-TEXT/Bailong-instruct-7B
使用 AutoTokenizer 出現錯誤
#2
by OwenLegalSign - opened
我嘗試使用 AutoTokenzier, 但遇到以下的錯誤
docker-llm-1 | File "/app/app.py", line 15, in load_model
docker-llm-1 | tokenizer = AutoTokenizer.from_pretrained("INX-TEXT/Bailong-instruct-7B")
docker-llm-1 | File "/usr/local/lib/python3.10/dist-packages/transformers/models/auto/tokenization_auto.py", line 814, in from_pretrained
docker-llm-1 | return tokenizer_class.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs)
docker-llm-1 | File "/usr/local/lib/python3.10/dist-packages/transformers/tokenization_utils_base.py", line 2029, in from_pretrained
docker-llm-1 | return cls._from_pretrained(
docker-llm-1 | File "/usr/local/lib/python3.10/dist-packages/transformers/tokenization_utils_base.py", line 2261, in _from_pretrained
docker-llm-1 | tokenizer = cls(*init_inputs, **init_kwargs)
docker-llm-1 | File "/usr/local/lib/python3.10/dist-packages/transformers/models/llama/tokenization_llama_fast.py", line 124, in __init__
docker-llm-1 | super().__init__(
docker-llm-1 | File "/usr/local/lib/python3.10/dist-packages/transformers/tokenization_utils_fast.py", line 120, in __init__
docker-llm-1 | raise ValueError(
docker-llm-1 | ValueError: Couldn't instantiate the backend tokenizer from one of:
docker-llm-1 | (1) a `tokenizers` library serialization file,
docker-llm-1 | (2) a slow tokenizer instance to convert or
docker-llm-1 | (3) an equivalent slow tokenizer class to instantiate and convert.
docker-llm-1 | You need to have sentencepiece installed to convert a slow tokenizer to a fast one.
我的 transformer=4.37.2 想請問上面的問題該如何解決 謝謝
嗨 @OwenLegalSign ,
您好,我剛才在更新至transformers=4.37.2後測試了一下,沒有發生您所示的錯誤。您是否可以幫我試試看更新或安裝sentencepiece後再重試一次,因為您提供的錯誤碼在最後一行有寫:"You need to have sentencepiece installed to convert a slow tokenizer to a fast one.",感謝您。
Blaze7451 changed discussion status to closed
謝謝,經安裝 sentencepiece 後就正常