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
fix autotokenizer
Browse files- tokenizer.json +20 -9
- tokenizer_config.json +5 -5
tokenizer.json
CHANGED
|
@@ -37,7 +37,7 @@
|
|
| 37 |
"lstrip": false,
|
| 38 |
"rstrip": false,
|
| 39 |
"normalized": false,
|
| 40 |
-
"special":
|
| 41 |
},
|
| 42 |
{
|
| 43 |
"id": 4,
|
|
@@ -46,7 +46,7 @@
|
|
| 46 |
"lstrip": false,
|
| 47 |
"rstrip": false,
|
| 48 |
"normalized": false,
|
| 49 |
-
"special":
|
| 50 |
},
|
| 51 |
{
|
| 52 |
"id": 5,
|
|
@@ -55,7 +55,7 @@
|
|
| 55 |
"lstrip": false,
|
| 56 |
"rstrip": false,
|
| 57 |
"normalized": false,
|
| 58 |
-
"special":
|
| 59 |
},
|
| 60 |
{
|
| 61 |
"id": 6,
|
|
@@ -64,15 +64,26 @@
|
|
| 64 |
"lstrip": false,
|
| 65 |
"rstrip": false,
|
| 66 |
"normalized": false,
|
| 67 |
-
"special":
|
| 68 |
}
|
| 69 |
],
|
| 70 |
-
"normalizer":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
"pre_tokenizer": {
|
| 72 |
-
"type": "
|
| 73 |
-
"
|
| 74 |
-
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
},
|
| 77 |
"post_processor": {
|
| 78 |
"type": "TemplateProcessing",
|
|
|
|
| 37 |
"lstrip": false,
|
| 38 |
"rstrip": false,
|
| 39 |
"normalized": false,
|
| 40 |
+
"special": true
|
| 41 |
},
|
| 42 |
{
|
| 43 |
"id": 4,
|
|
|
|
| 46 |
"lstrip": false,
|
| 47 |
"rstrip": false,
|
| 48 |
"normalized": false,
|
| 49 |
+
"special": true
|
| 50 |
},
|
| 51 |
{
|
| 52 |
"id": 5,
|
|
|
|
| 55 |
"lstrip": false,
|
| 56 |
"rstrip": false,
|
| 57 |
"normalized": false,
|
| 58 |
+
"special": true
|
| 59 |
},
|
| 60 |
{
|
| 61 |
"id": 6,
|
|
|
|
| 64 |
"lstrip": false,
|
| 65 |
"rstrip": false,
|
| 66 |
"normalized": false,
|
| 67 |
+
"special": true
|
| 68 |
}
|
| 69 |
],
|
| 70 |
+
"normalizer": {
|
| 71 |
+
"type": "Replace",
|
| 72 |
+
"pattern": {
|
| 73 |
+
"Regex": " {2,}"
|
| 74 |
+
},
|
| 75 |
+
"content": "▁"
|
| 76 |
+
},
|
| 77 |
"pre_tokenizer": {
|
| 78 |
+
"type": "Sequence",
|
| 79 |
+
"pretokenizers": [
|
| 80 |
+
{
|
| 81 |
+
"type": "Metaspace",
|
| 82 |
+
"replacement": "▁",
|
| 83 |
+
"prepend_scheme": "first",
|
| 84 |
+
"split": false
|
| 85 |
+
}
|
| 86 |
+
]
|
| 87 |
},
|
| 88 |
"post_processor": {
|
| 89 |
"type": "TemplateProcessing",
|
tokenizer_config.json
CHANGED
|
@@ -33,7 +33,7 @@
|
|
| 33 |
"normalized": false,
|
| 34 |
"rstrip": false,
|
| 35 |
"single_word": false,
|
| 36 |
-
"special":
|
| 37 |
},
|
| 38 |
"4": {
|
| 39 |
"content": "[/INST]",
|
|
@@ -41,7 +41,7 @@
|
|
| 41 |
"normalized": false,
|
| 42 |
"rstrip": false,
|
| 43 |
"single_word": false,
|
| 44 |
-
"special":
|
| 45 |
},
|
| 46 |
"5": {
|
| 47 |
"content": "<<SYS>>",
|
|
@@ -49,7 +49,7 @@
|
|
| 49 |
"normalized": false,
|
| 50 |
"rstrip": false,
|
| 51 |
"single_word": false,
|
| 52 |
-
"special":
|
| 53 |
},
|
| 54 |
"6": {
|
| 55 |
"content": "<</SYS>>",
|
|
@@ -57,7 +57,7 @@
|
|
| 57 |
"normalized": false,
|
| 58 |
"rstrip": false,
|
| 59 |
"single_word": false,
|
| 60 |
-
"special":
|
| 61 |
}
|
| 62 |
},
|
| 63 |
"bos_token": "<s>",
|
|
@@ -69,7 +69,7 @@
|
|
| 69 |
"pad_token": null,
|
| 70 |
"sp_model_kwargs": {},
|
| 71 |
"spaces_between_special_tokens": false,
|
| 72 |
-
"tokenizer_class": "
|
| 73 |
"unk_token": "<unk>",
|
| 74 |
"use_default_system_prompt": false
|
| 75 |
}
|
|
|
|
| 33 |
"normalized": false,
|
| 34 |
"rstrip": false,
|
| 35 |
"single_word": false,
|
| 36 |
+
"special": true
|
| 37 |
},
|
| 38 |
"4": {
|
| 39 |
"content": "[/INST]",
|
|
|
|
| 41 |
"normalized": false,
|
| 42 |
"rstrip": false,
|
| 43 |
"single_word": false,
|
| 44 |
+
"special": true
|
| 45 |
},
|
| 46 |
"5": {
|
| 47 |
"content": "<<SYS>>",
|
|
|
|
| 49 |
"normalized": false,
|
| 50 |
"rstrip": false,
|
| 51 |
"single_word": false,
|
| 52 |
+
"special": true
|
| 53 |
},
|
| 54 |
"6": {
|
| 55 |
"content": "<</SYS>>",
|
|
|
|
| 57 |
"normalized": false,
|
| 58 |
"rstrip": false,
|
| 59 |
"single_word": false,
|
| 60 |
+
"special": true
|
| 61 |
}
|
| 62 |
},
|
| 63 |
"bos_token": "<s>",
|
|
|
|
| 69 |
"pad_token": null,
|
| 70 |
"sp_model_kwargs": {},
|
| 71 |
"spaces_between_special_tokens": false,
|
| 72 |
+
"tokenizer_class": "PreTrainedTokenizerFast",
|
| 73 |
"unk_token": "<unk>",
|
| 74 |
"use_default_system_prompt": false
|
| 75 |
}
|