Text Generation
Transformers
Safetensors
llama
function-calling
conversational
text-generation-inference
Instructions to use fireworks-ai/llama-3-firefunction-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use fireworks-ai/llama-3-firefunction-v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="fireworks-ai/llama-3-firefunction-v2") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("fireworks-ai/llama-3-firefunction-v2") model = AutoModelForCausalLM.from_pretrained("fireworks-ai/llama-3-firefunction-v2") 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]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use fireworks-ai/llama-3-firefunction-v2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "fireworks-ai/llama-3-firefunction-v2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "fireworks-ai/llama-3-firefunction-v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/fireworks-ai/llama-3-firefunction-v2
- SGLang
How to use fireworks-ai/llama-3-firefunction-v2 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 "fireworks-ai/llama-3-firefunction-v2" \ --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": "fireworks-ai/llama-3-firefunction-v2", "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 "fireworks-ai/llama-3-firefunction-v2" \ --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": "fireworks-ai/llama-3-firefunction-v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use fireworks-ai/llama-3-firefunction-v2 with Docker Model Runner:
docker model run hf.co/fireworks-ai/llama-3-firefunction-v2
Update tokenizer_config.json
Browse files- tokenizer_config.json +1 -1
tokenizer_config.json
CHANGED
|
@@ -2052,7 +2052,7 @@
|
|
| 2052 |
"bos_token": "<|begin_of_text|>",
|
| 2053 |
"chat_template": "{%- set loop_messages = messages -%}\n{%- set message_roles = ['system', 'user', 'assistant', 'tool'] -%}\n{%- set system_prompt_suffix -%}\n{%- filter trim -%}\nIn addition to plain text responses, you can chose to call one or more of the provided functions.\n\nUse the following rule to decide when to call a function:\n * if the response can be generated from your internal knowledge (e.g., as in the case of queries like \"What is the capital of Poland?\"), do so\n * if you need external information that can be obtained by calling one or more of the provided functions, generate a function calls\n\nIf you decide to call functions:\n * prefix function calls with functools marker (no closing marker required)\n * all function calls should be generated in a single JSON list formatted as functools[{\"name\": [function name], \"arguments\": [function arguments as JSON]}, ...]\n * follow the provided JSON schema. Do not hallucinate arguments or values. Do to blindly copy values from the provided samples\n * respect the argument type formatting. E.g., if the type if number and format is float, write value 7 as 7.0\n * make sure you pick the right functions that match the user intent\n\nAvailable functions as JSON spec:\n{%- endfilter -%}\n{%- endset -%}\n{%- set system_prompt_suffix = system_prompt_suffix + \"\\n\" + functions -%}\n{%- set system_prompt_suffix = system_prompt_suffix + '\\nToday is ' + datetime + '.' -%}\n{%- set ns = namespace(role='', content='') -%}\n{#- Basic consistency checks -#}\n{%- if not loop_messages -%}\n {{ raise_exception('Expected non-empty messages') }}\n{%- endif -%}\n{%- for message in loop_messages -%}\n {%- set ns.role = message['role'] | lower -%}\n {%- if ns.role not in message_roles -%}\n {%- set message_roles_string = message_roles | join(', ') -%}\n {{ raise_exception('Invalid role ' + message['role'] + '. Only ' + message_roles_string + ' are supported.') }}\n {%- endif -%}\n {%- set msg_content = message['content'] | default('', true) | trim -%}\n {%- if loop.index0 == 0 -%}\n {%- if ns.role == 'system' -%}\n {%- set system_prompt = '<|start_header_id|>' + 'system' + '<|end_header_id|>\\n\\n' + message['content'] | trim + '\\n' + system_prompt_suffix + '<|eot_id|>' -%}\n {%- else -%}\n {%- set system_prompt = '<|start_header_id|>' + 'system' + '<|end_header_id|>\\n\\nYou are a helpful assistant with access to functions.\\n' + system_prompt_suffix + '<|eot_id|>' -%}\n {%- endif -%}\n {%- set ns.content = bos_token + system_prompt -%}\n {{- ns.content -}}\n {%- endif -%}\n {%- if loop.index0 > 0 or ns.role != 'system' -%}\n {%- set ns.content = '<|start_header_id|>' + ns.role + '<|end_header_id|>\\n\\n' + msg_content -%}\n {%- if 'tool_calls' in message and message['tool_calls'] -%}\n {%- set tool = namespace(calls=[]) -%}\n {%- for call in message['tool_calls'] -%}\n {%- set tool.calls = tool.calls + ['{\"name\": \"' + call['function']['name'] + '\", \"arguments\": ' + call['function']['arguments'] + '}'] -%}\n {%- endfor -%}\n {%- set ns.content = ns.content + ' functools[' + tool.calls | join(', ') + ']' -%}\n {%- endif -%}\n {%- set ns.content = ns.content + '<|eot_id|>' -%}\n {{- ns.content -}}\n {%- endif -%}\n{%- endfor -%}\n{{- '<|start_header_id|>assistant<|end_header_id|>\\n\\n' -}}\n",
|
| 2054 |
"clean_up_tokenization_spaces": true,
|
| 2055 |
-
"eos_token": "<|
|
| 2056 |
"legacy": false,
|
| 2057 |
"model_input_names": [
|
| 2058 |
"input_ids",
|
|
|
|
| 2052 |
"bos_token": "<|begin_of_text|>",
|
| 2053 |
"chat_template": "{%- set loop_messages = messages -%}\n{%- set message_roles = ['system', 'user', 'assistant', 'tool'] -%}\n{%- set system_prompt_suffix -%}\n{%- filter trim -%}\nIn addition to plain text responses, you can chose to call one or more of the provided functions.\n\nUse the following rule to decide when to call a function:\n * if the response can be generated from your internal knowledge (e.g., as in the case of queries like \"What is the capital of Poland?\"), do so\n * if you need external information that can be obtained by calling one or more of the provided functions, generate a function calls\n\nIf you decide to call functions:\n * prefix function calls with functools marker (no closing marker required)\n * all function calls should be generated in a single JSON list formatted as functools[{\"name\": [function name], \"arguments\": [function arguments as JSON]}, ...]\n * follow the provided JSON schema. Do not hallucinate arguments or values. Do to blindly copy values from the provided samples\n * respect the argument type formatting. E.g., if the type if number and format is float, write value 7 as 7.0\n * make sure you pick the right functions that match the user intent\n\nAvailable functions as JSON spec:\n{%- endfilter -%}\n{%- endset -%}\n{%- set system_prompt_suffix = system_prompt_suffix + \"\\n\" + functions -%}\n{%- set system_prompt_suffix = system_prompt_suffix + '\\nToday is ' + datetime + '.' -%}\n{%- set ns = namespace(role='', content='') -%}\n{#- Basic consistency checks -#}\n{%- if not loop_messages -%}\n {{ raise_exception('Expected non-empty messages') }}\n{%- endif -%}\n{%- for message in loop_messages -%}\n {%- set ns.role = message['role'] | lower -%}\n {%- if ns.role not in message_roles -%}\n {%- set message_roles_string = message_roles | join(', ') -%}\n {{ raise_exception('Invalid role ' + message['role'] + '. Only ' + message_roles_string + ' are supported.') }}\n {%- endif -%}\n {%- set msg_content = message['content'] | default('', true) | trim -%}\n {%- if loop.index0 == 0 -%}\n {%- if ns.role == 'system' -%}\n {%- set system_prompt = '<|start_header_id|>' + 'system' + '<|end_header_id|>\\n\\n' + message['content'] | trim + '\\n' + system_prompt_suffix + '<|eot_id|>' -%}\n {%- else -%}\n {%- set system_prompt = '<|start_header_id|>' + 'system' + '<|end_header_id|>\\n\\nYou are a helpful assistant with access to functions.\\n' + system_prompt_suffix + '<|eot_id|>' -%}\n {%- endif -%}\n {%- set ns.content = bos_token + system_prompt -%}\n {{- ns.content -}}\n {%- endif -%}\n {%- if loop.index0 > 0 or ns.role != 'system' -%}\n {%- set ns.content = '<|start_header_id|>' + ns.role + '<|end_header_id|>\\n\\n' + msg_content -%}\n {%- if 'tool_calls' in message and message['tool_calls'] -%}\n {%- set tool = namespace(calls=[]) -%}\n {%- for call in message['tool_calls'] -%}\n {%- set tool.calls = tool.calls + ['{\"name\": \"' + call['function']['name'] + '\", \"arguments\": ' + call['function']['arguments'] + '}'] -%}\n {%- endfor -%}\n {%- set ns.content = ns.content + ' functools[' + tool.calls | join(', ') + ']' -%}\n {%- endif -%}\n {%- set ns.content = ns.content + '<|eot_id|>' -%}\n {{- ns.content -}}\n {%- endif -%}\n{%- endfor -%}\n{{- '<|start_header_id|>assistant<|end_header_id|>\\n\\n' -}}\n",
|
| 2054 |
"clean_up_tokenization_spaces": true,
|
| 2055 |
+
"eos_token": "<|eot_id|>",
|
| 2056 |
"legacy": false,
|
| 2057 |
"model_input_names": [
|
| 2058 |
"input_ids",
|