Downloads · 30 days
0
RichardErkhov/k-l-lambda_-_Llama-3.2-1B-vocab32k-exl2
k-l-lambda_-_Llama-3.2-1B-vocab32k-exl2 is a machine learning model from RichardErkhov. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Downloads · 30 days
0
Access
Public
Updated Jan 18, 2025
Repo size
4.3 GB
Likes
0
Public
Click a slice to open those files.
.json893 KB · 99%
From the Hugging Face model README
Quantization made by Richard Erkhov.
Llama-3.2-1B-vocab32k - EXL2
| Branch | Bits | Description | | ----- | ---- | ------- | ------ | ------ | ------ | ------ | ------------ | | 8_0 | 8.0 | Maximum quality that ExLlamaV2 can produce, near unquantized performance. | | 6_5 | 6.5 | Very similar to 8.0, good tradeoff of size vs performance, recommended. | | 5_0 | 5.0 | Slightly lower quality vs 6.5, but usable on 8GB cards. | | 4_25 | 4.25 | GPTQ equivalent bits per weight, slightly higher quality. | | 3_5 | 3.5 | Lower quality, only use if you have to. |
With git:
git clone --single-branch --branch 6_5 https://huggingface.co/k-l-lambda_-_Llama-3.2-1B-vocab32k-exl2 Llama-3.2-1B-vocab32k-6_5
With huggingface hub:
pip3 install huggingface-hub
To download a specific branch, use the --revision parameter. For example, to download the 6.5 bpw branch:
Linux:
huggingface-cli download k-l-lambda_-_Llama-3.2-1B-vocab32k-exl2 --revision 6_5 --local-dir Llama-3.2-1B-vocab32k-6_5 --local-dir-use-symlinks False
Windows (which apparently doesn't like _ in folders sometimes?):
huggingface-cli download k-l-lambda_-_Llama-3.2-1B-vocab32k-exl2 --revision 6_5 --local-dir Llama-3.2-1B-vocab32k-6.5 --local-dir-use-symlinks False
license: mit language:
This is a vocab pruned variant of Llama-3.2-1B-Instruct. The vocabulary size is pruned from 128256 to 32256. The total parameter size is: 1,039,214,756, ~200M parameters pruned from origin.
This is a code example:
import torch
from transformers import pipeline
pipe = pipeline(
"text-generation",
model='k-l-lambda/Llama-3.2-1B-vocab32k',
torch_dtype=torch.bfloat16,
device_map="auto",
)
messages = [
{"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
{"role": "user", "content": "Who are you?"},
]
outputs = pipe(
messages,
max_new_tokens=256,
)
print(outputs[0]["generated_text"][-1])
Another:
from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("k-l-lambda/Llama-3.2-1B-vocab32k")
model = AutoModelForCausalLM.from_pretrained("k-l-lambda/Llama-3.2-1B-vocab32k")
input_ids = tokenizer.encode("Hello, ", return_tensors="pt")
output = model.generate(input_ids)
print(tokenizer.decode(output[0]))
You can map an ID value in 32k vocab to the ID value in original 128k vocab, by the tensor in token_indices.pt and inv_token_indices.pt.
import torch
from huggingface_hub import hf_hub_download
from transformers import AutoTokenizer
tokenizer128k = AutoTokenizer.from_pretrained('meta-llama/Llama-3.2-1B-Instruct')
tokenizer32k = AutoTokenizer.from_pretrained('k-l-lambda/Llama-3.2-1B-vocab32k')
indices_path = hf_hub_download(repo_id='k-l-lambda/Llama-3.2-1B-vocab32k', filename='token_indices.pt')
inv_indices_path = hf_hub_download(repo_id='k-l-lambda/Llama-3.2-1B-vocab32k', filename='inv_token_indices.pt')
token_indices = torch.load(indices_path)
inv_token_indices = torch.load(inv_indices_path)
ids_32k = tokenizer32k.encode('This is an example sentence.')
ids_128k = [token_indices[id].item() for id in ids_32k]
print(f'{ids_32k=}')
print(f'{ids_128k=}')
print(tokenizer128k.decode(ids_128k))
ids_128k = tokenizer128k.encode('This is another example sentence.')
ids_32k = [inv_token_indices[id].item() for id in ids_128k]
print(f'{ids_128k=}')
print(f'{ids_32k=}') # non-exist tokens in 32k vocab will map to -1
print(tokenizer32k.decode(ids_32k))