Instructions to use zai-org/LongWriter-llama3.1-8b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zai-org/LongWriter-llama3.1-8b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="zai-org/LongWriter-llama3.1-8b")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("zai-org/LongWriter-llama3.1-8b") model = AutoModelForCausalLM.from_pretrained("zai-org/LongWriter-llama3.1-8b") - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use zai-org/LongWriter-llama3.1-8b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "zai-org/LongWriter-llama3.1-8b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "zai-org/LongWriter-llama3.1-8b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/zai-org/LongWriter-llama3.1-8b
- SGLang
How to use zai-org/LongWriter-llama3.1-8b 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 "zai-org/LongWriter-llama3.1-8b" \ --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": "zai-org/LongWriter-llama3.1-8b", "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 "zai-org/LongWriter-llama3.1-8b" \ --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": "zai-org/LongWriter-llama3.1-8b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use zai-org/LongWriter-llama3.1-8b with Docker Model Runner:
docker model run hf.co/zai-org/LongWriter-llama3.1-8b
Not able to run LongWriter-llama3.1-8b-Q8_0-GGUF on Ollama
Hey THUDM, Thanks for this amazing model!
I built the ollama model for the LongWriter-llama3.1-8b-Q8_0-GGUF with the modelfile as below, and it doesn't output answers when run in ollama. Please help me fix this or point out what I am doing wrong. I have very less knowledge of coding, and I mostly will be using these models for academic work. Thanks in advance!
ModelFile contents -
FROM C:/Users/Prajw/.ollama/models/modelsfiles/longwriter/longwriter-llama3.1-8b-q8_0.gguf
PARAMETER temperature 0.5
PARAMETER top_p 0.8
PARAMETER top_k 50
PARAMETER num_ctx 32768
PARAMETER repeat_penalty 1.15
PARAMETER stop USER:
PARAMETER stop ASSISTANT:
TEMPLATE """{{ if .System }}
<>
{{ .System }}
<>
{{ end }}
[INST]{{ index .Messages 0 "Content" }}[/INST]{{ index .Messages 0 "Response" }}
{{ range $i, $msg := .Messages }}
{{- if ne $i 0 -}}
[INST]{{ $msg.Content }}[/INST]{{ $msg.Response }}
{{- end -}}
{{ end }}"""