Text Generation
Transformers
Safetensors
PyTorch
GGUF
English
llama
facebook
meta
llama-2
function-calling
function calling
conversational
text-generation-inference
Instructions to use Trelis/Llama-2-7b-chat-hf-function-calling-v3 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Trelis/Llama-2-7b-chat-hf-function-calling-v3 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Trelis/Llama-2-7b-chat-hf-function-calling-v3") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Trelis/Llama-2-7b-chat-hf-function-calling-v3") model = AutoModelForCausalLM.from_pretrained("Trelis/Llama-2-7b-chat-hf-function-calling-v3") 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 Settings
- vLLM
How to use Trelis/Llama-2-7b-chat-hf-function-calling-v3 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Trelis/Llama-2-7b-chat-hf-function-calling-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": "Trelis/Llama-2-7b-chat-hf-function-calling-v3", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Trelis/Llama-2-7b-chat-hf-function-calling-v3
- SGLang
How to use Trelis/Llama-2-7b-chat-hf-function-calling-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 "Trelis/Llama-2-7b-chat-hf-function-calling-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": "Trelis/Llama-2-7b-chat-hf-function-calling-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 "Trelis/Llama-2-7b-chat-hf-function-calling-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": "Trelis/Llama-2-7b-chat-hf-function-calling-v3", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Trelis/Llama-2-7b-chat-hf-function-calling-v3 with Docker Model Runner:
docker model run hf.co/Trelis/Llama-2-7b-chat-hf-function-calling-v3
Commit ·
be631f4
1
Parent(s): 50dfeeb
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,14 +1,4 @@
|
|
| 1 |
---
|
| 2 |
-
extra_gated_heading: Access Llama 2 on Hugging Face
|
| 3 |
-
extra_gated_description: >-
|
| 4 |
-
This is a form to enable access to Llama 2 on Hugging Face after you have been
|
| 5 |
-
granted access from Meta. Please visit the [Meta website](https://ai.meta.com/resources/models-and-libraries/llama-downloads) and accept our
|
| 6 |
-
license terms and acceptable use policy before submitting this form. Requests
|
| 7 |
-
will be processed in 1-2 days.
|
| 8 |
-
extra_gated_prompt: "**Your Hugging Face account email address MUST match the email you provide on the Meta website, or your request will not be approved.**"
|
| 9 |
-
extra_gated_button_content: Submit
|
| 10 |
-
extra_gated_fields:
|
| 11 |
-
I agree to share my name, email address and username with Meta and confirm that I have already been granted download access on the Meta website: checkbox
|
| 12 |
language:
|
| 13 |
- en
|
| 14 |
pipeline_tag: text-generation
|
|
@@ -21,6 +11,91 @@ tags:
|
|
| 21 |
- llama
|
| 22 |
- llama-2
|
| 23 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
# **Llama 2**
|
| 25 |
Llama 2 is a collection of pretrained and fine-tuned generative text models ranging in scale from 7 billion to 70 billion parameters. This is the repository for the 7B fine-tuned model, optimized for dialogue use cases and converted for the Hugging Face Transformers format. Links to other models can be found in the index at the bottom.
|
| 26 |
|
|
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
language:
|
| 3 |
- en
|
| 4 |
pipeline_tag: text-generation
|
|
|
|
| 11 |
- llama
|
| 12 |
- llama-2
|
| 13 |
---
|
| 14 |
+
# Function Calling Fine-tuned Llama 2 Chat
|
| 15 |
+
|
| 16 |
+
The model is suitable for commercial use and is licensed with the Llama 2 Community license.
|
| 17 |
+
|
| 18 |
+
Check out other fine-tuned function calling models [here](https://trelis.com/function-calling/).
|
| 19 |
+
|
| 20 |
+
## Inference Scripts
|
| 21 |
+
Out-of-the-box inference scripts are available for purchase [here](https://trelis.com/enterprise-server-api-and-inference-guide/).
|
| 22 |
+
|
| 23 |
+
## Prompt Format
|
| 24 |
+
```
|
| 25 |
+
B_FUNC, E_FUNC = "You have access to the following functions. Use them if required:\n\n", "\n\n"
|
| 26 |
+
B_INST, E_INST = "[INST] ", " [/INST]" #Llama style
|
| 27 |
+
prompt = f"{E_INST}{B_FUNC}{functionList.strip()}{E_FUNC}{B_INST}{user_prompt.strip()}{E_INST}\n\n"
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
## Sample Prompt and Response:
|
| 31 |
+
```
|
| 32 |
+
[INST] You have access to the following functions. Use them if required:
|
| 33 |
+
|
| 34 |
+
[
|
| 35 |
+
{
|
| 36 |
+
"type": "function",
|
| 37 |
+
"function": {
|
| 38 |
+
"name": "get_big_stocks",
|
| 39 |
+
"description": "Get the names of the largest N stocks by market cap",
|
| 40 |
+
"parameters": {
|
| 41 |
+
"type": "object",
|
| 42 |
+
"properties": {
|
| 43 |
+
"number": {
|
| 44 |
+
"type": "integer",
|
| 45 |
+
"description": "The number of largest stocks to get the names of, e.g. 25"
|
| 46 |
+
},
|
| 47 |
+
"region": {
|
| 48 |
+
"type": "string",
|
| 49 |
+
"description": "The region to consider, can be \"US\" or \"World\"."
|
| 50 |
+
}
|
| 51 |
+
},
|
| 52 |
+
"required": [
|
| 53 |
+
"number"
|
| 54 |
+
]
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
},
|
| 58 |
+
{
|
| 59 |
+
"type": "function",
|
| 60 |
+
"function": {
|
| 61 |
+
"name": "get_stock_price",
|
| 62 |
+
"description": "Get the stock price of an array of stocks",
|
| 63 |
+
"parameters": {
|
| 64 |
+
"type": "object",
|
| 65 |
+
"properties": {
|
| 66 |
+
"names": {
|
| 67 |
+
"type": "array",
|
| 68 |
+
"items": {
|
| 69 |
+
"type": "string"
|
| 70 |
+
},
|
| 71 |
+
"description": "An array of stocks"
|
| 72 |
+
}
|
| 73 |
+
},
|
| 74 |
+
"required": [
|
| 75 |
+
"names"
|
| 76 |
+
]
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
]
|
| 81 |
+
|
| 82 |
+
[INST] Get the names of the five largest stocks in the US by market cap [/INST]
|
| 83 |
+
|
| 84 |
+
{
|
| 85 |
+
"name": "get_big_stocks",
|
| 86 |
+
"arguments": {
|
| 87 |
+
"number": 5,
|
| 88 |
+
"region": "US"
|
| 89 |
+
}
|
| 90 |
+
}</s>
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
# Dataset
|
| 94 |
+
See [Trelis/function_calling_v3](https://huggingface.co/datasets/Trelis/function_calling_v3).
|
| 95 |
+
|
| 96 |
+
~~~
|
| 97 |
+
The original repo card follows below.
|
| 98 |
+
~~~
|
| 99 |
# **Llama 2**
|
| 100 |
Llama 2 is a collection of pretrained and fine-tuned generative text models ranging in scale from 7 billion to 70 billion parameters. This is the repository for the 7B fine-tuned model, optimized for dialogue use cases and converted for the Hugging Face Transformers format. Links to other models can be found in the index at the bottom.
|
| 101 |
|