Instructions to use yentinglin/Taiwan-LLaMa-v1.0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yentinglin/Taiwan-LLaMa-v1.0 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="yentinglin/Taiwan-LLaMa-v1.0") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("yentinglin/Taiwan-LLaMa-v1.0") model = AutoModelForCausalLM.from_pretrained("yentinglin/Taiwan-LLaMa-v1.0", 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use yentinglin/Taiwan-LLaMa-v1.0 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "yentinglin/Taiwan-LLaMa-v1.0" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yentinglin/Taiwan-LLaMa-v1.0", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/yentinglin/Taiwan-LLaMa-v1.0
- SGLang
How to use yentinglin/Taiwan-LLaMa-v1.0 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 "yentinglin/Taiwan-LLaMa-v1.0" \ --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": "yentinglin/Taiwan-LLaMa-v1.0", "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 "yentinglin/Taiwan-LLaMa-v1.0" \ --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": "yentinglin/Taiwan-LLaMa-v1.0", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use yentinglin/Taiwan-LLaMa-v1.0 with Docker Model Runner:
docker model run hf.co/yentinglin/Taiwan-LLaMa-v1.0
請問如何部署在GCP
#2
by sherlocktaiwan - opened
您好,感謝對於台灣文化結合AI的貢獻。
我有GCP的compute engine機器(T4),那我在那裡可以找到安裝文件呢? 我之前其實有安裝過open ai whisper,以及Stable diffusion ,但Taiwan-LLaMa-v1.0 好像有點複雜,感謝喔!
您好,我照著AI社團先進的作法,https://www.facebook.com/groups/Taiwan.NLP/posts/6277225012372637/ 可以執行,但我猜他是基於cpu運算,所以好慢。
我放GCP的結論:
1.Cloud Function和Cloud Run 有容量限制。所以使用13G模型 不可行。
2.放在compute engine (T4 n1-highmem-4),以Flask service接,詢問『台中的經緯度』,花費46秒。
ex Q:台中的經緯度 A: 台中的經緯度為24°23′N 120°47′E。
