Instructions to use QuantFactory/InkubaLM-0.4B-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use QuantFactory/InkubaLM-0.4B-GGUF with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="QuantFactory/InkubaLM-0.4B-GGUF", filename="InkubaLM-0.4B.Q2_K.gguf", )
output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use QuantFactory/InkubaLM-0.4B-GGUF with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf QuantFactory/InkubaLM-0.4B-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf QuantFactory/InkubaLM-0.4B-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf QuantFactory/InkubaLM-0.4B-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf QuantFactory/InkubaLM-0.4B-GGUF:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf QuantFactory/InkubaLM-0.4B-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf QuantFactory/InkubaLM-0.4B-GGUF:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf QuantFactory/InkubaLM-0.4B-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf QuantFactory/InkubaLM-0.4B-GGUF:Q4_K_M
Use Docker
docker model run hf.co/QuantFactory/InkubaLM-0.4B-GGUF:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use QuantFactory/InkubaLM-0.4B-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "QuantFactory/InkubaLM-0.4B-GGUF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "QuantFactory/InkubaLM-0.4B-GGUF", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/QuantFactory/InkubaLM-0.4B-GGUF:Q4_K_M
- Ollama
How to use QuantFactory/InkubaLM-0.4B-GGUF with Ollama:
ollama run hf.co/QuantFactory/InkubaLM-0.4B-GGUF:Q4_K_M
- Unsloth Studio new
How to use QuantFactory/InkubaLM-0.4B-GGUF with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for QuantFactory/InkubaLM-0.4B-GGUF to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for QuantFactory/InkubaLM-0.4B-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for QuantFactory/InkubaLM-0.4B-GGUF to start chatting
- Docker Model Runner
How to use QuantFactory/InkubaLM-0.4B-GGUF with Docker Model Runner:
docker model run hf.co/QuantFactory/InkubaLM-0.4B-GGUF:Q4_K_M
- Lemonade
How to use QuantFactory/InkubaLM-0.4B-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull QuantFactory/InkubaLM-0.4B-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.InkubaLM-0.4B-GGUF-Q4_K_M
List all available models
lemonade list
output = llm(
"Once upon a time,",
max_tokens=512,
echo=True
)
print(output)QuantFactory/InkubaLM-0.4B-GGUF
This is quantized version of lelapa/InkubaLM-0.4B created using llama.cpp
Original Model Card
InkubaLM-0.4B: Small language model for low-resource African Languages
Model Details
InkubaLM has been trained from scratch using 1.9 billion tokens of data for five African languages, along with English and French data, totaling 2.4 billion tokens of data. Similar to the model architecture used for MobileLLM, we trained this InkubaLM with a parameter size of 0.4 billion and a vocabulary size of 61788. For detailed information on training, benchmarks, and performance, please refer to our full blog post.
Model Description
- Developed by: Lelapa AI - Fundamental Research Team.
- Model type: Small Language Model (SLM) for five African languages built using the architecture design of LLaMA-7B.
- Language(s) (NLP): isiZulu, Yoruba, Swahili, isiXhosa, Hausa, English and French.
- License: CC BY-NC 4.0.
Model Sources
- Repository: TBD
- Paper : InkubaLM
How to Get Started with the Model
Use the code below to get started with the model.
pip install transformers
Running the model on CPU/GPU/multi GPU
- Running the model on CPU
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("lelapa/InkubaLM-0.4B",trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("lelapa/InkubaLM-0.4B",trust_remote_code=True)
text = "Today I planned to"
inputs = tokenizer(text, return_tensors="pt")
input_ids = inputs.input_ids
# Create an attention mask
attention_mask = inputs.attention_mask
# Generate outputs using the attention mask
outputs = model.generate(input_ids, attention_mask=attention_mask, max_length=60,pad_token_id=tokenizer.eos_token_id)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
- Using full precision
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("lelapa/InkubaLM-0.4B", trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("lelapa/InkubaLM-0.4B", trust_remote_code=True)
model.to('cuda')
text = "Today i planned to "
input_ids = tokenizer(text, return_tensors="pt").to('cuda').input_ids
outputs = model.generate(input_ids, max_length=1000, repetition_penalty=1.2, pad_token_id=tokenizer.eos_token_id)
print(tokenizer.batch_decode(outputs[:, input_ids.shape[1]:-1])[0].strip())
- Using torch.bfloat16
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
checkpoint = "lelapa/InkubaLM-0.4B"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto",torch_dtype=torch.bfloat16, trust_remote_code=True)
inputs = tokenizer.encode("Today i planned to ", return_tensors="pt").to("cuda")
outputs = model.generate(inputs)
print(tokenizer.decode(outputs[0]))
- Using quantized Versions via bitsandbytes
pip install bitsandbytes accelerate
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
quantization_config = BitsAndBytesConfig(load_in_8bit=True) # to use 4bit use `load_in_4bit=True` instead
checkpoint = "lelapa/InkubaLM-0.4B"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForCausalLM.from_pretrained(checkpoint, quantization_config=quantization_config, trust_remote_code=True)
inputs = tokenizer.encode("Today i planned to ", return_tensors="pt").to("cuda")
outputs = model.generate(inputs)
print(tokenizer.decode(outputs[0]))
Training Details
Training Data
- For training, we used the Inkuba-mono dataset.
Training Hyperparameters
| Hyperparameter | Value |
|---|---|
| Total Parameters | 0.422B |
| Hidden Size | 2048 |
| Intermediate Size (MLPs) | 5632 |
| Number of Attention Heads | 32 |
| Number of Hidden Layers | 8 |
| RMSNorm É› | 1e^-5 |
| Max Seq Length | 2048 |
| Vocab Size | 61788 |
Limitations
The InkubaLM model has been trained on multilingual datasets but does have some limitations. It is capable of understanding and generating content in five African languages: Swahili, Yoruba, Hausa, isiZulu, and isiXhosa, as well as English and French. While it can generate text on various topics, the resulting content may not always be entirely accurate, logically consistent, or free from biases found in the training data. Additionally, the model may sometimes use different languages when generating text. Nonetheless, this model is intended to be a foundational tool to aid research in African languages.
Ethical Considerations and Risks
InkubaLM is a small LM developed for five African languages. The model is evaluated only in sentiment analysis, machine translation, AfriMMLU, and AfriXNLI tasks and has yet to cover all possible evaluation scenarios. Similar to other language models, it is impossible to predict all of InkubaLM's potential outputs in advance, and in some cases, the model may produce inaccurate, biased, or objectionable responses. Therefore, before using the model in any application, the users should conduct safety testing and tuning tailored to their intended use.
Citation
@article{tonja2024inkubalm,
title={InkubaLM: A small language model for low-resource African languages},
author={Tonja, Atnafu Lambebo and Dossou, Bonaventure FP and Ojo, Jessica and Rajab, Jenalea and Thior, Fadel and Wairagala, Eric Peter and Anuoluwapo, Aremu and Moiloa, Pelonomi and Abbott, Jade and Marivate, Vukosi and others},
journal={arXiv preprint arXiv:2408.17024},
year={2024}
}
Model Card Authors
Lelapa AI - Fundamental Research Team
Model Card Contact
- Downloads last month
- 261
2-bit
3-bit
4-bit
5-bit
6-bit
8-bit

# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="QuantFactory/InkubaLM-0.4B-GGUF", filename="", )