Text Generation
Transformers
Safetensors
Finnish
llama
finnish
conversational
text-generation-inference
Instructions to use Finnish-NLP/Ahma-3B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Finnish-NLP/Ahma-3B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Finnish-NLP/Ahma-3B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Finnish-NLP/Ahma-3B") model = AutoModelForCausalLM.from_pretrained("Finnish-NLP/Ahma-3B", device_map="auto") 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 Finnish-NLP/Ahma-3B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Finnish-NLP/Ahma-3B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Finnish-NLP/Ahma-3B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Finnish-NLP/Ahma-3B
- SGLang
How to use Finnish-NLP/Ahma-3B 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 "Finnish-NLP/Ahma-3B" \ --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": "Finnish-NLP/Ahma-3B", "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 "Finnish-NLP/Ahma-3B" \ --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": "Finnish-NLP/Ahma-3B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Finnish-NLP/Ahma-3B with Docker Model Runner:
docker model run hf.co/Finnish-NLP/Ahma-3B
File size: 2,301 Bytes
5a63fc6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | #! /bin/bash
# Put your WANDB API key here to enable logging to wandb.
export WANDB_API_KEY=''
# TPU specific flags to improve training throughput
export LIBTPU_INIT_ARGS='--xla_jf_spmd_threshold_for_windowed_einsum_mib=0 --xla_tpu_spmd_threshold_for_allgather_cse=10000 --xla_tpu_spmd_rewrite_einsum_with_reshape=true --xla_enable_async_all_gather=true --jax_enable_async_collective_offload=true --xla_tpu_enable_latency_hiding_scheduler=true TPU_MEGACORE=MEGACORE_DENSE'
python3 -m EasyLM.models.llama.llama_train \
--jax_distributed.initialize_jax_distributed=True \
--mesh_dim='1,-1,1' \
--dtype='bf16' \
--total_steps=900000 \
--eval_freq=50000 \
--log_freq=1000 \
--save_model_freq=2000 \
--save_milestone_freq=50000 \
--load_llama_config='3b' \
--update_llama_config='' \
--load_dataset_state='' \
--load_checkpoint='' \
--tokenizer.pretrained_model_name_or_path='./' \
--optimizer.type='lion' \
--optimizer.lion_optimizer.weight_decay=1.0 \
--optimizer.lion_optimizer.lr_schedule_type='warmup_constant' \
--optimizer.lion_optimizer.lr=3e-4 \
--optimizer.lion_optimizer.end_lr=3e-5 \
--optimizer.lion_optimizer.lr_warmup_steps=60000 \
--optimizer.lion_optimizer.lr_decay_steps=100000 \
--optimizer.lion_optimizer.bf16_momentum=True \
--train_dataset.type='huggingface' \
--train_dataset.text_processor.fields='text' \
--train_dataset.huggingface_dataset.path='/researchdisk/lm_training_dataset_first_stage' \
--train_dataset.huggingface_dataset.split='train' \
--train_dataset.huggingface_dataset.seq_length=2048 \
--train_dataset.huggingface_dataset.batch_size=64 \
--eval_dataset.type='huggingface' \
--eval_dataset.text_processor.fields='text' \
--eval_dataset.huggingface_dataset.path='/researchdisk/lm_training_dataset_first_stage' \
--eval_dataset.huggingface_dataset.split='validation' \
--eval_dataset.huggingface_dataset.seq_length=2048 \
--eval_dataset.huggingface_dataset.batch_size=64 \
--checkpointer.save_optimizer_state=True \
--logger.online=True \
--logger.prefix='EasyLM' \
--logger.project="llama-3b-finnish-v2" \
--logger.output_dir="gs://finnish-nlp-research-us/llama-3b-v2-checkpoint" \
--logger.wandb_dir="./"
|