CoolFace
Modelpublic

ejbejaranos/Bitnet-Llama3-from8BM-now2B

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
0likes25downloads
Model Card

๐Ÿš€ BitNet-Llama3 (from 8B to 2B) Transformation & Training

This project transforms a Llama3 model from 8B parameters to a BitNet architecture with 2B parameters, applying BitLinear layers. Additionally, the model is trained with a predefined dataset and uploaded to Hugging Face for future use.


Model Description

<!-- Provide a longer summary of what this model is. -->

This is the model card of a ๐Ÿค— transformers model that has been pushed on the Hub. This model card has been automatically generated.

  • โ€”Developed by: ejbejaranos@gmail.com
  • โ€”Funded by [optional]: ITCL
  • โ€”Shared by [optional]: [More Information Needed]
  • โ€”Model type: LLama3 8B Tramsformed to Bitnet
  • โ€”Language(s) (NLP): Bitnet
  • โ€”License: [More Information Needed]
  • โ€”Finetuned from model [optional]: [More Information Needed]

Model Sources [optional]

<!-- Provide the basic links for the model. -->

  • โ€”Repository: ejbejaranos/Bitnet-Llama3-from8BM-now2B

๐Ÿ“„ Description

This repository includes scripts to:

  1. 1.๐ŸŽฏ Transform a Llama3 model to a BitNet architecture.
  2. 2.๐Ÿ’ป Train the model using Hugging Face and Weights & Biases.
  3. 3.๐Ÿš€ Upload the transformed and trained model to Hugging Face for inference and future use.

โš™๏ธ Requirements

  • โ€”Python 3.8+
  • โ€”Pytorch 1.10+
  • โ€”Transformers 4.0+
  • โ€”Hugging Face Hub API
  • โ€”Weights & Biases

๐Ÿงฐ Installation

Make sure you have all required dependencies installed:

bash
pip install torch transformers datasets wandb huggingface_hub

๐Ÿ’ฅ How to Use

  1. 1.Using the trained model for inference
python
from transformers import AutoModelForCausalLM, AutoTokenizer
from utils.bitnet_transformation import replace_linears_in_hf

# Load the BitNet model
model = "ejbejaranos/Bitnet-Llama3-from8BM-now2B"
model = AutoModelForCausalLM.from_pretrained(
    model,
    use_auth_token="YOUR_HF_TOKEN"
)

# Replace BitNet layers for inference
replace_linears_in_hf(model)
tokenizer = AutoTokenizer.from_pretrained("ejbejaranos/Bitnet-Llama3-from8BM-now2B")

# Set up for inference
model.to(device="cuda:0")
prompt = "What is Machine Learning?"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
generate_ids = model.generate(inputs.input_ids, max_length=50)
output = tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]

print(output)

๐Ÿง‘โ€๐Ÿ”ฌ Metrics

image/png

During training, the following metrics will be logged to Weights & Biases:

  • โ€”final_loss: 1.4.
  • โ€”final_perplexity: 4.2.

๐ŸŽฏ Future Goals

  • โ€”Implement additional quantization layers for inference.
  • โ€”Test the model on different datasets and contexts.

๐Ÿ“ข Contact

If you have questions, suggestions, or improvements, feel free to open an Issue or contact us through Hugging Face.


Environmental Impact

<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->

Carbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).

  • โ€”Hardware Type: [More Information Needed]
  • โ€”Hours used: [More Information Needed]
  • โ€”Cloud Provider: [More Information Needed]
  • โ€”Compute Region: [More Information Needed]
  • โ€”Carbon Emitted: [More Information Needed]
  • โ€”

๐Ÿ’ก Acknowledgments

Thanks to Hugging Face and Weights & Biases for providing support and tools.