Instructions to use prithivMLmods/Llama-3.1-5B-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use prithivMLmods/Llama-3.1-5B-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="prithivMLmods/Llama-3.1-5B-Instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("prithivMLmods/Llama-3.1-5B-Instruct") model = AutoModelForCausalLM.from_pretrained("prithivMLmods/Llama-3.1-5B-Instruct") 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
- vLLM
How to use prithivMLmods/Llama-3.1-5B-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "prithivMLmods/Llama-3.1-5B-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "prithivMLmods/Llama-3.1-5B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/prithivMLmods/Llama-3.1-5B-Instruct
- SGLang
How to use prithivMLmods/Llama-3.1-5B-Instruct 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 "prithivMLmods/Llama-3.1-5B-Instruct" \ --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": "prithivMLmods/Llama-3.1-5B-Instruct", "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 "prithivMLmods/Llama-3.1-5B-Instruct" \ --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": "prithivMLmods/Llama-3.1-5B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use prithivMLmods/Llama-3.1-5B-Instruct with Docker Model Runner:
docker model run hf.co/prithivMLmods/Llama-3.1-5B-Instruct
Llama-3.1-5B-Instruct
Llama-3.1 is a collection of multilingual large language models (LLMs) that includes pretrained and instruction-tuned generative models in various sizes. The Llama-3.1-5B-Instruct model is part of the series optimized for multilingual dialogue use cases, offering powerful conversational abilities and outperforming many open-source and closed chat models on key industry benchmarks.
Model Overview
- Size: 5B parameters
- Model Architecture: Llama-3.1 is an auto-regressive language model using an optimized transformer architecture.
- Training: The model is fine-tuned using Supervised Fine-Tuning (SFT) and Reinforcement Learning with Human Feedback (RLHF) to align with human preferences, ensuring helpfulness, safety, and natural conversations.
The Llama-3.1-5B-Instruct model is optimized for multilingual text generation and excels in a variety of dialog-based use cases. It is designed to handle a wide array of tasks, including question answering, translation, and instruction following.
How to Use
Requirements
Install the latest version of Transformers:
pip install --upgrade transformersEnsure you have PyTorch installed with support for
bfloat16:pip install torch
Example Code
Below is an example of how to use the Llama-3.1-5B-Instruct model for conversational inference:
import transformers
import torch
# Define the model ID
model_id = "prithivMLmods/Llama-3.1-5B-Instruct"
# Set up the pipeline for text generation
pipeline = transformers.pipeline(
"text-generation",
model=model_id,
model_kwargs={"torch_dtype": torch.bfloat16},
device_map="auto", # Use the best device available
)
# Define conversation messages
messages = [
{"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
{"role": "user", "content": "Who are you?"},
]
# Generate a response
outputs = pipeline(
messages,
max_new_tokens=256,
)
# Print the generated response
print(outputs[0]["generated_text"][-1])
Model Details
- Model Type: Instruction-Tuned Large Language Model (LLM)
- Training: Trained using supervised fine-tuning and reinforcement learning with human feedback.
- Supported Tasks: Dialogue generation, question answering, translation, and other text-based tasks.
Performance
The Llama-3.1-5B-Instruct model outperforms many existing models on several benchmarks, making it a reliable choice for conversational AI tasks in multilingual environments.
Notes
- This model is optimized for safety and helpfulness, ensuring a positive user experience.
- The torch_dtype is set to
bfloat16to optimize memory usage and performance.
- Downloads last month
- 17