Meta-Llama-3-8B-GGUF
- This is a GGUF quantized version of Meta-Llama-3-8B.
Model Details
- Meta developed and released the Meta Llama 3 family of large language models (LLMs) based on the Transformer architecture.
- Model Architecture: Transformer-based with 8.5 billion parameters.
- GGUF Quantization: Currently only availabel in f_16, Q8_0 version.
About GGUF
GGUF is a new format introduced by the llama.cpp team on August 21st 2023. It is a replacement for GGML, which is no longer supported by llama.cpp. GGUF offers numerous advantages over GGML, such as better tokenisation, and support for special tokens. It is also supports metadata, and is designed to be extensible.
Here is an incomplate list of clients and libraries that are known to support GGUF:
llama.cpp. The source project for GGUF. Offers a CLI and a server option.
text-generation-webui, the most widely used web UI, with many features and powerful extensions. Supports GPU acceleration.
KoboldCpp, a fully featured web UI, with GPU accel across all platforms and GPU architectures. Especially good for story telling.
LM Studio, an easy-to-use and powerful local GUI for Windows and macOS (Silicon), with GPU acceleration.
LoLLMS Web UI, a great web UI with many interesting and unique features, including a full model library for easy model selection.
Faraday.dev, an attractive and easy to use character-based chat GUI for Windows and macOS (both Silicon and Intel), with GPU acceleration.
ctransformers, a Python library with GPU accel, LangChain support, and OpenAI-compatible AI server.
llama-cpp-python, a Python library with GPU accel, LangChain support, and OpenAI-compatible API server.
candle, a Rust ML framework with a focus on performance, including GPU support, and ease of use.
Intended Use
- This model is intended for research and experimentation in understanding and advancing language model capabilities.
- Sample Use Cases:
- Text generation of various kinds (creative, factual, etc.)
- Summarization
- Question-answering
Performance & Limitations
- Performance Metrics: Report speed improvements, performance changes compared to the original model.
- Limitations:
May still generate unsafe or biased outputs, use with caution.
Performance changes compared to the original due to quantization.
How to Use
- Load the model and tokenizer:
1##### Llama3 Inference #############
2from huggingface_hub import hf_hub_download
3import time
4from llama_cpp.llama import Llama, LlamaGrammar
5import httpx
6import json
7import torch
8import multiprocessing as mp
9
10number_of_cpu = mp.cpu_count()
11grammar_text = httpx.get("https://raw.githubusercontent.com/ggerganov/llama.cpp/master/grammars/json.gbnf").text
12grammar = LlamaGrammar.from_string(grammar_text)
13model_name_or_path = "Orneyfish/Meta-Llama-3-8B_F_16.gguf"
14model_basename = "Meta-Llama-3-8B_F_16.gguf" # the model is in bin format
15
16
17model_path = hf_hub_download(repo_id=model_name_or_path, filename=model_basename, local_dir='models/')
18from langchain import PromptTemplate, LLMChain
19from langchain.callbacks.manager import CallbackManager
20from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
21
22# Callbacks support token-wise streaming
23callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])
24# Verbose is required to pass to the callback manager
25n_gpu_layers = 40 # Change this value based on your model and your GPU VRAM pool.
26n_batch = 1024 # Should be between 1 and n_ctx, consider the amount of VRAM in your GPU.
27
28# Loading model,
29llm = Llama(
30model_path=model_path,
31n_threads=number_of_cpu,
32n_gpu_layers=n_gpu_layers,
33n_batch=n_batch,
34n_threads_batch = 512,
35# use_mlock =True,
36callback_manager=callback_manager,
37verbose=True,
38n_ctx=8196, # Context window
39stop = ['USER:'], # Dynamic stopping when such token is detected.
40temperature = 0.2,
41# use_mmap = False,
42)
Prompt Template
1. System prompt message added to a single user message
1prompt = """<|begin_of_text|><|start_header_id|>system<|end_header_id|>
2{{ system_prompt }}<|eot_id|><|start_header_id|>user<|end_header_id|>
3{{ user_message }}<|eot_id|><|start_header_id|>assistant<|end_header_id|>"""
4
2. System prompt and multiple turn conversation between the user and assistant
1prompt = """<|begin_of_text|><|start_header_id|>system<|end_header_id|>
2{{ system_prompt }}<|eot_id|><|start_header_id|>user<|end_header_id|>
3{{ user_message_1 }}<|eot_id|><|start_header_id|>assistant<|end_header_id|>
4{{ model_answer_1 }}<|eot_id|><|start_header_id|>user<|end_header_id|>
5{{ user_message_2 }}<|eot_id|><|start_header_id|>assistant<|end_header_id|>"""
6
Please test the model out