Run this model with HF Jobs
Run Finnish-NLP/Ahma-3B on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/Finnish-NLP/Ahma-3B. Ask me which dataset to train on, then push the LoRA adapter to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs and Transformers to run batch inference with https://huggingface.co/Finnish-NLP/Ahma-3B on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the predictions back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs and Lighteval to evaluate https://huggingface.co/Finnish-NLP/Ahma-3B. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/Finnish-NLP/Ahma-3B with Transformers and bitsandbytes. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
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)# pip install -U transformers accelerate # 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=256) 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
Improve model card: add `library_name` and primary paper link
Browse filesThis PR improves the model card by:
- Adding `library_name: transformers` to the metadata, which enables the "How to use" widget on the model page and ensures better integration with the Hugging Face ecosystem.
- Adding a prominent link to the paper [Scaling Data-Constrained Language Models](https://huggingface.co/papers/2305.16264), where this model was explicitly presented. This provides crucial context for users visiting the model page.
123456789101112131415161718192021222338 unmodified lines6263646566676875 unmodified lines144145146147148149150151152153154155156157158159160161162163164165166167168169170---language:- filicense: apache-2.0tags:- finnish- llamadatasets:- Finnish-NLP/CulturaX_fi_cleaned- Finnish-NLP/HPLT_1.2_fi_cleaned- Finnish-NLP/wikipedia_20231101_fi_cleaned- Finnish-NLP/Reddit_fi_2006_2022- intfloat/multilingual_cc_newsinference: falsepipeline_tag: text-generation---# Ahma-3B for FinnishAhma-3B is 3B parameter decoder-only transformer model based on Meta's Llama (v1) architecture pretrained from scratch on Finnish language. Original Llama model architecture was introduced in[this paper](https://arxiv.org/abs/2302.13971)and first released at [this page](https://github.com/facebookresearch/llama).38 unmodified linesdef format_prompt(prompt: str) -> str:prompt = f" [INST] <<SYS>>\n{system_prompt.strip()}\n<</SYS>>\n\n{prompt.strip()} [/INST] "return prompt75 unmodified linesThe first stage:|Dataset | Words | Ratio ||:-----------------------------|:------------|:-------------||CulturaX | 12.820B | 59.88\% ||HPLT v1.2 | 5.034B | 23.51\% ||Suomi24 | 3.018B | 14.09\% ||Reddit | 0.141B | 0.66\% ||CC-News | 0.311B | 1.45\% ||FI news corpus | 0.004B | 0.02\% ||Project Lönnrot | 0.083B | 0.39\% ||**TOTAL** | **21.410B** | **100.0\%** |The second stage:|Dataset | Words | Ratio ||:--------------------------------------------------------------|:------------|:------------||CulturaX (cleaner sample using KenLM perplexity score) | 2.252B | 55.48\% ||Wikipedia | 0.095B | 2.34\% ||STT | 0.253B | 6.23\% ||Yle | 0.212B | 5.22\% ||Finnish parliament speeches | 0.021B | 0.52\% ||Finnish higher education public theses | 0.855B | 21.07\% ||Finnish instruction-following datasets (note: 2X upsampled) | 0.371B | 9.14\% ||**TOTAL** | **4.059B** | **100.0\%** |## Training procedure1234567891011121314151617181920212223242538 unmodified lines646566676869707172737475 unmodified lines150151152153154155156157158159160161162163164165166167168169170171172173174175176---datasets:- Finnish-NLP/CulturaX_fi_cleaned- Finnish-NLP/HPLT_1.2_fi_cleaned- Finnish-NLP/wikipedia_20231101_fi_cleaned- Finnish-NLP/Reddit_fi_2006_2022- intfloat/multilingual_cc_newslanguage:- filicense: apache-2.0pipeline_tag: text-generationtags:- finnish- llamainference: falselibrary_name: transformers---# Ahma-3B for FinnishThis model was presented in the paper [Scaling Data-Constrained Language Models](https://huggingface.co/papers/2305.16264).Ahma-3B is 3B parameter decoder-only transformer model based on Meta's Llama (v1) architecture pretrained from scratch on Finnish language. Original Llama model architecture was introduced in[this paper](https://arxiv.org/abs/2302.13971)and first released at [this page](https://github.com/facebookresearch/llama).38 unmodified linesdef format_prompt(prompt: str) -> str:prompt = f" [INST] <<SYS>>{system_prompt.strip()}<</SYS>>{prompt.strip()} [/INST] "return prompt75 unmodified linesThe first stage:|Dataset | Words | Ratio ||:-----------------------------|:------------|:-------------||CulturaX | 12.820B | 59.88% ||HPLT v1.2 | 5.034B | 23.51% ||Suomi24 | 3.018B | 14.09% ||Reddit | 0.141B | 0.66% ||CC-News | 0.311B | 1.45% ||FI news corpus | 0.004B | 0.02% ||Project Lönnrot | 0.083B | 0.39% ||**TOTAL** | **21.410B** | **100.0%** |The second stage:|Dataset | Words | Ratio ||:--------------------------------------------------------------|:------------|:------------||CulturaX (cleaner sample using KenLM perplexity score) | 2.252B | 55.48% ||Wikipedia | 0.095B | 2.34% ||STT | 0.253B | 6.23% ||Yle | 0.212B | 5.22% ||Finnish parliament speeches | 0.021B | 0.52% ||Finnish higher education public theses | 0.855B | 21.07% ||Finnish instruction-following datasets (note: 2X upsampled) | 0.371B | 9.14% ||**TOTAL** | **4.059B** | **100.0%** |## Training procedure