Text Generation
Transformers
Safetensors
English
llama
Merge
axolotl
conversational
text-generation-inference
Instructions to use minpeter/Llama-3.2-1B-chatml-tool-v3 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use minpeter/Llama-3.2-1B-chatml-tool-v3 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="minpeter/Llama-3.2-1B-chatml-tool-v3") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("minpeter/Llama-3.2-1B-chatml-tool-v3") model = AutoModelForCausalLM.from_pretrained("minpeter/Llama-3.2-1B-chatml-tool-v3", 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 minpeter/Llama-3.2-1B-chatml-tool-v3 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "minpeter/Llama-3.2-1B-chatml-tool-v3" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "minpeter/Llama-3.2-1B-chatml-tool-v3", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/minpeter/Llama-3.2-1B-chatml-tool-v3
- SGLang
How to use minpeter/Llama-3.2-1B-chatml-tool-v3 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 "minpeter/Llama-3.2-1B-chatml-tool-v3" \ --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": "minpeter/Llama-3.2-1B-chatml-tool-v3", "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 "minpeter/Llama-3.2-1B-chatml-tool-v3" \ --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": "minpeter/Llama-3.2-1B-chatml-tool-v3", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use minpeter/Llama-3.2-1B-chatml-tool-v3 with Docker Model Runner:
docker model run hf.co/minpeter/Llama-3.2-1B-chatml-tool-v3
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 <tools> </tools> 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.
<tools>
[{"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"}]
</tools>
For each function call return a json object with function name and arguments within <tool_call> </tool_call> tags with the following schema:
<tool_call>
{'arguments': <args-dict>, 'name': <function-name>}
</tool_call><|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:
Token: Ċ ID: 198
Token: <tool_call> 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: </tool_call> ID: 128014
Generated text:
<tool_call>
{'arguments': {'location': 'Boston', 'unit': 'fahrenheit'}, 'name': 'get_current_weather'
</tool_call>
- Downloads last month
- 13
Model tree for minpeter/Llama-3.2-1B-chatml-tool-v3
Merge model
this model