---
license: llama3.2
language:
- en
base_model:
- minpeter/QLoRA-Llama-3.2-1B-chatml-tool-v3
- minpeter/Llama-3.2-1B-AlternateTokenizer-tool-chatml
pipeline_tag: text-generation
library_name: transformers
tags:
- merge
- axolotl
---
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "minpeter/Llama-3.2-1B-chatml-tool-v3"
model = AutoModelForCausalLM.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
input_text = """<|im_start|>system
You are a function calling AI model. You are provided with function signatures within XML tags. You may call one or more functions to assist with the user query. Don't make assumptions about what values to plug into functions.
[{"function": {"description": "Get the current weather in a given location", "name": "get_current_weather", "parameters": {"properties": {"location": {"description": "The city and state, e.g. San Francisco, CA", "type": "string"}, "unit": {"enum": ["celsius", "fahrenheit"], "type": "string"}}, "required": ["location"], "type": "object"}}, "type": "function"}]
For each function call return a json object with function name and arguments within tags with the following schema:
{'arguments': , 'name': }
<|im_end|>
<|im_start|>user
What is the weather like in Boston?<|im_end|>
<|im_start|>assistant
"""
input_length = len(tokenizer.tokenize(input_text))
input_ids = tokenizer.encode(input_text, return_tensors="pt")
output = model.generate(input_ids, max_new_tokens=600)
generated_ids = output[0][input_length:]
generated_text = tokenizer.decode(generated_ids, skip_special_tokens=True)
tokens = tokenizer.tokenize(generated_text)
token_ids = tokenizer.convert_tokens_to_ids(tokens)
for token, id in zip(tokens, token_ids):
print(f"Token: {token:20} ID: {id}")
print(f"\nGenerated text:\n{generated_text}")
```
Output:
```text
Token: Ċ ID: 198
Token: ID: 128013
Token: Ċ ID: 198
Token: {' ID: 13922
Token: arguments ID: 16774
Token: ': ID: 1232
Token: Ġ{' ID: 5473
Token: location ID: 2588
Token: ': ID: 1232
Token: Ġ' ID: 364
Token: Boston ID: 65432
Token: ', ID: 518
Token: Ġ' ID: 364
Token: unit ID: 3928
Token: ': ID: 1232
Token: Ġ' ID: 364
Token: f ID: 69
Token: ahrenheit ID: 49010
Token: '}, ID: 25762
Token: Ġ' ID: 364
Token: name ID: 609
Token: ': ID: 1232
Token: Ġ' ID: 364
Token: get ID: 456
Token: _current ID: 11327
Token: _weather ID: 70464
Token: 'Ċ ID: 1270
Token: ID: 128014
Generated text:
{'arguments': {'location': 'Boston', 'unit': 'fahrenheit'}, 'name': 'get_current_weather'
```