Instructions to use CraneAILabs/ganda-gemma-1b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use CraneAILabs/ganda-gemma-1b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="CraneAILabs/ganda-gemma-1b") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("CraneAILabs/ganda-gemma-1b", dtype="auto") - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use CraneAILabs/ganda-gemma-1b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "CraneAILabs/ganda-gemma-1b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "CraneAILabs/ganda-gemma-1b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/CraneAILabs/ganda-gemma-1b
- SGLang
How to use CraneAILabs/ganda-gemma-1b 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 "CraneAILabs/ganda-gemma-1b" \ --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": "CraneAILabs/ganda-gemma-1b", "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 "CraneAILabs/ganda-gemma-1b" \ --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": "CraneAILabs/ganda-gemma-1b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use CraneAILabs/ganda-gemma-1b with Docker Model Runner:
docker model run hf.co/CraneAILabs/ganda-gemma-1b
Prompt retuned
Hello, the model seems to return the prompt itself and not the expected response
Hello there could you share the prompt you tried?
The model by default will work as a translator unless it detects an explicit instruction.
from transformers import AutoModelForCausalLM, AutoTokenizer
Load model and tokenizer
model = AutoModelForCausalLM.from_pretrained("CraneAILabs/ganda-gemma-1b")
tokenizer = AutoTokenizer.from_pretrained("CraneAILabs/ganda-gemma-1b")
Translate to Luganda
prompt = "Translate to Luganda: Hello, how are you today?"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_length=100, temperature=0.3)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
I got this response
Translate to Luganda: Hello, how are you today?
@sulaimank this seems a little strange, I can't recreate it on my end. Can you rerun the command a couple of times and let us know if its consistent?
I actually ran the quick start code in the model card. I was testing it out. Though it seems to return the prompt itself on my side.
Here is the quick start code I ran from the model card
from transformers import AutoModelForCausalLM, AutoTokenizer
Load model and tokenizer
model = AutoModelForCausalLM.from_pretrained("CraneAILabs/ganda-gemma-1b")
tokenizer = AutoTokenizer.from_pretrained("CraneAILabs/ganda-gemma-1b")
Translate to Luganda
prompt = "Translate to Luganda: Hello, how are you today?"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_length=100, temperature=0.3)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
@sulaimank we're going to advise you to try the pipeline example for now as we figure this out.
It seems to be inconsistently happening across different machines.