Text Generation
Transformers
PyTorch
Chinese
English
llama
LLaMA2
Linly
Chinese-LLaMA2
text-generation-inference
Instructions to use Linly-AI/Chinese-LLaMA-2-13B-hf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Linly-AI/Chinese-LLaMA-2-13B-hf with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Linly-AI/Chinese-LLaMA-2-13B-hf")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Linly-AI/Chinese-LLaMA-2-13B-hf") model = AutoModelForCausalLM.from_pretrained("Linly-AI/Chinese-LLaMA-2-13B-hf") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Linly-AI/Chinese-LLaMA-2-13B-hf with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Linly-AI/Chinese-LLaMA-2-13B-hf" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Linly-AI/Chinese-LLaMA-2-13B-hf", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Linly-AI/Chinese-LLaMA-2-13B-hf
- SGLang
How to use Linly-AI/Chinese-LLaMA-2-13B-hf 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 "Linly-AI/Chinese-LLaMA-2-13B-hf" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Linly-AI/Chinese-LLaMA-2-13B-hf", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "Linly-AI/Chinese-LLaMA-2-13B-hf" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Linly-AI/Chinese-LLaMA-2-13B-hf", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Linly-AI/Chinese-LLaMA-2-13B-hf with Docker Model Runner:
docker model run hf.co/Linly-AI/Chinese-LLaMA-2-13B-hf
Chinese-LLaMA-2-13B
Linly-Chinese-LLaMA2 ๅบไบ LLaMA2่ฟ่กไธญๆๅ่ฎญ็ป๏ผไฝฟ็จ่ฏพ็จๅญฆไน ๆนๆณ่ทจ่ฏญ่จ่ฟ็งป๏ผ่ฏ่กจ้ๅฏนไธญๆ้ๆฐ่ฎพ่ฎก๏ผๆฐๆฎๅๅธๆดๅ่กก๏ผๆถๆๆด็จณๅฎใ
่ฎญ็ป็ป่ๅbenchmarkๆๆ ่ฏฆ่ง ๐ป Github Repo
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("Linly-AI/Chinese-LLaMA-2-13B-hf", device_map="cuda:0", torch_dtype=torch.float16, trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("Linly-AI/Chinese-LLaMA-2-13B-hf", use_fast=False, trust_remote_code=True)
prompt = "ๅไบฌๆไปไนๅฅฝ็ฉ็ๅฐๆน๏ผ"
prompt = f"### Instruction:{prompt.strip()} ### Response:"
inputs = tokenizer(prompt, return_tensors="pt").to("cuda:0")
generate_ids = model.generate(inputs.input_ids, do_sample=True, max_new_tokens=2048, top_k=10, top_p=0.85, temperature=1, repetition_penalty=1.15, eos_token_id=2, bos_token_id=1, pad_token_id=0)
response = tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
response = response.lstrip(prompt)
- Downloads last month
- 1,022