keras / llama3.1_8b

huggingface.co
Total runs: 6
24-hour runs: 0
7-day runs: -3
30-day runs: 3
Model's Last Updated: June 17 2025
text-generation

Introduction of llama3.1_8b

Model Details of llama3.1_8b

Model Overview

Llama 3 is a set of large language models published by Meta. Both pretrained and instruction tuned models are available, and range in size from 7 billion to 70 billion parameters. See the model card below for benchmarks, data sources, and intended use cases.

Weights are released under the Llama 3 Community License . Keras model code is released under the Apache 2 License .

Links
Installation

Keras and KerasHub can be installed with:

pip install -U -q keras-hub
pip install -U -q keras

Jax, TensorFlow, and Torch come preinstalled in Kaggle Notebooks. For instructions on installing them in another environment see the Keras Getting Started page.

Presets

The following model checkpoints are provided by the Keras team. Full code examples for each are available below.

Preset name Parameters Description
llama3_8b_en 8.03B 8 billion parameter, 32-layer, base LLaMA 3 model.
llama3_8b_en_int8 8.03B 8 billion parameter, 32-layer, base LLaMA 3 model with activation and weights quantized to int8.
llama3_instruct_8b_en 8.03B 8 billion parameter, 32-layer, instruction tuned LLaMA 3 model.
llama3_instruct_8b_en_int8 8.03B 8 billion parameter, 32-layer, instruction tuned LLaMA 3 model with activation and weights quantized to int8.
llama3.1_8b 8.03B 8 billion parameter, 32-layer, based LLaMA 3.1 model.
llama3.1_guard_8b 8.03B 8 billion parameter, 32-layer, LLaMA 3.1 fine-tuned for consent safety classification.
llama3.1_instruct_8b 8.03B 8 billion parameter, 32-layer, instruction tuned LLaMA 3.1.
llama3.2_1b 1.5B 1 billion parameter, 16-layer, based LLaMA 3.2 model.
llama3.2_3b 3.6B 3 billion parameter, 26-layer, based LLaMA 3.2 model.
llama3.2_guard_1b 1.5B 1 billion parameter, 16-layer, based LLaMA 3.2 model fine-tuned for consent safety classification.
llama3.2_instruct_1b 1.5B 1 billion parameter, 16-layer, instruction tuned LLaMA 3.2.
llama3.2_instruct_3b 3.6B 3 billion parameter, 28-layer, instruction tuned LLaMA 3.2.
Prompts

Llama-3 "instruct" models are instruction tuned on turn by turn conversations and should be prompted with examples that precisely match the training data. Specifically, you must alternate user and assistant turns that begin and end with special tokens. New lines do matter. See the following for an example:

prompt = """<|start_header_id|>system<|end_header_id|>

You are a helpful AI assistant for travel tips and recommendations<|eot_id|><|start_header_id|>user<|end_header_id|>

What can you help me with?<|eot_id|><|start_header_id|>assistant<|end_header_id|>
"""

For more details, please refer to this link: Llama 3 Model Card & Prompt Formats .

Base models (without instruct in the name) have no specific prompting structure, and should usually be fine-tuned for a specific task.

Example Usage
import keras
import keras_hub
import numpy as np

Use generate() to do text generation.

llama_lm = keras_hub.models.Llama3CausalLM.from_preset("llama3.1_8b")
llama_lm.generate("What is Keras?", max_length=500)

# Generate with batched prompts.
llama_lm.generate(["What is Keras?", "Give me your best brownie recipe."], max_length=500)

Compile the generate() function with a custom sampler.

llama_lm = keras_hub.models.Llama3CausalLM.from_preset("llama3.1_8b")
llama_lm.compile(sampler="greedy")
llama_lm.generate("I want to say", max_length=30)

llama_lm.compile(sampler=keras_hub.samplers.BeamSampler(num_beams=2))
llama_lm.generate("I want to say", max_length=30)

Use generate() without preprocessing.

prompt = {
    "token_ids": np.array([[306, 864, 304, 1827, 0, 0, 0, 0, 0, 0]] * 2),
    # Use `"padding_mask"` to indicate values that should not be overridden.
    "padding_mask": np.array([[1, 1, 1, 1, 0, 0, 0, 0, 0, 0]] * 2),
}

llama_lm = keras_hub.models.Llama3CausalLM.from_preset(
    "llama3.1_8b",
    preprocessor=None,
    dtype="bfloat16"
)
llama_lm.generate(prompt)

Call fit() on a single batch.

features = ["The quick brown fox jumped.", "I forgot my homework."]
llama_lm = keras_hub.models.Llama3CausalLM.from_preset("llama3.1_8b")
llama_lm.fit(x=features, batch_size=2)

Call fit() without preprocessing.

x = {
    "token_ids": np.array([[450, 4996, 17354, 1701, 29916, 12500, 287, 29889, 0, 0]] * 2),
    "padding_mask": np.array([[1, 1, 1, 1, 1, 1, 1, 1, 0, 0]] * 2),
}
y = np.array([[4996, 17354, 1701, 29916, 12500, 287, 29889, 0, 0, 0]] * 2)
sw = np.array([[1, 1, 1, 1, 1, 1, 1, 0, 0, 0]] * 2)

llama_lm = keras_hub.models.Llama3CausalLM.from_preset(
    "llama3.1_8b",
    preprocessor=None,
    dtype="bfloat16"
)
llama_lm.fit(x=x, y=y, sample_weight=sw, batch_size=2)
Example Usage with Hugging Face URI
import keras
import keras_hub
import numpy as np

Use generate() to do text generation.

llama_lm = keras_hub.models.Llama3CausalLM.from_preset("hf://keras/llama3.1_8b")
llama_lm.generate("What is Keras?", max_length=500)

