Update README.md
Browse files
README.md
CHANGED
|
@@ -16,7 +16,7 @@ Leanstral consists of the following architectural choices:
|
|
| 16 |
|
| 17 |
- MoE: 128 experts and 4 active.
|
| 18 |
- 119B with 6.5B activated parameters per token.
|
| 19 |
-
-
|
| 20 |
- Multimodal Input: Accepts both text and image input, with text output.
|
| 21 |
|
| 22 |
Leanstral offers the following capabilities:
|
|
@@ -29,6 +29,399 @@ Leanstral offers the following capabilities:
|
|
| 29 |
- **Apache 2.0 License**: Open-source license allowing usage and modification for both commercial and non-commercial purposes.
|
| 30 |
- **Large Context Window**: Supports a 256k context window.
|
| 31 |
|
| 32 |
-
##
|
| 33 |
|
| 34 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
- MoE: 128 experts and 4 active.
|
| 18 |
- 119B with 6.5B activated parameters per token.
|
| 19 |
+
- 200k Context Length.
|
| 20 |
- Multimodal Input: Accepts both text and image input, with text output.
|
| 21 |
|
| 22 |
Leanstral offers the following capabilities:
|
|
|
|
| 29 |
- **Apache 2.0 License**: Open-source license allowing usage and modification for both commercial and non-commercial purposes.
|
| 30 |
- **Large Context Window**: Supports a 256k context window.
|
| 31 |
|
| 32 |
+
## Usage
|
| 33 |
|
| 34 |
+
### Scaffolding
|
| 35 |
+
|
| 36 |
+
We recommend using `Leanstral 119B A6B` with [Mistral Vibe](https://github.com/mistralai/mistral-vibe).
|
| 37 |
+
|
| 38 |
+
... TODO
|
| 39 |
+
|
| 40 |
+
### Local Deployment
|
| 41 |
+
|
| 42 |
+
The model can also be deployed with the following libraries, we advise everyone to use the Mistral AI API if the model is subpar with local serving:
|
| 43 |
+
- [`vllm (recommended)`](https://github.com/vllm-project/vllm): See [here](#vllm-recommended)
|
| 44 |
+
- [`transformers`](https://github.com/huggingface/transformers): WIP ⏳ - follow updates on this PR: ....
|
| 45 |
+
|
| 46 |
+
#### vLLM (recommended)
|
| 47 |
+
|
| 48 |
+
<details>
|
| 49 |
+
<summary>Expand</summary
|
| 50 |
+
|
| 51 |
+
We recommend using this model with the [vLLM library](https://github.com/vllm-project/vllm)
|
| 52 |
+
to implement production-ready inference pipelines.
|
| 53 |
+
|
| 54 |
+
**_Installation_**
|
| 55 |
+
|
| 56 |
+
Please make sure to install latest vLLM:
|
| 57 |
+
|
| 58 |
+
```
|
| 59 |
+
uv pip install -U vllm
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
Alternatively you can also directly use the latest docker image [vllm/vllm-openai:latest](https://hub.docker.com/layers/vllm/vllm-openai/latest/):
|
| 63 |
+
|
| 64 |
+
```
|
| 65 |
+
docker pull vllm/vllm-openai:latest
|
| 66 |
+
docker run -it vllm/vllm-openai:latest
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
Also make sure to have installed [`mistral_common >= 1.8.6`](https://github.com/mistralai/mistral-common/releases/tag/v1.8.6).
|
| 70 |
+
To check:
|
| 71 |
+
```
|
| 72 |
+
python -c "import mistral_common; print(mistral_common.__version__)"
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
**_Launch server_**
|
| 76 |
+
|
| 77 |
+
We recommand that you use Devstral in a server/client setting.
|
| 78 |
+
|
| 79 |
+
1. Spin up a server:
|
| 80 |
+
|
| 81 |
+
```
|
| 82 |
+
vllm serve mistralai/Leanstral-2603 \
|
| 83 |
+
--max-model-len 200000 \
|
| 84 |
+
--tensor-parallel-size 4 \
|
| 85 |
+
--attention-backend FLASH_ATTN_MLA \
|
| 86 |
+
--tool-call-parser mistral \
|
| 87 |
+
--enable-auto-tool-choice \
|
| 88 |
+
--reasoning-parser mistral
|
| 89 |
+
```
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
2. To ping the client you can use a simple Python snippet.
|
| 93 |
+
|
| 94 |
+
```py
|
| 95 |
+
import requests
|
| 96 |
+
import json
|
| 97 |
+
from huggingface_hub import hf_hub_download
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
url = "http://<your-hostname>/v1/chat/completions"
|
| 101 |
+
headers = {"Content-Type": "application/json", "Authorization": "Bearer token"}
|
| 102 |
+
|
| 103 |
+
model = "mistralai/Leanstral-2603"
|
| 104 |
+
|
| 105 |
+
prompt = """Define the transition rules as an inductive proposition.
|
| 106 |
+
|
| 107 |
+
This choice provides better support for proving properties about valid transitions and is generally more natural for modeling state machines in Lean, where you want to express logical rules rather than just computing a yes/no vale for each possible transition."""
|
| 108 |
+
|
| 109 |
+
messages = [
|
| 110 |
+
{
|
| 111 |
+
"role": "user",
|
| 112 |
+
"content": [
|
| 113 |
+
{
|
| 114 |
+
"type": "text",
|
| 115 |
+
"text": prompt,
|
| 116 |
+
},
|
| 117 |
+
],
|
| 118 |
+
},
|
| 119 |
+
]
|
| 120 |
+
|
| 121 |
+
# or switch to 'reasoning_effort': "none" for faster answers
|
| 122 |
+
data = {"model": model, "messages": messages, "temperature": 1.0, "reasoning_effort": "high"}
|
| 123 |
+
|
| 124 |
+
# Devstral 2 supports tool calling. If you want to use tools, follow this:
|
| 125 |
+
# tools = [ # Define tools for vLLM
|
| 126 |
+
# {
|
| 127 |
+
# "type": "function",
|
| 128 |
+
# "function": {
|
| 129 |
+
# "name": "git_clone",
|
| 130 |
+
# "description": "Clone a git repository",
|
| 131 |
+
# "parameters": {
|
| 132 |
+
# "type": "object",
|
| 133 |
+
# "properties": {
|
| 134 |
+
# "url": {
|
| 135 |
+
# "type": "string",
|
| 136 |
+
# "description": "The url of the git repository",
|
| 137 |
+
# },
|
| 138 |
+
# },
|
| 139 |
+
# "required": ["url"],
|
| 140 |
+
# },
|
| 141 |
+
# },
|
| 142 |
+
# }
|
| 143 |
+
# ]
|
| 144 |
+
# data = {"model": model, "messages": messages, "temperature": 0.15, "tools": tools} # Pass tools to payload.
|
| 145 |
+
|
| 146 |
+
response = requests.post(url, headers=headers, data=json.dumps(data))
|
| 147 |
+
import ipdb; ipdb.set_trace()
|
| 148 |
+
print(response.json()["choices"][0]["message"]["content"])
|
| 149 |
+
```
|
| 150 |
+
</details>
|
| 151 |
+
|
| 152 |
+
#### SGLang
|
| 153 |
+
|
| 154 |
+
<details>
|
| 155 |
+
<summary>Expand</summary>
|
| 156 |
+
|
| 157 |
+
To use this model with [SGLang](https://github.com/sgl-project/sglang) to implement a production-ready inference pipelines (OpenAI-compatible API server),
|
| 158 |
+
see the following sections.
|
| 159 |
+
|
| 160 |
+
**_Installation_**
|
| 161 |
+
|
| 162 |
+
Install SGLang from source (track latest `main` locally):
|
| 163 |
+
|
| 164 |
+
```
|
| 165 |
+
git clone https://github.com/sgl-project/sglang.git
|
| 166 |
+
cd sglang
|
| 167 |
+
uv pip install -e python
|
| 168 |
+
uv pip install transformers==5.0.0rc # required
|
| 169 |
+
```
|
| 170 |
+
|
| 171 |
+
**_Launch server_**
|
| 172 |
+
|
| 173 |
+
We recommend that you use Devstral in a server/client setting.
|
| 174 |
+
|
| 175 |
+
1. Spin up a server:
|
| 176 |
+
|
| 177 |
+
```
|
| 178 |
+
python -m sglang.launch_server --model-path mistralai/Devstral-2-123B-Instruct-2512 --host 0.0.0.0 --port 30000 --tp 8 --tool-call-parser mistral
|
| 179 |
+
```
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
2. To ping the client you can use a simple Python snippet.
|
| 183 |
+
|
| 184 |
+
```py
|
| 185 |
+
import requests
|
| 186 |
+
import json
|
| 187 |
+
from huggingface_hub import hf_hub_download
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
url = "http://<your-server-url>:30000/v1/chat/completions"
|
| 191 |
+
headers = {"Content-Type": "application/json", "Authorization": "Bearer token"}
|
| 192 |
+
|
| 193 |
+
model = "mistralai/Devstral-2-123B-Instruct-2512"
|
| 194 |
+
|
| 195 |
+
def load_system_prompt(repo_id: str, filename: str) -> str:
|
| 196 |
+
file_path = hf_hub_download(repo_id=repo_id, filename=filename)
|
| 197 |
+
with open(file_path, "r") as file:
|
| 198 |
+
system_prompt = file.read()
|
| 199 |
+
return system_prompt
|
| 200 |
+
|
| 201 |
+
SYSTEM_PROMPT = load_system_prompt(model, "CHAT_SYSTEM_PROMPT.txt")
|
| 202 |
+
|
| 203 |
+
messages = [
|
| 204 |
+
{"role": "system", "content": SYSTEM_PROMPT},
|
| 205 |
+
{
|
| 206 |
+
"role": "user",
|
| 207 |
+
"content": [
|
| 208 |
+
{
|
| 209 |
+
"type": "text",
|
| 210 |
+
"text": "<your-command>",
|
| 211 |
+
},
|
| 212 |
+
],
|
| 213 |
+
},
|
| 214 |
+
]
|
| 215 |
+
|
| 216 |
+
data = {"model": model, "messages": messages, "temperature": 0.15}
|
| 217 |
+
|
| 218 |
+
# Devstral 2 supports tool calling. If you want to use tools, follow this:
|
| 219 |
+
# tools = [ # Define tools (OpenAI-compatible)
|
| 220 |
+
# {
|
| 221 |
+
# "type": "function",
|
| 222 |
+
# "function": {
|
| 223 |
+
# "name": "git_clone",
|
| 224 |
+
# "description": "Clone a git repository",
|
| 225 |
+
# "parameters": {
|
| 226 |
+
# "type": "object",
|
| 227 |
+
# "properties": {
|
| 228 |
+
# "url": {
|
| 229 |
+
# "type": "string",
|
| 230 |
+
# "description": "The url of the git repository",
|
| 231 |
+
# },
|
| 232 |
+
# },
|
| 233 |
+
# "required": ["url"],
|
| 234 |
+
# },
|
| 235 |
+
# },
|
| 236 |
+
# }
|
| 237 |
+
# ]
|
| 238 |
+
# data = {"model": model, "messages": messages, "temperature": 0.15, "tools": tools} # Pass tools to payload.
|
| 239 |
+
|
| 240 |
+
response = requests.post(url, headers=headers, data=json.dumps(data))
|
| 241 |
+
print(response.json()["choices"][0]["message"]["content"])
|
| 242 |
+
```
|
| 243 |
+
</details>
|
| 244 |
+
|
| 245 |
+
#### Transformers
|
| 246 |
+
|
| 247 |
+
<details>
|
| 248 |
+
<summary>Expand</summary
|
| 249 |
+
|
| 250 |
+
Make sure to install from main:
|
| 251 |
+
|
| 252 |
+
```sh
|
| 253 |
+
uv pip install git+https://github.com/huggingface/transformers
|
| 254 |
+
```
|
| 255 |
+
|
| 256 |
+
And run the following code snippet:
|
| 257 |
+
|
| 258 |
+
```python
|
| 259 |
+
from transformers import (
|
| 260 |
+
MistralForCausalLM,
|
| 261 |
+
MistralCommonBackend,
|
| 262 |
+
)
|
| 263 |
+
|
| 264 |
+
model_id = "mistralai/Devstral-2-123B-Instruct-2512"
|
| 265 |
+
|
| 266 |
+
tokenizer = MistralCommonBackend.from_pretrained(model_id)
|
| 267 |
+
model = MistralForCausalLM.from_pretrained(model_id, device_map="auto")
|
| 268 |
+
|
| 269 |
+
SP = """You are operating as and within Mistral Vibe, a CLI coding-agent built by Mistral AI and powered by default by the Devstral family of models. It wraps Mistral's Devstral models to enable natural language interaction with a local codebase. Use the available tools when helpful.
|
| 270 |
+
|
| 271 |
+
You can:
|
| 272 |
+
|
| 273 |
+
- Receive user prompts, project context, and files.
|
| 274 |
+
- Send responses and emit function calls (e.g., shell commands, code edits).
|
| 275 |
+
- Apply patches, run commands, based on user approvals.
|
| 276 |
+
|
| 277 |
+
Answer the user's request using the relevant tool(s), if they are available. Check that all the required parameters for each tool call are provided or can reasonably be inferred from context. IF there are no relevant tools or there are missing values for required parameters, ask the user to supply these values; otherwise proceed with the tool calls. If the user provides a specific value for a parameter (for example provided in quotes), make sure to use that value EXACTLY. DO NOT make up values for or ask about optional parameters. Carefully analyze descriptive terms in the request as they may indicate required parameter values that should be included even if not explicitly quoted.
|
| 278 |
+
|
| 279 |
+
Always try your hardest to use the tools to answer the user's request. If you can't use the tools, explain why and ask the user for more information.
|
| 280 |
+
|
| 281 |
+
Act as an agentic assistant, if a user asks for a long task, break it down and do it step by step.
|
| 282 |
+
|
| 283 |
+
When you want to commit changes, you will always use the 'git commit' bash command. It will always be suffixed with a line telling it was generated by Mistral Vibe with the appropriate co-authoring information. The format you will always use is the following heredoc.
|
| 284 |
+
|
| 285 |
+
```bash
|
| 286 |
+
git commit -m "<Commit message here>
|
| 287 |
+
|
| 288 |
+
Generated by Mistral Vibe.
|
| 289 |
+
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>"
|
| 290 |
+
```"""
|
| 291 |
+
|
| 292 |
+
input = {
|
| 293 |
+
"messages": [
|
| 294 |
+
{
|
| 295 |
+
"role": "system",
|
| 296 |
+
"content": SP,
|
| 297 |
+
},
|
| 298 |
+
{
|
| 299 |
+
"role": "user",
|
| 300 |
+
"content": [
|
| 301 |
+
{
|
| 302 |
+
"type": "text",
|
| 303 |
+
"text": "Can you implement in Python a method to compute the fibonnaci sequence at the `n`th element with `n` a parameter passed to the function ? You should start the sequence from 1, previous values are invalid.\nThen run the Python code for the function for n=5 and give the answer.",
|
| 304 |
+
}
|
| 305 |
+
],
|
| 306 |
+
},
|
| 307 |
+
],
|
| 308 |
+
"tools": [
|
| 309 |
+
{
|
| 310 |
+
"type": "function",
|
| 311 |
+
"function": {
|
| 312 |
+
"name": "add_number",
|
| 313 |
+
"description": "Add two numbers.",
|
| 314 |
+
"parameters": {
|
| 315 |
+
"type": "object",
|
| 316 |
+
"properties": {
|
| 317 |
+
"a": {"type": "string", "description": "The first number."},
|
| 318 |
+
"b": {"type": "string", "description": "The second number."},
|
| 319 |
+
},
|
| 320 |
+
"required": ["a", "b"],
|
| 321 |
+
},
|
| 322 |
+
},
|
| 323 |
+
},
|
| 324 |
+
{
|
| 325 |
+
"type": "function",
|
| 326 |
+
"function": {
|
| 327 |
+
"name": "multiply_number",
|
| 328 |
+
"description": "Multiply two numbers.",
|
| 329 |
+
"parameters": {
|
| 330 |
+
"type": "object",
|
| 331 |
+
"properties": {
|
| 332 |
+
"a": {"type": "string", "description": "The first number."},
|
| 333 |
+
"b": {"type": "string", "description": "The second number."},
|
| 334 |
+
},
|
| 335 |
+
"required": ["a", "b"],
|
| 336 |
+
},
|
| 337 |
+
},
|
| 338 |
+
},
|
| 339 |
+
{
|
| 340 |
+
"type": "function",
|
| 341 |
+
"function": {
|
| 342 |
+
"name": "substract_number",
|
| 343 |
+
"description": "Substract two numbers.",
|
| 344 |
+
"parameters": {
|
| 345 |
+
"type": "object",
|
| 346 |
+
"properties": {
|
| 347 |
+
"a": {"type": "string", "description": "The first number."},
|
| 348 |
+
"b": {"type": "string", "description": "The second number."},
|
| 349 |
+
},
|
| 350 |
+
"required": ["a", "b"],
|
| 351 |
+
},
|
| 352 |
+
},
|
| 353 |
+
},
|
| 354 |
+
{
|
| 355 |
+
"type": "function",
|
| 356 |
+
"function": {
|
| 357 |
+
"name": "write_a_story",
|
| 358 |
+
"description": "Write a story about science fiction and people with badass laser sabers.",
|
| 359 |
+
"parameters": {},
|
| 360 |
+
},
|
| 361 |
+
},
|
| 362 |
+
{
|
| 363 |
+
"type": "function",
|
| 364 |
+
"function": {
|
| 365 |
+
"name": "terminal",
|
| 366 |
+
"description": "Perform operations from the terminal.",
|
| 367 |
+
"parameters": {
|
| 368 |
+
"type": "object",
|
| 369 |
+
"properties": {
|
| 370 |
+
"command": {
|
| 371 |
+
"type": "string",
|
| 372 |
+
"description": "The command you wish to launch, e.g `ls`, `rm`, ...",
|
| 373 |
+
},
|
| 374 |
+
"args": {
|
| 375 |
+
"type": "string",
|
| 376 |
+
"description": "The arguments to pass to the command.",
|
| 377 |
+
},
|
| 378 |
+
},
|
| 379 |
+
"required": ["command"],
|
| 380 |
+
},
|
| 381 |
+
},
|
| 382 |
+
},
|
| 383 |
+
{
|
| 384 |
+
"type": "function",
|
| 385 |
+
"function": {
|
| 386 |
+
"name": "python",
|
| 387 |
+
"description": "Call a Python interpreter with some Python code that will be ran.",
|
| 388 |
+
"parameters": {
|
| 389 |
+
"type": "object",
|
| 390 |
+
"properties": {
|
| 391 |
+
"code": {
|
| 392 |
+
"type": "string",
|
| 393 |
+
"description": "The Python code to run",
|
| 394 |
+
},
|
| 395 |
+
"result_variable": {
|
| 396 |
+
"type": "string",
|
| 397 |
+
"description": "Variable containing the result you'd like to retrieve from the execution.",
|
| 398 |
+
},
|
| 399 |
+
},
|
| 400 |
+
"required": ["code", "result_variable"],
|
| 401 |
+
},
|
| 402 |
+
},
|
| 403 |
+
},
|
| 404 |
+
],
|
| 405 |
+
}
|
| 406 |
+
|
| 407 |
+
tokenized = tokenizer.apply_chat_template(
|
| 408 |
+
conversation=input["messages"],
|
| 409 |
+
tools=input["tools"],
|
| 410 |
+
return_tensors="pt",
|
| 411 |
+
return_dict=True,
|
| 412 |
+
)
|
| 413 |
+
|
| 414 |
+
input_ids = tokenized["input_ids"].to(device="cuda")
|
| 415 |
+
|
| 416 |
+
output = model.generate(
|
| 417 |
+
input_ids,
|
| 418 |
+
max_new_tokens=200,
|
| 419 |
+
do_sample=True,
|
| 420 |
+
temperature=0.15,
|
| 421 |
+
)[0]
|
| 422 |
+
|
| 423 |
+
decoded_output = tokenizer.decode(output[len(tokenized["input_ids"][0]) :])
|
| 424 |
+
print(decoded_output)
|
| 425 |
+
```
|
| 426 |
+
|
| 427 |
+
</details>
|