File size: 3,243 Bytes
213e0b4 5e161be 213e0b4 a476a93 213e0b4 e03b89d 1af414b 213e0b4 e03b89d 57c662c 213e0b4 57c662c e03b89d 57c662c 213e0b4 57c662c 5e161be |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
---
license: apache-2.0
language:
- ja
programming_language:
- Python
pipeline_tag: text-generation
library_name: mlx
inference: false
base_model: mlx-community/llm-jp-3.1-1.8b-instruct4-4bit
datasets:
- nappa0326/glaive-function-calling-v2-sharegpt-japanese
---
# aipib/llm-jp-3.1-1.8b-function-calling
The Model [aipib/llm-jp-3.1-1.8b-function-calling](https://huggingface.co/aipib/llm-jp-3.1-1.8b-function-calling) was
finetuned with [nappa0326/glaive-function-calling-v2-sharegpt-japanese](https://huggingface.co/datasets/nappa0326/glaive-function-calling-v2-sharegpt-japanese) dataset
from [mlx-community/llm-jp-3.1-1.8b-instruct4-4bit](https://huggingface.co/mlx-community/llm-jp-3.1-1.8b-instruct4-4bit).
## Use with mlx
You need to convert this model to mlx model with mlx-lm.convert. Otherwise, please refer to [the Llama3.2 tool-calling method](https://github.com/huggingface/huggingface-llama-recipes/tree/main/tool_calling) or call this model from some Agent.
```bash
pip install mlx-lm
```
```python
from mlx_lm import load, generate
model, tokenizer = load("aipib/llm-jp-3.1-1.8b-function-calling")
prompt="""<bos><start_of_turn>user
あなたは関数呼び出しAIモデルです。<tools></tools> XMLタグ内に関数シグネチャが提供されます。ユーザークエリを支援するために、1つ以上の関数を呼び出すことができます。関数に代入する値について、想定しないでください。使用可能なツールは次のとおりです:<tools> [{'type': 'function', 'function': {'name': 'convert_currency', 'description': 'ある通貨から別の通貨に変換する', 'parameters': {'type': 'object', 'properties': {'amount': {'type': 'number', 'description': '変換する金額'}, 'from_currency': {'type': 'string', 'description': '変換元の通貨'}, 'to_currency': {'type': 'string', 'description': '変換後の通貨'}}, 'required': ['amount', 'from_currency', 'to_currency']}}}, {'type': 'function', 'function': {'name': 'calculate_distance', 'description': '2つの場所間の距離を計算します', 'parameters': {'type': 'object', 'properties': {'start_location': {'type': 'string', 'description': '開始場所'}, 'end_location': {'type': 'string', 'description': '終了場所'}}, 'required': ['start_location', 'end_location']}}}] </tools>各ツール呼び出しには、次の pydantic モデル JSON スキーマを使用します: {'title': 'FunctionCall', 'type': 'object', 'properties': {'arguments': {'title': 'Arguments', 'type': 'object'}, 'name': {'title': 'Name', 'type': 'string'}}, 'required': ['arguments', 'name']}関数呼び出しごとに、関数名と引数を含むJSONオブジェクトを、<tool_call></tool_call> XMLタグ内に以下のように記述して返します。
<tool_call>
{tool_call}
</tool_call>また、関数を呼び出す前に、関数が実行する処理について時間をかけて計画を立ててください。<think>{あなたの考え}
こんにちは。500米ドルをユーロに両替したいのですが、手伝っていただけますか?<end_of_turn><eos>
<start_of_turn>assistant
<think>"""
response = generate(model, tokenizer, prompt=prompt, verbose=True, max_tokens=1000)
``` |