Text Generation
Transformers
Safetensors
PyTorch
Turkish
llama
legal
turkish
llama-3.1
fp8
bfloat16
mixed-precision
question-answering
fsdp-v2
distributed-training
conversational
text-generation-inference
Instructions to use newmindai/Llama-3.1-8B-Instruct-w16a8-rw-with-gw-hp-4nodes with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use newmindai/Llama-3.1-8B-Instruct-w16a8-rw-with-gw-hp-4nodes with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="newmindai/Llama-3.1-8B-Instruct-w16a8-rw-with-gw-hp-4nodes") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("newmindai/Llama-3.1-8B-Instruct-w16a8-rw-with-gw-hp-4nodes") model = AutoModelForCausalLM.from_pretrained("newmindai/Llama-3.1-8B-Instruct-w16a8-rw-with-gw-hp-4nodes", 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 newmindai/Llama-3.1-8B-Instruct-w16a8-rw-with-gw-hp-4nodes with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "newmindai/Llama-3.1-8B-Instruct-w16a8-rw-with-gw-hp-4nodes" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "newmindai/Llama-3.1-8B-Instruct-w16a8-rw-with-gw-hp-4nodes", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/newmindai/Llama-3.1-8B-Instruct-w16a8-rw-with-gw-hp-4nodes
- SGLang
How to use newmindai/Llama-3.1-8B-Instruct-w16a8-rw-with-gw-hp-4nodes 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 "newmindai/Llama-3.1-8B-Instruct-w16a8-rw-with-gw-hp-4nodes" \ --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": "newmindai/Llama-3.1-8B-Instruct-w16a8-rw-with-gw-hp-4nodes", "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 "newmindai/Llama-3.1-8B-Instruct-w16a8-rw-with-gw-hp-4nodes" \ --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": "newmindai/Llama-3.1-8B-Instruct-w16a8-rw-with-gw-hp-4nodes", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use newmindai/Llama-3.1-8B-Instruct-w16a8-rw-with-gw-hp-4nodes with Docker Model Runner:
docker model run hf.co/newmindai/Llama-3.1-8B-Instruct-w16a8-rw-with-gw-hp-4nodes
Upload README
Browse files
README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Finetuned Model (Distributed Checkpoint)
|
| 2 |
+
|
| 3 |
+
Base Model: meta-llama/Llama-3.1-8B-Instruct
|
| 4 |
+
Dataset: newmindai/euro_hpc-legal
|
| 5 |
+
Training dtype: bf16
|
| 6 |
+
Checkpoint Type: Distributed/Sharded (requires loading with FSDP)
|
| 7 |
+
|
| 8 |
+
## Loading Instructions
|
| 9 |
+
|
| 10 |
+
This model was saved using PyTorch Distributed Checkpointing and requires special loading:
|
| 11 |
+
|
| 12 |
+
```python
|
| 13 |
+
import torch
|
| 14 |
+
from torch.distributed.checkpoint import load
|
| 15 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 16 |
+
|
| 17 |
+
# Load tokenizer
|
| 18 |
+
tokenizer = AutoTokenizer.from_pretrained("/gpfs/scratch/ehpc317/esavirdi/dual_precision_training/7Dec/lama3.1_8b_rowwise_with_gw_hp_4nodes/final_model")
|
| 19 |
+
|
| 20 |
+
# Load model architecture
|
| 21 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 22 |
+
"meta-llama/Llama-3.1-8B-Instruct",
|
| 23 |
+
torch_dtype=torch.bf16,
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
# Load sharded weights
|
| 27 |
+
checkpoint = {"model": model.state_dict()}
|
| 28 |
+
load(checkpoint, checkpoint_id="/gpfs/scratch/ehpc317/esavirdi/dual_precision_training/7Dec/lama3.1_8b_rowwise_with_gw_hp_4nodes/final_model/sharded")
|
| 29 |
+
model.load_state_dict(checkpoint["model"])
|
| 30 |
+
|
| 31 |
+
# Generate text
|
| 32 |
+
inputs = tokenizer("Your prompt here", return_tensors="pt")
|
| 33 |
+
outputs = model.generate(**inputs, max_length=100)
|
| 34 |
+
print(tokenizer.decode(outputs[0]))
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
Note: For easier inference, consider converting this to a standard HuggingFace checkpoint
|
| 38 |
+
by loading and re-saving on a single GPU.
|