Text Generation
Transformers
Safetensors
French
English
mamba
conversational
text-generation-inference
Instructions to use lightonai/mambaoutai with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lightonai/mambaoutai with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="lightonai/mambaoutai") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("lightonai/mambaoutai") model = AutoModelForCausalLM.from_pretrained("lightonai/mambaoutai") 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use lightonai/mambaoutai with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "lightonai/mambaoutai" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lightonai/mambaoutai", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/lightonai/mambaoutai
- SGLang
How to use lightonai/mambaoutai 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 "lightonai/mambaoutai" \ --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": "lightonai/mambaoutai", "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 "lightonai/mambaoutai" \ --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": "lightonai/mambaoutai", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use lightonai/mambaoutai with Docker Model Runner:
docker model run hf.co/lightonai/mambaoutai
Add inference llama.cpp example
Browse files
README.md
CHANGED
|
@@ -70,6 +70,34 @@ out = model.generate(input_ids, max_new_tokens=10)
|
|
| 70 |
print(tokenizer.batch_decode(out))
|
| 71 |
```
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
### Model hyperparameters
|
| 74 |
|
| 75 |
More details about the model hyperparameters are given in the table below :
|
|
|
|
| 70 |
print(tokenizer.batch_decode(out))
|
| 71 |
```
|
| 72 |
|
| 73 |
+
### On-device Inference
|
| 74 |
+
|
| 75 |
+
Since Mambaoutai is only 1.6B parameters, it can run on a CPU at a a fast speed.
|
| 76 |
+
|
| 77 |
+
Here is an example of how to run it on llama.cpp:
|
| 78 |
+
|
| 79 |
+
```bash
|
| 80 |
+
# Clone llama.cpp repository and compile it from source
|
| 81 |
+
git clone https://github.com/ggerganov/llama.cpp\
|
| 82 |
+
cd llama.cpp
|
| 83 |
+
make
|
| 84 |
+
|
| 85 |
+
# Create a venv and install dependencies
|
| 86 |
+
conda create -n mamba-cpp python=3.10
|
| 87 |
+
conda activate mamba-cpp
|
| 88 |
+
pip install -r requirements/requirements-convert-hf-to-gguf.txt
|
| 89 |
+
|
| 90 |
+
# Download the weights, tokenizer, config, tokenizer_config and special_tokens_map from this repo and
|
| 91 |
+
# put them in a directory 'Mambaoutai/'
|
| 92 |
+
mkdir Mambaoutai
|
| 93 |
+
|
| 94 |
+
# Convert the weights to GGUF format
|
| 95 |
+
python convert-hf-to-gguf.py Mambaoutai
|
| 96 |
+
|
| 97 |
+
# Run inference with a prompt
|
| 98 |
+
./main -m Mambaoutai/ggml-model-f16.gguf -p "Building a website can be done in 10 simple steps:\nStep 1:" -n 400 -e -ngl 1
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
### Model hyperparameters
|
| 102 |
|
| 103 |
More details about the model hyperparameters are given in the table below :
|