Instructions to use AfricaComputeFund/Monarch-1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AfricaComputeFund/Monarch-1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="AfricaComputeFund/Monarch-1") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("AfricaComputeFund/Monarch-1") model = AutoModelForCausalLM.from_pretrained("AfricaComputeFund/Monarch-1") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - PEFT
How to use AfricaComputeFund/Monarch-1 with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use AfricaComputeFund/Monarch-1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "AfricaComputeFund/Monarch-1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AfricaComputeFund/Monarch-1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/AfricaComputeFund/Monarch-1
- SGLang
How to use AfricaComputeFund/Monarch-1 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "AfricaComputeFund/Monarch-1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AfricaComputeFund/Monarch-1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "AfricaComputeFund/Monarch-1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AfricaComputeFund/Monarch-1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use AfricaComputeFund/Monarch-1 with Docker Model Runner:
docker model run hf.co/AfricaComputeFund/Monarch-1
Monarch-1: A Generative AI Model Optimized for Africa
Monarch-1 is a generative AI model fine-tuned from Mistral-7B-Instruct-v0.3, specifically optimized for African linguistic, cultural, and economic contexts. Developed as a foundational project within the Africa Compute Fund (ACF), Monarch-1 demonstrates the power of localized AI infrastructure, regional dataset curation, and specialized fine-tuning methodologies.
Purpose and Vision
Monarch-1 was created to bridge the gap between global AI models and Africa’s unique needs. Generic large-scale models often lack awareness of the diverse languages, historical contexts, and market-specific data necessary for effective AI applications across the continent. Monarch-1 aims to:
- Provide linguistically and culturally relevant AI interactions tailored to African users.
- Enhance economic and business applications by fine-tuning responses to regional market trends.
- Strengthen Africa’s AI infrastructure and computational sovereignty, ensuring local access to powerful generative AI models.
- Serve as a starting point for domain-specific AI applications across key sectors such as finance, healthcare, agriculture, and education.
This model is part of a broader initiative to establish high-performance GPU-powered compute infrastructure, train indigenous AI systems, and build an ecosystem where African developers can train and deploy AI solutions optimized for their own markets.
Technical Specifications
- Base Model: mistralai/Mistral-7B-Instruct-v0.3
- Fine-Tuning Method: Parameter-Efficient Fine-Tuning (PEFT) utilizing LoRA for optimized training efficiency.
- Dataset: Curated dataset integrating African linguistic, cultural, and economic data to improve relevance and response quality.
- Training Framework: AutoTrain by Hugging Face, leveraging efficient model training techniques.
- Infrastructure: Hosted on a local AI compute cluster to enable scalable deployment and continued improvements.
Usage
Developers and researchers can use Monarch-1 to generate human-like responses aligned with African contexts. Below is an example of how to run inference using the model:
from transformers import AutoModelForCausalLM, AutoTokenizer
model_path = "PATH_TO_MONARCH-1_REPO"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(
model_path,
device_map="auto",
torch_dtype='auto'
).eval()
# Example prompt
messages = [
{"role": "user", "content": "What impact can Monarch-1 have in Africa?"}
]
input_ids = tokenizer.apply_chat_template(conversation=messages, tokenize=True, add_generation_prompt=True, return_tensors='pt')
output_ids = model.generate(input_ids.to('cuda'))
response = tokenizer.decode(output_ids[0][input_ids.shape[1]:], skip_special_tokens=True)
print(response)
Ethical Use and Responsibility
Monarch-1 is designed for ethical and responsible AI use. Developers and users must ensure that the model is used in a manner that promotes positive social impact, accuracy, and fairness. The following considerations are essential:
- Avoid generating harmful, biased, or misleading content.
- Ensure culturally sensitive responses, particularly in areas such as history, politics, and identity.
- Use the model in applications that align with constructive, transparent, and ethical AI deployment.
Future Roadmap
Monarch-1 represents the first step in a broader AI initiative focused on localized, high-performance AI models. Planned developments include:
- Expanding linguistic support to include more African languages.
- Fine-tuning for domain-specific applications such as healthcare, legal, and financial AI solutions.
- Increasing model efficiency and accuracy through iterative training updates.
- Integrating with localized AI hardware infrastructure to enhance Africa’s AI research and deployment capabilities.
Disclaimer
Monarch-1 is provided as is with no guarantees of performance or accuracy in critical applications. Users are responsible for evaluating the model's suitability for their specific use cases.
- Downloads last month
- 6