# Generate with batched prompts.
llama_lm.generate(["What is Keras?", "Give me your best brownie recipe."], max_length=500)

Compile the generate() function with a custom sampler.

llama_lm = keras_hub.models.Llama3CausalLM.from_preset("hf://keras/llama3.1_8b")
llama_lm.compile(sampler="greedy")
llama_lm.generate("I want to say", max_length=30)

llama_lm.compile(sampler=keras_hub.samplers.BeamSampler(num_beams=2))
llama_lm.generate("I want to say", max_length=30)

Use generate() without preprocessing.

prompt = {
    "token_ids": np.array([[306, 864, 304, 1827, 0, 0, 0, 0, 0, 0]] * 2),
    # Use `"padding_mask"` to indicate values that should not be overridden.
    "padding_mask": np.array([[1, 1, 1, 1, 0, 0, 0, 0, 0, 0]] * 2),
}

llama_lm = keras_hub.models.Llama3CausalLM.from_preset(
    "hf://keras/llama3.1_8b",
    preprocessor=None,
    dtype="bfloat16"
)
llama_lm.generate(prompt)

Call fit() on a single batch.

features = ["The quick brown fox jumped.", "I forgot my homework."]
llama_lm = keras_hub.models.Llama3CausalLM.from_preset("hf://keras/llama3.1_8b")
llama_lm.fit(x=features, batch_size=2)

Call fit() without preprocessing.

x = {
    "token_ids": np.array([[450, 4996, 17354, 1701, 29916, 12500, 287, 29889, 0, 0]] * 2),
    "padding_mask": np.array([[1, 1, 1, 1, 1, 1, 1, 1, 0, 0]] * 2),
}
y = np.array([[4996, 17354, 1701, 29916, 12500, 287, 29889, 0, 0, 0]] * 2)
sw = np.array([[1, 1, 1, 1, 1, 1, 1, 0, 0, 0]] * 2)

llama_lm = keras_hub.models.Llama3CausalLM.from_preset(
    "hf://keras/llama3.1_8b",
    preprocessor=None,
    dtype="bfloat16"
)
llama_lm.fit(x=x, y=y, sample_weight=sw, batch_size=2)

Runs of keras llama3.1_8b on huggingface.co

6
Total runs
0
24-hour runs
-3
3-day runs
-3
7-day runs
3
30-day runs

More Information About llama3.1_8b huggingface.co Model

llama3.1_8b huggingface.co

llama3.1_8b huggingface.co is an AI model on huggingface.co that provides llama3.1_8b's model effect (), which can be used instantly with this keras llama3.1_8b model. huggingface.co supports a free trial of the llama3.1_8b model, and also provides paid use of the llama3.1_8b. Support call llama3.1_8b model through api, including Node.js, Python, http.

llama3.1_8b huggingface.co Url

https://huggingface.co/keras/llama3.1_8b

keras llama3.1_8b online free

llama3.1_8b huggingface.co is an online trial and call api platform, which integrates llama3.1_8b's modeling effects, including api services, and provides a free online trial of llama3.1_8b, you can try llama3.1_8b online for free by clicking the link below.

keras llama3.1_8b online free url in huggingface.co:

https://huggingface.co/keras/llama3.1_8b

llama3.1_8b install

llama3.1_8b is an open source model from GitHub that offers a free installation service, and any user can find llama3.1_8b on GitHub to install. At the same time, huggingface.co provides the effect of llama3.1_8b install, users can directly use llama3.1_8b installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

llama3.1_8b install url in huggingface.co:

https://huggingface.co/keras/llama3.1_8b

Url of llama3.1_8b

llama3.1_8b huggingface.co Url

Provider of llama3.1_8b huggingface.co

keras
ORGANIZATIONS

Other API from keras

huggingface.co

Total runs: 22
Run Growth: 19
Growth Rate: 86.36%
Updated:February 27 2026
huggingface.co

Total runs: 15
Run Growth: -130
Growth Rate: -866.67%
Updated:July 17 2026
huggingface.co

Total runs: 13
Run Growth: -28
Growth Rate: -215.38%
Updated:June 17 2025
huggingface.co

Total runs: 13
Run Growth: 6
Growth Rate: 46.15%
Updated:February 27 2026
huggingface.co

Total runs: 13
Run Growth: 10
Growth Rate: 76.92%
Updated:March 25 2025
huggingface.co

Total runs: 13
Run Growth: -23
Growth Rate: -176.92%
Updated:June 17 2025
huggingface.co

Total runs: 11
Run Growth: 8
Growth Rate: 72.73%
Updated:February 27 2026
huggingface.co

Total runs: 11
Run Growth: -130
Growth Rate: -1181.82%
Updated:July 17 2026
huggingface.co

Total runs: 10
Run Growth: 0
Growth Rate: 0.00%
Updated:March 25 2025
huggingface.co

Total runs: 9
Run Growth: 3
Growth Rate: 33.33%
Updated:March 25 2025
huggingface.co

Total runs: 8
Run Growth: 1
Growth Rate: 12.50%
Updated:March 25 2025
huggingface.co

Total runs: 7
Run Growth: -12
Growth Rate: -171.43%
Updated:May 15 2026
huggingface.co

Total runs: 7
Run Growth: -27
Growth Rate: -385.71%
Updated:June 17 2025
huggingface.co

Total runs: 7
Run Growth: 4
Growth Rate: 57.14%
Updated:February 27 2026
huggingface.co

Total runs: 7
Run Growth: 4
Growth Rate: 57.14%
Updated:February 27 2026
huggingface.co

Total runs: 6
Run Growth: 6
Growth Rate: 100.00%
Updated:June 17 2025
huggingface.co

Total runs: 6
Run Growth: 3
Growth Rate: 50.00%
Updated:March 25 2025