Text Generation
Transformers
Safetensors
llama
conversational
text-generation-inference
8-bit precision
bitsandbytes
Instructions to use Amar-89/Llama-3.1-8B-Instruct-8bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Amar-89/Llama-3.1-8B-Instruct-8bit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Amar-89/Llama-3.1-8B-Instruct-8bit") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Amar-89/Llama-3.1-8B-Instruct-8bit") model = AutoModelForCausalLM.from_pretrained("Amar-89/Llama-3.1-8B-Instruct-8bit") 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 Amar-89/Llama-3.1-8B-Instruct-8bit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Amar-89/Llama-3.1-8B-Instruct-8bit" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Amar-89/Llama-3.1-8B-Instruct-8bit", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Amar-89/Llama-3.1-8B-Instruct-8bit
- SGLang
How to use Amar-89/Llama-3.1-8B-Instruct-8bit 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 "Amar-89/Llama-3.1-8B-Instruct-8bit" \ --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": "Amar-89/Llama-3.1-8B-Instruct-8bit", "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 "Amar-89/Llama-3.1-8B-Instruct-8bit" \ --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": "Amar-89/Llama-3.1-8B-Instruct-8bit", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Amar-89/Llama-3.1-8B-Instruct-8bit with Docker Model Runner:
docker model run hf.co/Amar-89/Llama-3.1-8B-Instruct-8bit
Model Card
Model Details
- Developed by: Amar-89
- Model type: Quantized (8-bit)
- License: MIT
- Quantized from model: meta-llama/Llama-3.1-8B-Instruct
- Model size: 9.1 GB
Uses the tokenizer from the base model. No additional tweaks to model besides quantization. Recommended: 12 GB VRAM
How to use
pip install -q -U torch bitsandbytes transformers accelerate
from transformers import AutoTokenizer, AutoModelForCausalLM
model_name = "Amar-89/Llama-3.1-8B-Instruct-8bit"
model = AutoModelForCausalLM.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
def terminal_chat(model, tokenizer, system_prompt):
"""
Starts a terminal-based chat session with a specified model, tokenizer, and system prompt.
Args:
model: The Hugging Face model object.
tokenizer: The Hugging Face tokenizer object.
system_prompt: The system role or instruction to define the chat behavior.
"""
from transformers import pipeline
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
messages = [{"role": "system", "content": system_prompt}]
print("Chat session started. Type 'exit' to quit.")
while True:
user_input = input("User: ")
if user_input.lower() == "exit":
print("Ending chat session. Goodbye!")
break
messages.append({"role": "user", "content": user_input})
outputs = pipe(messages, max_new_tokens=256)
response = outputs[0]["generated_text"][-1]['content']
print(f"Assistant: {response}")
print(messages)
system_prompt = "You are a pirate chatbot who always responds in pirate speak!"
terminal_chat(model, tokenizer, system_prompt)
- Downloads last month
- 31
Model tree for Amar-89/Llama-3.1-8B-Instruct-8bit
Base model
meta-llama/Llama-3.1-8B Finetuned
meta-llama/Llama-3.1-8B-Instruct