Text Generation
Transformers
Safetensors
mistral
function-call
conversational
text-generation-inference
Instructions to use InterSync/Mistral-7B-Instruct-v0.2-Function-Calling with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use InterSync/Mistral-7B-Instruct-v0.2-Function-Calling with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="InterSync/Mistral-7B-Instruct-v0.2-Function-Calling") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("InterSync/Mistral-7B-Instruct-v0.2-Function-Calling") model = AutoModelForCausalLM.from_pretrained("InterSync/Mistral-7B-Instruct-v0.2-Function-Calling", 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use InterSync/Mistral-7B-Instruct-v0.2-Function-Calling with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "InterSync/Mistral-7B-Instruct-v0.2-Function-Calling" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "InterSync/Mistral-7B-Instruct-v0.2-Function-Calling", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/InterSync/Mistral-7B-Instruct-v0.2-Function-Calling
- SGLang
How to use InterSync/Mistral-7B-Instruct-v0.2-Function-Calling 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 "InterSync/Mistral-7B-Instruct-v0.2-Function-Calling" \ --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": "InterSync/Mistral-7B-Instruct-v0.2-Function-Calling", "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 "InterSync/Mistral-7B-Instruct-v0.2-Function-Calling" \ --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": "InterSync/Mistral-7B-Instruct-v0.2-Function-Calling", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use InterSync/Mistral-7B-Instruct-v0.2-Function-Calling with Docker Model Runner:
docker model run hf.co/InterSync/Mistral-7B-Instruct-v0.2-Function-Calling
Update README.md
Browse files
README.md
CHANGED
|
@@ -53,33 +53,7 @@ tools = [
|
|
| 53 |
"required": ["location", "format"],
|
| 54 |
},
|
| 55 |
}
|
| 56 |
-
}
|
| 57 |
-
{
|
| 58 |
-
"type": "function",
|
| 59 |
-
"function": {
|
| 60 |
-
"name": "get_n_day_weather_forecast",
|
| 61 |
-
"description": "Get an N-day weather forecast",
|
| 62 |
-
"parameters": {
|
| 63 |
-
"type": "object",
|
| 64 |
-
"properties": {
|
| 65 |
-
"location": {
|
| 66 |
-
"type": "string",
|
| 67 |
-
"description": "The city and state, e.g. San Francisco, CA",
|
| 68 |
-
},
|
| 69 |
-
"format": {
|
| 70 |
-
"type": "string",
|
| 71 |
-
"enum": ["celsius", "fahrenheit"],
|
| 72 |
-
"description": "The temperature unit to use. Infer this from the user's location.",
|
| 73 |
-
},
|
| 74 |
-
"num_days": {
|
| 75 |
-
"type": "integer",
|
| 76 |
-
"description": "The number of days to forecast",
|
| 77 |
-
}
|
| 78 |
-
},
|
| 79 |
-
"required": ["location", "format", "num_days"]
|
| 80 |
-
},
|
| 81 |
-
}
|
| 82 |
-
},
|
| 83 |
]
|
| 84 |
```
|
| 85 |
|
|
@@ -107,10 +81,9 @@ messages = [
|
|
| 107 |
},
|
| 108 |
{
|
| 109 |
"role": "user",
|
| 110 |
-
"content": "What is the current weather in San Francisco?
|
| 111 |
},
|
| 112 |
]
|
| 113 |
-
|
| 114 |
```
|
| 115 |
|
| 116 |
### Preparing Model Inputs
|
|
@@ -122,14 +95,15 @@ model_inputs = inputs.to(device)
|
|
| 122 |
### Generating the Response
|
| 123 |
```python
|
| 124 |
model.to(device)
|
| 125 |
-
|
| 126 |
generate_ids = model.generate(model_inputs, streamer=streamer, do_sample=True, max_length=4096)
|
| 127 |
decoded = tokenizer.batch_decode(generate_ids)
|
| 128 |
```
|
| 129 |
|
| 130 |
### Output
|
| 131 |
```python
|
| 132 |
-
|
|
|
|
|
|
|
| 133 |
```
|
| 134 |
|
| 135 |
|
|
|
|
| 53 |
"required": ["location", "format"],
|
| 54 |
},
|
| 55 |
}
|
| 56 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
]
|
| 58 |
```
|
| 59 |
|
|
|
|
| 81 |
},
|
| 82 |
{
|
| 83 |
"role": "user",
|
| 84 |
+
"content": "What is the current weather in San Francisco?"
|
| 85 |
},
|
| 86 |
]
|
|
|
|
| 87 |
```
|
| 88 |
|
| 89 |
### Preparing Model Inputs
|
|
|
|
| 95 |
### Generating the Response
|
| 96 |
```python
|
| 97 |
model.to(device)
|
|
|
|
| 98 |
generate_ids = model.generate(model_inputs, streamer=streamer, do_sample=True, max_length=4096)
|
| 99 |
decoded = tokenizer.batch_decode(generate_ids)
|
| 100 |
```
|
| 101 |
|
| 102 |
### Output
|
| 103 |
```python
|
| 104 |
+
<tool_call>
|
| 105 |
+
{"arguments": {"location": "San Francisco, CA", "format": "celsius"}, "name": "get_current_weather"}
|
| 106 |
+
</tool_call>
|
| 107 |
```
|
| 108 |
|
| 109 |
|